Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import youtube_dl
- import pandas as pd
- import os
- import traceback
- def download2(id):
- id = "09R8_2nJtjg"
- options = {
- 'format': 'bestaudio/best', # choice of quality
- 'extractaudio' : True, # only keep the audio
- 'audioformat' : "mp3", # convert to mp3
- 'outtmpl': 'converted/%(title)s.mp3', # name the file the ID of the video
- 'noplaylist' : True, # only download single song, not playlist
- }
- with youtube_dl.YoutubeDL(options) as ydl:
- ydl.download(['https://www.youtube.com/watch?v=' + id])
- if __name__ == '__main__':
- # create directory
- savedir = "converted"
- if not os.path.exists(savedir):
- os.makedirs(savedir)
- download2("1")
Advertisement
Add Comment
Please, Sign In to add comment