Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pytube import YouTube
- from sys import argv
- from os import system
- DOWLOAD_LOCATION = 'videos/'
- MP3_LOCATION = 'mp3/'
- src = argv[1]
- if not(src):
- print "Error: Need to supply video source."
- yt = YouTube(src)
- target = yt.filter('mp4')[-1]
- print 'Now downloading: ' + target.filename
- target.download(DOWLOAD_LOCATION)
- print 'Download complete.\n'
- # start converting
- originMP4 = DOWLOAD_LOCATION + target.filename + '.mp4'
- newMP3Name = MP3_LOCATION + target.filename + '.mp3'
- print 'Now Converting to: ' + newMP3Name
- command = 'ffmpeg -i ' + '"' + originMP4 + '"' + ' -ab 128k ' + '"' + newMP3Name + '"'
- system(command)
- print 'Done Converting.\n'
- print 'Removing video.'
- system('rm ' + '"' + originMP4 + '"')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement