Skip to content

Commit

Permalink
[youtube] fix extraction (player 3bb1f723)
Browse files Browse the repository at this point in the history
  • Loading branch information
soimort committed Dec 10, 2024
1 parent 3614cb9 commit aeb1321
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/you_get/extractors/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,17 @@ def n_to_n(js, n):
# 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
# WyE, bE7, Gsn - https://www.youtube.com/s/player/3bb1f723/player-plasma-ias-phone-sv_SE.vflset/base.js
if not f1:
f0 = match1(js, r'c=([$\w]+)\[0\]\(c\),a\.set\(b,c\)')
f0 = match1(js, r'\w=([$\w]+)\[0\]\(\w\),\w\.set\(\w,\w\)')
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))
v1 = match1(f1def, r'if\(typeof ([$\w]+)==="undefined"\)')
v1def = match1(js, r'(var %s=[^;]+;)' % v1)
if not v1def:
v1def = ''
n = dukpy.evaljs('%s(%s)("%s")' % (v1def, f1def, n))
return n

u = urlparse(url)
Expand Down

0 comments on commit aeb1321

Please sign in to comment.