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 (
|
2017-07-22 22:53:12 -07:00
|
|
|
current_torrents SeriesTorrent
|
2017-06-17 02:11:46 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2017-07-23 23:21:25 -07:00
|
|
|
var (
|
|
|
|
err error
|
|
|
|
args struct {
|
|
|
|
RES string `arg:"help:Resolution preference [480/720/1080]"`
|
|
|
|
RELEASE []string `arg:"-r,help:Release group preference order."`
|
|
|
|
Series []string `arg:"required,positional,help:TV series 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)
|
2017-07-22 22:53:12 -07:00
|
|
|
scanner := bufio.NewScanner(os.Stdin)
|
2017-07-16 23:48:06 -07:00
|
|
|
for err == nil {
|
2017-07-23 23:21:25 -07:00
|
|
|
if !scanner.Scan() {
|
2017-07-16 23:48:06 -07:00
|
|
|
panic("fail")
|
|
|
|
}
|
2017-07-23 23:21:25 -07:00
|
|
|
exec.Command("wget", scanner.Text(), "-o", args.PATH+"/")
|
|
|
|
process(args.PATH + "/" + path.Base(scanner.Text()))
|
2017-07-16 23:48:06 -07:00
|
|
|
}
|
2017-06-20 12:25:19 -07:00
|
|
|
}
|
|
|
|
|
2017-07-23 23:21:25 -07:00
|
|
|
func process(torrentFile string) *MediaTorrent {
|
2017-06-20 12:25:19 -07:00
|
|
|
var (
|
|
|
|
mt *MetaTorrent = new(MetaTorrent)
|
2017-07-23 23:21:25 -07:00
|
|
|
vt *MediaTorrent = new(MediaTorrent)
|
2017-06-20 12:25:19 -07:00
|
|
|
)
|
|
|
|
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
|
|
|
}
|