From 3107df104519afe1908ce6117469008aed73d660 Mon Sep 17 00:00:00 2001 From: lordwelch Date: Sun, 16 Jul 2017 13:11:35 -0700 Subject: [PATCH] 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 --- type.go | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/type.go b/type.go index 8850328..08870f8 100644 --- a/type.go +++ b/type.go @@ -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))