TorrentFilter/main.go

52 lines
1.1 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 SeriesTorrent
)
func main() {
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)
scanner := bufio.NewScanner(os.Stdin)
for err == nil {
if !scanner.Scan() {
panic("fail")
}
exec.Command("wget", scanner.Text(), "-o", args.PATH+"/")
process(args.PATH + "/" + path.Base(scanner.Text()))
}
2017-06-20 12:25:19 -07:00
}
func process(torrentFile string) *MediaTorrent {
2017-06-20 12:25:19 -07:00
var (
mt *MetaTorrent = new(MetaTorrent)
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
}