I don`t know what is the problem in my code i wanna download youtube playlist with numeric
from pytube import Playlist
from tkinter import filedialog
import os
playlist = Playlist(input("input the link:\n"))
folder_name = filedialog.askdirectory()
print("print total videos in playlist :", len(playlist.video_urls))
v = 1
for video in playlist.videos:
video.streams.get_by_resolution('360p').download(folder_name) ##remove video.title+str(v)
os.rename( video.streams.get_by_resolution('360p').default_filename,str(v)+video.title)
print("Video Downloaded: ", video.title)
v += 1
And the problem message is
C:\Users\HP\PycharmProjects\pythonProject\venv\Scripts\python.exe C:\Users\HP\PycharmProjects\pythonProject\yt_playlist.py
input the link:
https://www.youtube.com/playlist?list=PLWlltQ6Oy0zpgxVhd2vZqTDvVXpPhSVd0
print total videos in playlist : 8
Traceback (most recent call last):
File "C:\Users\HP\PycharmProjects\pythonProject\yt_playlist.py", line 10, in <module>
os.rename( video.streams.get_by_resolution('360p').default_filename,str(v)+video.title)
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'What is Sustainable Agriculture Episode 1 A Whole-Farm Approach to Sustainability.mp4' -> '1What is Sustainable Agriculture? Episode 1: A Whole-Farm Approach to Sustainability'
Process finished with exit code 1
I tried this code and didn`t work
from pytube import Playlist
from tkinter import filedialog
import os
playlist = Playlist(input("input the link:\n"))
folder_name = filedialog.askdirectory()
print("print total videos in playlist :", len(playlist.video_urls))
v = 1
for video in playlist.videos:
video.streams.get_by_resolution('360p').download(folder_name)
os.chdir(folder_name)
os.rename( video.streams.get_by_resolution('360p').default_filename,str(v)+video.title)
print("Video Downloaded: ", video.title)
v += 1
it shows this problem
C:\Users\HP\PycharmProjects\pythonProject\venv\Scripts\python.exe C:\Users\HP\PycharmProjects\pythonProject\yt_playlist.py
input the link:
https://www.youtube.com/playlist?list=PLWlltQ6Oy0zpgxVhd2vZqTDvVXpPhSVd0
print total videos in playlist : 8
Traceback (most recent call last):
File "C:\Users\HP\PycharmProjects\pythonProject\yt_playlist.py", line 11, in <module>
os.rename( video.streams.get_by_resolution('360p').default_filename,str(v)+video.title)
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: 'What is Sustainable Agriculture Episode 1 A Whole-Farm Approach to Sustainability.mp4' -> '1What is Sustainable Agriculture? Episode 1: A Whole-Farm Approach to Sustainability'
Process finished with exit code 1
just to know it works with just video not playlists (that`s what happend with me)