Skip to content

Commit

Permalink
[youtube] fix reason
Browse files Browse the repository at this point in the history
  • Loading branch information
soimort committed Oct 28, 2024
1 parent 5b4142d commit ab9a978
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/you_get/extractors/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,17 @@ def check_playability_response(self, ytInitialPlayerResponse):

playerResponseStatus = ytInitialPlayerResponse["playabilityStatus"]["status"]
if playerResponseStatus != STATUS_OK:
reason = ytInitialPlayerResponse["playabilityStatus"].get("reason", "")
raise AssertionError(
f"Server refused to provide video details. Returned status: {playerResponseStatus}, reason: {reason}."
)
try:
reason = ytInitialPlayerResponse["playabilityStatus"]['errorScreen']\
['playerErrorMessageRenderer']['reason']['runs'][0]['text']
reason += ' ' + ytInitialPlayerResponse["playabilityStatus"]['errorScreen']\
['playerErrorMessageRenderer']['subreason']['runs'][0]['text']
except:
reason = ytInitialPlayerResponse["playabilityStatus"].get("reason", "")
if reason:
log.wtf(f'Server refused to provide video details. Returned status: {playerResponseStatus}. Reason: {reason}')
else:
log.wtf(f'Server refused to provide video details. Returned status: {playerResponseStatus}.')

def prepare(self, **kwargs):
self.ua = 'Mozilla/5.0 (Linux; Android 15) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.73 Mobile Safari/537.36'
Expand Down

0 comments on commit ab9a978

Please sign in to comment.