2015-03-27 17:16:50 +11:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2015-04-08 02:15:25 +10:00
|
|
|
"flag"
|
2015-03-27 17:16:50 +11:00
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/anacrolix/torrent"
|
2015-04-30 00:31:34 +10:00
|
|
|
"github.com/anacrolix/torrent/metainfo"
|
2015-03-27 17:16:50 +11:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2015-04-08 02:15:25 +10:00
|
|
|
flag.Parse()
|
|
|
|
if flag.NArg() != 0 {
|
|
|
|
fmt.Fprintf(os.Stderr, "%s\n", "torrent-magnet: unexpected positional arguments")
|
|
|
|
os.Exit(2)
|
|
|
|
}
|
2015-03-27 17:16:50 +11:00
|
|
|
mi, err := metainfo.Load(os.Stdin)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Fprintf(os.Stderr, "error reading metainfo from stdin: %s", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
2016-04-03 08:51:46 -05:00
|
|
|
|
|
|
|
magnet := torrent.Magnetize(mi)
|
|
|
|
fmt.Fprintf(os.Stdout, "%s\n", magnet.String())
|
2015-03-27 17:16:50 +11:00
|
|
|
}
|