From f3054da51b96db67634f89b08f3d84d93f6bb465 Mon Sep 17 00:00:00 2001 From: lordwelch Date: Sat, 17 Jun 2017 22:24:41 -0700 Subject: [PATCH] create struct for Video Torrents add function to get values from torrent metadata --- type.go | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/type.go b/type.go index f2360a5..f94500a 100644 --- a/type.go +++ b/type.go @@ -1,9 +1,25 @@ package main import ( + "strings" + "github.com/zeebo/bencode" ) +type Src int +type Fmt int +type Std int + +const ( + HDTV Src = iota + CAM + DVD + X264 Fmt = iota + Xvid + Ntsc Std = iota + Pal +) + type MetaTorrent struct { Announce string `bencode:"announce"` Announcelist [][]string `bencode:"announce-list"` @@ -22,5 +38,47 @@ type MetaTorrent struct { } type Torrent struct { - Name string + Name string + Comment string + Creator string + size int +} + +type TorrentVideo struct { + *Torrent + Release string + Source Src + Format Fmt + Standard Std + Retail bool + Proper bool + Internal bool + Dl bool + Recode bool + Repack bool + Nuked bool + p720 bool +} + +func NewTorrent(mt MetaTorrent) (T *Torrent) { + if mt.Info.Length == 0 { + for i, path := range mt.Info.Files { + for _, file := range path { + if file[len(file)-3:] == "mkv" || file[len(file)-3:] == "mp4" { + T.size = mt.Info.Files[i].Length + T.Name = file + } + } + } + } else { + T.Name = mt.Info.Name + T.size = mt.Info.Length + } + T.Comment = mt.Comment + T.Creator = mt.CreatedBy +} + +func (T TorrentVideo) Process() { + reader := strings.NewReader(T.Name) + }