@@ -2,9 +2,9 @@ package main
22
33import (
44 "fmt"
5- // "time"
5+ "time"
66
7- // "github.com/dustin/go-humanize"
7+ "github.com/dustin/go-humanize"
88 "github.com/sweetbbak/toru/pkg/libtorrent"
99 "github.com/sweetbbak/toru/pkg/player"
1010 "github.com/sweetbbak/toru/pkg/search"
@@ -20,18 +20,18 @@ func StreamTorrent(torfile string, cl *libtorrent.Client) (string, error) {
2020 link := cl .ServeTorrent (t )
2121
2222 // consider deleting this as it sometimes conflicts with the fzf user interface
23- // go func() {
24- // for !t.Complete.Bool() {
25- // c := t.BytesCompleted()
26- // total := t.Length()
27- // s := humanize.Bytes(uint64(c))
28- // x := humanize.Bytes(uint64(total))
29- // numpeers := len(t.PeerConns())
30- // fmt.Printf("\x1b[2K\rDownloaded (%v/%v) from [%v] Peers...\n ", s, x, numpeers)
31- // time.Sleep(time.Millisecond * 500)
32- // }
33- // println("Complete")
34- // }()
23+ go func () {
24+ for ! t .Complete .Bool () {
25+ c := t .BytesCompleted ()
26+ total := t .Length ()
27+ s := humanize .Bytes (uint64 (c ))
28+ x := humanize .Bytes (uint64 (total ))
29+ numpeers := len (t .PeerConns ())
30+ fmt .Printf ("\x1b [2K\r Downloaded (%v/%v) from [%v] Peers..." , s , x , numpeers )
31+ time .Sleep (time .Millisecond * 500 )
32+ }
33+ println ("Complete" )
34+ }()
3535
3636 fmt .Println (link )
3737 return link , nil
0 commit comments