I have the below code that has been used to download youtube videos. I automatically detect if it's a playlist or single video. However all the sudden it is giving the above error. What can be the problem?
import pafy
from log import *
import tkinter.filedialog
import pytube
url = input("Enter url :")
directory = tkinter.filedialog.askdirectory()
def single_url(url,directory):
print("==================================================================================================================")
video = pafy.new(url)
print(url)
print(video.title)
#logs(video.title,url)
file_object = open(directory "/links.log", "a")
file_object.write(video.title ' ' url '\n')
file_object.close()
print('Rating :',video.rating,', Duration :',video.duration,', Likes :',video.likes, ', Dislikes : ', video.dislikes)
#print(video.description)
best = video.getbest()
print(best.resolution, best.extension)
best.download(quiet=False, filepath=directory '/' video.title "." best.extension)
print("saved at :", directory, " directory")
print("==================================================================================================================")
def playlist_func(url,directory):
try:
playlist = pytube.Playlist(url)
file_object = open(directory "/links.log", "a")
file_object.write('Playlist Url :' url '\n')
file_object.close()
print('There are {0}'.format(len(playlist.video_urls)))
for url in playlist.video_urls:
single_url(url,directory)
except:
single_url(url,directory)
playlist_func(url,directory)
CodePudding user response:
Your issue doesn't have anything to do with your code.
Youtube does no longer have a dislike count, they simply removed it.
You just have to wait for the pafy package to be updated accordingly, or patch the package locally and remove that part by yourself.
Keep in mind there are at least 5 different pull requests open trying to fix it.