So, it's not my code I found it on youtube tutorial(which I can't find now).
from __future__ import unicode_literals
import youtube_dl
import os
from sys import argv
# Download data and config
download_options = {
'format': 'bestaudio/best',
'outtmpl': '%(title)s.%(ext)s',
'nocheckcertificate': True,
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
}
# Song Directory
if not os.path.exists('Songs'):
os.mkdir('Songs')
else:
os.chdir('Songs')
# Download Songs
with youtube_dl.YoutubeDL(download_options) as dl:
with open('..\\' + argv[1], 'r') as f:
for song_url in f:
dl.download([song_url])
It is first downloading ".webm" file(video),then converting to mp3 correctly and after that removing original ".webm" video, I don't want it to remove it, when I run it in CMD it says "Deleting original file .webm (pass -k to keep), but I don't know where to pass -k (I'm not programmer I just copied the code)
Thanks in advance!