TorrentFilter/main.go

53 lines
1.3 KiB
Go
Raw Normal View History

package main
import (
"bufio"
"fmt"
2017-06-20 12:25:19 -07:00
"os"
"os/exec"
"path"
2017-06-20 12:25:19 -07:00
"github.com/alexflint/go-arg"
)
var (
current_torrents [][]TorrentVideo
)
func main() {
2017-06-20 12:25:19 -07:00
var args struct {
P720 bool `arg:"-7,help:Do not select 720p file if another exists."`
NUKED bool `arg:"-N,help:Allow NUKED files."`
DIVX bool `arg:"help:Prefer DivX encoding if available. Default x264"`
PROPER bool `arg:"help:Do not prefer PROPER FILES."`
INTERNAL bool `arg:"help:Prefer INTERNAL files."`
RELEASE string `arg:"-r,help:Release group preference order. Comma seperated."`
SHOW []string `arg:"positional,help:TV show to download"`
NEW bool `arg:"-n,help:Only modify new torrents"`
PATH string `arg:"-P,help:Path to torrent files"`
2017-06-20 12:25:19 -07:00
}
arg.MustParse(&args)
scnr := bufio.NewScanner(os.Stdin)
for err == nil {
if !scnr.scan() {
panic("fail")
}
exec.Command("wget", scnr.Text(), "-o", args.PATH+'/')
process(args.PATH + '/' + path.Base(scnr.Text()))
}
2017-06-20 12:25:19 -07:00
}
func process(torrentFile string) *TorrentVideo {
var (
mt *MetaTorrent = new(MetaTorrent)
vt *TorrentVideo = new(TorrentVideo)
)
f, _ := os.OpenFile(torrentFile, os.O_RDONLY, 755)
mt.Load(f)
fmt.Printf("%+v\n", mt)
vt.Torrent = NewTorrent(*mt)
vt.Process()
fmt.Printf("%+v\n", *vt)
return vt
}