create struct for Video Torrents
add function to get values from torrent metadata
This commit is contained in:
parent
c1a5e4e667
commit
f3054da51b
60
type.go
60
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)
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user