Now saves title of torrent

Possibly need to move thetitle to an intermediate media struct
Need to create an interface to use so that new torrent structs can be implemented outside of library
This commit is contained in:
lordwelch 2017-07-16 13:11:35 -07:00
parent bf03aa8942
commit 3107df1045

35
type.go
View File

@ -48,8 +48,7 @@ type Torrent struct {
type TorrentVideo struct {
*Torrent
Episode string
Season string
Title string
Release string
Source Src
Format Fmt
@ -60,6 +59,12 @@ type TorrentVideo struct {
P720 bool
}
type TorrentEpisode struct {
*TorrentVideo
Episode string
Season string
}
func NewTorrent(mt MetaTorrent) (T *Torrent) {
T = new(Torrent)
if mt.Info.Length == 0 {
@ -130,17 +135,21 @@ func (T *TorrentVideo) Process() error {
case "DVD":
T.Source = DVD
}
}
switch {
case re[0].MatchString(str):
tag = true
match := re[0].FindStringSubmatch(str)
T.Season = match[1]
T.Episode = match[2]
case re[1].MatchString(str):
match := re[1].FindStringSubmatch(str)
T.Release = match[1]
T.Creator = match[2]
if re[1].MatchString(str) {
match := re[1].FindStringSubmatch(str)
T.Release = match[1]
T.Creator = match[2]
}
} else {
if re[0].MatchString(str) {
tag = true
match := re[0].FindStringSubmatch(str)
T.Season = match[1]
T.Episode = match[2]
} else {
T.Title += str
}
}
fmt.Println(re[1])
fmt.Printf("tag: %t\n", re[1].MatchString(str))