diff --git a/main.go b/main.go index 52b6c94..2743e2d 100644 --- a/main.go +++ b/main.go @@ -28,8 +28,13 @@ func main() { PATH string `arg:"-P,help:Path to torrent files"` } ) + arg.MustParse(&args) + if len(args.PATH < 1) { + args.PATH, _ = os.Getwd() + } unselectedDir = filepath.Clean(args.PATH + "/unselected/") + scanner := bufio.NewScanner(os.Stdin) for scanner.Scan() { url := strings.TrimSpace(scanner.Text()) @@ -50,7 +55,7 @@ func process(torrentFile string) *MediaTorrent { vt *MediaTorrent = new(MediaTorrent) ) f, _ := os.OpenFile(torrentFile, os.O_RDONLY, 755) - mt.Load(f) + mt.ReadFile(f) fmt.Printf("%+v\n", mt) vt.Torrent = NewTorrent(*mt) vt.Parse(vt.Name) diff --git a/type.go b/type.go index 0160a55..8798a6a 100644 --- a/type.go +++ b/type.go @@ -66,7 +66,7 @@ func NewTorrent(mt MetaTorrent) (T Torrent) { return T } -func (Mt *MetaTorrent) Load(r io.Reader) error { +func (Mt *MetaTorrent) ReadFile(r io.Reader) error { return bencode.NewDecoder(r).Decode(Mt) }