Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import sys
- """
- Set the paths to Youtube-dl and where you want the files to download to
- """
- YTDL_PATH = 'youtube-dl.exe' # I put the py file where my .exe is
- DOWNLOAD_PATH = 'F:/Videos/'
- RANDOM_USERAGENT = True
- """
- Put urls on seperate lines like
- url1
- url2
- url3
- Also you can use # to comment out/disable a url from being downloaded - url1 will only be downloaded
- url1
- #url2
- #url3
- """
- STREAMS_PATH = 'streams.txt'
- """
- Username and password to login to said site if it requires it
- """
- USERNAME = 'username'
- PASSWORD = 'password'
- """
- Define subtitle stuff here
- """
- SUBTITLES_LANG = 'en'
- SUBTITLES_FORMAT = 'srt'
- """
- How long to wait before sending another request to download said content (helpful if said provider checks for bots mass downloading content)
- """
- MIN_SLEEP_TIME = 60
- MAX_SLEEP_TIME = 90
- def main():
- try:
- if os.path.isfile(YTDL_PATH):
- if os.path.isdir(DOWNLOAD_PATH):
- if os.path.isfile(STREAMS_PATH) and os.stat(STREAMS_PATH).st_size != 0:
- print('{+} Parsing streams')
- streams = open(STREAMS_PATH, 'r')
- for stream in streams:
- for url in stream.splitlines():
- if not url.startswith("#"):
- print('{*} Downloading '+url+' ...')
- if "youtube" in url:
- if "/playlist?list" in url:
- 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\"')
- else:
- os.system('start /min cmd.exe /c'+YTDL_PATH+' -f bestvideo+bestaudio '+url+' -o \"'+DOWNLOAD_PATH+'%(title)s.%(ext)s\"')
- elif "pluralsight" in url:
- 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')
- else:
- os.system('start /min cmd.exe /c'+YTDL_PATH+' '+url+' -o \"'+DOWNLOAD_PATH+'%(title)s.%(ext)s\"')
- else:
- print('{!} The '+STREAMS_PATH+' file doesn\'t exist or it\'s empty!')
- else:
- print('{!} The '+DOWNLOAD_PATH+' path doesn\'t exist!')
- else:
- print('{!} The '+YTDL_PATH+' file doesn\'t exist!')
- except Exception as e:
- print(e)
- print('{!!} Oh no! Something went wrong! Try again later!')
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement