Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Cool script. Not sure if you are still improving it but I see one thing right away that you could create a dl_video method to eliminate the duplicate download video code. E.g.:
- def dl_video(link):
- download_video = link.streams().first()
- print('Download Started')
- download_video.download('videos/')
- # And while you're at it, a dl_audio:
- def dl_audio(link):
- download_mp3 = link.streams.filter(only_audio=True).first()
- print('Download Started')
- download_mp3.download('audio/')
- # So it'll look like this:
- ...
- while True:
- user = input('To Download Video/Audio Y/n: ')
- if user == 'Y':
- url = input('Enter Url: ')
- link = YouTube(url)
- form = input('Do you want to download video or audio: ')
- if form == 'video':
- dl_video(link)
- elif form == 'audio':
- warn = input('Audio Downloads take longer Do you want to Continue Y/n: ')
- if warn == 'Y':
- dl_audio(link)
- elif warn == 'n':
- vid = input('To Download Vid Y/n ')
- if vid == 'Y':
- dl_video(link)
- elif vid == 'n':
- exit()
- ...
Add Comment
Please, Sign In to add comment