Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. func TCDownload(magnet string) error {
  2. log.Printf("Starting dowload for `%s`\n", magnet)
  3. defer log.Printf("`%s` finished downloading", magnet)
  4. torrent, err := client.AddMagnet(magnet)
  5. if err != nil {
  6. return err
  7. }
  8. log.Println("Getting information")
  9. <-torrent.GotInfo() // do this so things don't whine
  10.  
  11. log.Println("Getting files")
  12. files := torrent.Files()
  13. if len(files) == 1 { // torrent is a single file so we download it all
  14. log.Println("Downloading all")
  15. torrent.DownloadAll()
  16. } else { // figure out which file is the video file
  17. log.Println("Not downloading all")
  18. for file := range files {
  19. println(file)
  20. }
  21. }
  22. client.WaitAll()
  23. return nil
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement