2017-06-17 02:11:46 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2017-07-16 23:48:06 -07:00
|
|
|
"bufio"
|
2017-06-17 02:11:46 -07:00
|
|
|
"fmt"
|
2017-06-20 12:25:19 -07:00
|
|
|
"os"
|
2017-07-16 23:48:06 -07:00
|
|
|
"os/exec"
|
|
|
|
"path"
|
2017-06-20 12:25:19 -07:00
|
|
|
|
|
|
|
"github.com/alexflint/go-arg"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
current_torrents [][]TorrentVideo
|
2017-06-17 02:11:46 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
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"`
|
2017-07-16 23:48:06 -07:00
|
|
|
PATH string `arg:"-P,help:Path to torrent files"`
|
2017-06-20 12:25:19 -07:00
|
|
|
}
|
|
|
|
arg.MustParse(&args)
|
2017-07-16 23:48:06 -07:00
|
|
|
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
|
2017-06-17 02:11:46 -07:00
|
|
|
}
|