String() methods added for ParsedTorrent and Resolution
This commit is contained in:
parent
0378bec21c
commit
baf74b76eb
@ -1,6 +1,11 @@
|
||||
package model
|
||||
|
||||
import "git.milar.in/milarin/anilist"
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.milar.in/milarin/anilist"
|
||||
)
|
||||
|
||||
type ParsedTorrent struct {
|
||||
// parsed data
|
||||
@ -15,3 +20,13 @@ type ParsedTorrent struct {
|
||||
Torrent *Torrent
|
||||
Parser *Parser
|
||||
}
|
||||
|
||||
func (t ParsedTorrent) String() string {
|
||||
return fmt.Sprintf("title: %s | episode: %d | resolution: %s | languages: %s | subtitles: %s",
|
||||
t.Anime.Title.Native,
|
||||
t.Episode,
|
||||
t.Resolution,
|
||||
strings.Join(t.Languages, ", "),
|
||||
strings.Join(t.Subtitles, ", "),
|
||||
)
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
@ -30,3 +31,12 @@ func ParseResolution(str string) (Resolution, error) {
|
||||
return Resolution(v), err
|
||||
}
|
||||
}
|
||||
|
||||
func (r Resolution) String() string {
|
||||
switch r {
|
||||
case Resolution4K:
|
||||
return "4K"
|
||||
default:
|
||||
return fmt.Sprintf("%dp", r)
|
||||
}
|
||||
}
|
||||
|
28
torrent.go
28
torrent.go
@ -1,6 +1,9 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Torrent struct {
|
||||
ID TorrentID
|
||||
@ -14,3 +17,26 @@ type Torrent struct {
|
||||
}
|
||||
|
||||
type TorrentID string
|
||||
|
||||
func (t Torrent) String() string {
|
||||
return fmt.Sprintf("id: %s | title: %s | seeders: %d | leechers: %d | downloads: %d | trusted: %t | upload time: %s",
|
||||
t.ID,
|
||||
t.Title,
|
||||
t.Seeders,
|
||||
t.Leechers,
|
||||
t.Downloads,
|
||||
t.Trusted,
|
||||
t.Time.Format("2006-01-02 15:04:05"),
|
||||
)
|
||||
}
|
||||
|
||||
func (t Torrent) StringWithoutTitle() string {
|
||||
return fmt.Sprintf("id: %s | seeders: %d | leechers: %d | downloads: %d | trusted: %t | upload time: %s",
|
||||
t.ID,
|
||||
t.Seeders,
|
||||
t.Leechers,
|
||||
t.Downloads,
|
||||
t.Trusted,
|
||||
t.Time.Format("2006-01-02 15:04:05"),
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user