Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. from pytube import YouTube
  2. from sys import argv
  3. from os import system
  4.  
  5. DOWLOAD_LOCATION = 'videos/'
  6. MP3_LOCATION = 'mp3/'
  7.  
  8. src = argv[1]
  9.  
  10. if not(src):
  11. print "Error: Need to supply video source."
  12.  
  13. yt = YouTube(src)
  14.  
  15.  
  16. target = yt.filter('mp4')[-1]
  17.  
  18. print 'Now downloading: ' + target.filename
  19.  
  20. target.download(DOWLOAD_LOCATION)
  21.  
  22. print 'Download complete.\n'
  23.  
  24. # start converting
  25. originMP4 = DOWLOAD_LOCATION + target.filename + '.mp4'
  26. newMP3Name = MP3_LOCATION + target.filename + '.mp3'
  27.  
  28. print 'Now Converting to: ' + newMP3Name
  29.  
  30. command = 'ffmpeg -i ' + '"' + originMP4 + '"' + ' -ab 128k ' + '"' + newMP3Name + '"'
  31. system(command)
  32.  
  33. print 'Done Converting.\n'
  34.  
  35. print 'Removing video.'
  36. system('rm ' + '"' + originMP4 + '"')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement