Closed STEM-Coders closed 3 years ago
Error: AttributeError: 'NoneType' object has no attribute 'filesize_approx' My Code:
AttributeError: 'NoneType' object has no attribute 'filesize_approx'
from pytube import YouTube from pytube import Playlist import shutil def getVideo(url): yt = YouTube(url).streams.get_by_resolution("720p").download() return yt print("YouTube To MP4. By: Name.") inp = input(f"Video (1)\nPlayList(2)\nOr type Exit to quit\n") if inp == "1": url = input("Youtube URL: ") print("Your YouTube file: " + getVideo(url).title()) elif inp == "2": # create folder with playlist. Purl = input("Youtube PlayList URL: ") for vid in Playlist(Purl).video_urls: print(getVideo(vid)) # shutil.move(getVideo(vid), Playlist(Purl).title()) print("Your YouTube PlayList Folder: " + Playlist(Purl).title) elif inp.lower() == "exit": exit() else: print("Not Valid Input.")
If you trying doing print(YouTube(url).streams.get_by_resolution("720p")) then it prints None.
print(YouTube(url).streams.get_by_resolution("720p"))
None
Error:
AttributeError: 'NoneType' object has no attribute 'filesize_approx'
My Code: