JuanBindez / pytubefix

Python3 library for downloading YouTube Videos.
https://pytubefix.readthedocs.io
MIT License
729 stars 101 forks source link

key error on yt.title #256

Closed fedetony closed 1 month ago

fedetony commented 1 month ago

:exclamation: DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE :exclamation:

lack of information will lead to closure of the issue


Describe the bug when running extract.py gets a key error: File "C:\Users\Tony\AppData\Roaming\Python\Python39\site-packages\pytubefix\__main__.py", line 693, in title self.check_availability() File "C:\Users\Tony\AppData\Roaming\Python\Python39\site-packages\pytubefix\__main__.py", line 312, in check_availability status, messages = extract.playability_status(self.vid_info) File "C:\Users\Tony\AppData\Roaming\Python\Python39\site-packages\pytubefix\extract.py", line 110, in playability_status if 'isLive' in player_response['videoDetails']: KeyError: 'videoDetails'


code that was used that resulted in the bug error happens while reading: yt.title for any video url I give.

from pytubefix import YouTube
def get_yt_video_from_url(self,url,client='WEB_CREATOR'):
        try:
            yt = YouTube(url, client=client, on_progress_callback = self._on_progress)
        except Exception as eee:
            #print(eee)
            self.to_log.emit("Error Video: {}".format(eee))
            yt = None
        return yt

def get_url_info(self,url):
        yt_info={}
        yt = self.get_yt_video_from_url(url)
        if yt:
            yt_info.update({"title":yt.title})
            yt_info.update({"age_restricted":yt.age_restricted})
            yt_info.update({"author":yt.author})
            yt_info.update({"caption_tracks":yt.caption_tracks})
            yt_info.update({"captions":yt.captions})
            yt_info.update({"channel_id":yt.channel_id})
            yt_info.update({"channel_url":yt.channel_url})
            yt_info.update({"chapters":yt.chapters})
            yt_info.update({"description":yt.description})
            yt_info.update({"length":yt.length})
            yt_info.update({"keywords":yt.keywords})
            yt_info.update({"publish_date":yt.publish_date})
            yt_info.update({"rating":yt.rating})
            yt_info.update({"key_moments":yt.key_moments})
            yt_info.update({"metadata":yt.metadata})
            yt_info.update({"views":yt.views})
            yt_info.update({"vid_info":yt.vid_info})
        return yt_info    

Expected behavior It used to return all info.


Screenshots If applicable, add screenshots to help explain your problem.


Desktop (please complete the following information):


Additional context Add any other context about the problem here.

JuanBindez commented 1 month ago

try the lastest version

fedetony commented 1 month ago

Ok :) version 7.1.3 works fine, was using 7.1rc2 because of the video unavailable error. Thanks, you may close issue

fedetony commented 1 month ago

All fixed in 7.1.3