Skip to content

Commit

Permalink
Merge pull request #216 from felipeucelli/search-update
Browse files Browse the repository at this point in the history
[Shorts] fixed KeyError: 'reelItemRenderer'
  • Loading branch information
JuanBindez authored Sep 8, 2024
2 parents ee39697 + a936d1d commit 2bd7b99
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions pytubefix/contrib/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def __init__(
then passed as a `po_token` query parameter to affected clients.
If allow_oauth_cache is set to True, the user should only be prompted once.
:param Callable po_token_verifier:
(Optional) Verified used to obtain the visitorData and po_tokenoken.
The verifier will return the visitorData and po_tokenoken respectively.
(Optional) Verified used to obtain the visitorData and po_token.
The verifier will return the visitorData and po_token respectively.
(if passed, else default verifier will be used)
"""
self.query = query
Expand Down Expand Up @@ -306,8 +306,13 @@ def fetch_and_parse(self, continuation=None):
# Get shorts results
if 'reelShelfRenderer' in video_details:
for items in video_details['reelShelfRenderer']['items']:
shorts.append(YouTube(f"https://www.youtube.com/watch?v="
f"{items['reelItemRenderer']['videoId']}",
if 'reelItemRenderer' in items:
video_id = items['reelItemRenderer']['videoId']
else:
video_id = items['shortsLockupViewModel']['inlinePlayerData']['onVisible'][
'innertubeCommand']['watchEndpoint']['videoId']

shorts.append(YouTube(f"https://www.youtube.com/watch?v={video_id}",
use_oauth=self.use_oauth,
allow_oauth_cache=self.allow_oauth_cache,
token_file=self.token_file,
Expand Down

0 comments on commit 2bd7b99

Please sign in to comment.