Python scripts for download music video from youtube and convert it into mp3
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
pythube/pyOnlyDownload.py

42 lines
1.1 KiB

from pytube import Playlist
import youtube_dl, os, time
from moviepy.editor import *
### FOR DOWNLOAD 1 VIDEO ###
## FUNTIONS ##
# downloading
def download():
try:
print("downloading...", link)
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([link])
except:
print("un probleme est survenu... on réessaye!")
# converting and renaming fonction
def convert(video):
videoO = VideoFileClip(video)
# split the .mp4
filename, file_extension = os.path.splitext(str(video))
# renvoie le .mp3 dans le repertoire de destination
return videoO.audio.write_audiofile(os.path.join("./" + destination + "/" + filename + ".mp3"))
## MAIN PROGRAM
# recup des liens de la playlist via lien playlist input
link = str(input("Entrer le lien de la video youtube a télécharger: "))
# creation du repertoire destination
#destination = str(input("Entrer le repertoire de destination:"))
destination = ""
#os.mkdir("./" + destination + "")
# options
ydl_opts = {'format': 'best',}
# download
download()
# fini!
print("Téléchargement terminé!")