tikimyster

youtube video to mp3 converter

Apr 6th, 2015
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. import youtube_dl
  2. import pandas as pd
  3. import os
  4. import traceback
  5.  
  6.  
  7. def download2(id):
  8.     id = "09R8_2nJtjg"
  9.     options = {
  10.         'format': 'bestaudio/best', # choice of quality
  11.         'extractaudio' : True,      # only keep the audio
  12.         'audioformat' : "mp3",      # convert to mp3
  13.         'outtmpl': 'converted/%(title)s.mp3',        # name the file the ID of the video
  14.         'noplaylist' : True,        # only download single song, not playlist
  15.     }
  16.     with youtube_dl.YoutubeDL(options) as ydl:
  17.         ydl.download(['https://www.youtube.com/watch?v=' + id])
  18.  
  19. if __name__ == '__main__':
  20.     # create directory
  21.     savedir = "converted"
  22.     if not os.path.exists(savedir):
  23.         os.makedirs(savedir)
  24.     download2("1")
Advertisement
Add Comment
Please, Sign In to add comment