Advertisement
Guest User

Untitled

a guest
May 13th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. import os
  2. import sys
  3.  
  4. """
  5. Set the paths to Youtube-dl and where you want the files to download to
  6. """
  7. YTDL_PATH = 'youtube-dl.exe' # I put the py file where my .exe is
  8. DOWNLOAD_PATH = 'F:/Videos/'
  9.  
  10. RANDOM_USERAGENT = True
  11.  
  12. """
  13. Put urls on seperate lines like
  14. url1
  15. url2
  16. url3
  17.  
  18. Also you can use # to comment out/disable a url from being downloaded - url1 will only be downloaded
  19. url1
  20. #url2
  21. #url3
  22. """
  23. STREAMS_PATH = 'streams.txt'
  24.  
  25. """
  26. Username and password to login to said site if it requires it
  27. """
  28. USERNAME = 'username'
  29. PASSWORD = 'password'
  30.  
  31. """
  32. Define subtitle stuff here
  33. """
  34. SUBTITLES_LANG = 'en'
  35. SUBTITLES_FORMAT = 'srt'
  36.  
  37. """
  38. How long to wait before sending another request to download said content (helpful if said provider checks for bots mass downloading content)
  39. """
  40. MIN_SLEEP_TIME = 60
  41. MAX_SLEEP_TIME = 90
  42.  
  43.  
  44. def main():
  45. try:
  46. if os.path.isfile(YTDL_PATH):
  47. if os.path.isdir(DOWNLOAD_PATH):
  48. if os.path.isfile(STREAMS_PATH) and os.stat(STREAMS_PATH).st_size != 0:
  49. print('{+} Parsing streams')
  50. streams = open(STREAMS_PATH, 'r')
  51.  
  52. for stream in streams:
  53. for url in stream.splitlines():
  54. if not url.startswith("#"):
  55. print('{*} Downloading '+url+' ...')
  56. if "youtube" in url:
  57. if "/playlist?list" in url:
  58. os.system('start /min cmd.exe /c'+YTDL_PATH+' -f bestvideo+bestaudio '+url+' -o \"'+DOWNLOAD_PATH+'%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s\"')
  59. else:
  60. os.system('start /min cmd.exe /c'+YTDL_PATH+' -f bestvideo+bestaudio '+url+' -o \"'+DOWNLOAD_PATH+'%(title)s.%(ext)s\"')
  61. elif "pluralsight" in url:
  62. os.system('start /min cmd.exe /c'+YTDL_PATH+' '+url+' --username '+USERNAME+' --password '+PASSWORD+' -o \"'+DOWNLOAD_PATH+'%(playlist)s/%(chapter_number)s - %(chapter)s/%(playlist_index)s - %(title)s.%(ext)s\" --sleep-interval '+str(MIN_SLEEP_TIME)+' --max-sleep-interval '+str(MAX_SLEEP_TIME)+' --sub-lang '+SUBTITLES_LANG+' --sub-format '+SUBTITLES_FORMAT+' --write-sub')
  63. else:
  64. os.system('start /min cmd.exe /c'+YTDL_PATH+' '+url+' -o \"'+DOWNLOAD_PATH+'%(title)s.%(ext)s\"')
  65. else:
  66. print('{!} The '+STREAMS_PATH+' file doesn\'t exist or it\'s empty!')
  67. else:
  68. print('{!} The '+DOWNLOAD_PATH+' path doesn\'t exist!')
  69. else:
  70. print('{!} The '+YTDL_PATH+' file doesn\'t exist!')
  71. except Exception as e:
  72. print(e)
  73. print('{!!} Oh no! Something went wrong! Try again later!')
  74.  
  75. if __name__ == '__main__':
  76. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement