The script should download an entire playlist (only one song for this test) from YT and convert all the downloaded MP4 to MP3:
from distutils import extension
from pytube import Playlist
import os
link = input("Enter YouTube Playlist URL: ")
yt_playlist = Playlist(link)
for video in yt_playlist.videos:
downloaded_file = video.streams.filter(only_audio=True).first().download(r"C:\Users\Francesco\Desktop\Music\JC's\+++NEW+++")
file, extension = os.path.splitext(downloaded_file)
# Convert video into .mp3 file
os.system('ffmpeg -i {file}{ext} {file}.mp3'.format(file=file, ext=extension))
Now, when I put the playlist's url in input, the script downloads the song but it can't convert it because:
C:\Users\Francesco\Desktop\Music\JC's\+++NEW+++\Ariete: No such file or directory
but the right path is:
C:\Users\Francesco\Desktop\Music\JC's\+++NEW+++\Ariete - LULTIMA NOTTE Testo Lyrics
so it stops when is there a space in directory name...