Skip to content

Commit

Permalink
[youtube] fix extraction (close #3031)
Browse files Browse the repository at this point in the history
  • Loading branch information
soimort committed Oct 27, 2024
1 parent c4042d0 commit 1c9c0f3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/you_get/extractors/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ def n_to_n(js, n):
# Xka - https://www.youtube.com/s/player/dc0c6770/player_ias.vflset/sv_SE/base.js
# jma - https://www.youtube.com/s/player/8d9f6215/player_ias.vflset/sv_SE/base.js
f1 = match1(js, r',[$\w]+\.length\|\|([$\w]+)\(""\)\)}};')

# Examples:
# Yla, ida - https://www.youtube.com/s/player/fb725ac8/player-plasma-ias-phone-sv_SE.vflset/base.js
# Hla, eda - https://www.youtube.com/s/player/2f238d39/player-plasma-ias-phone-en_US.vflset/base.js
if not f1:
f0 = match1(js, r'c=([$\w]+)\[0\]\(c\),a\.set\(b,c\)')
f1 = match1(js, r'%s=\[([$\w]+)\]' % f0)

f1def = match1(js, r'\W%s=(function\(\w+\).+?\)});' % re.escape(f1))
n = dukpy.evaljs('(%s)("%s")' % (f1def, n))
return n
Expand Down Expand Up @@ -186,7 +194,7 @@ def check_playability_response(self, ytInitialPlayerResponse):
)

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

assert self.url or self.vid

Expand Down

0 comments on commit 1c9c0f3

Please sign in to comment.