1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-12-21 23:48:57 +00:00

patch jsdom for iq

This commit is contained in:
c-basalt
2024-12-31 13:42:36 -05:00
parent b086b8635d
commit 02001159b8
5 changed files with 54 additions and 24 deletions

View File

@@ -5,7 +5,7 @@ import time
import urllib.parse
from .common import InfoExtractor
from ..jsinterp import PhantomJSwrapper
from ..jsinterp import JSIWrapper
from ..utils import (
ExtractorError,
clean_html,
@@ -449,7 +449,6 @@ class IqIE(InfoExtractor):
}
_DASH_JS = '''
console.log(page.evaluate(function() {
var tvid = "%(tvid)s"; var vid = "%(vid)s"; var src = "%(src)s";
var uid = "%(uid)s"; var dfp = "%(dfp)s"; var mode = "%(mode)s"; var lang = "%(lang)s";
var bid_list = %(bid_list)s; var ut_list = %(ut_list)s; var tm = new Date().getTime();
@@ -515,9 +514,7 @@ class IqIE(InfoExtractor):
var dash_path = '/dash?' + enc_params.join('&'); dash_path += '&vf=' + cmd5x(dash_path);
dash_paths[bid] = dash_path;
});
return JSON.stringify(dash_paths);
}));
saveAndExit();
console.log(JSON.stringify(dash_paths));
'''
def _extract_vms_player_js(self, webpage, video_id):
@@ -597,22 +594,22 @@ class IqIE(InfoExtractor):
else:
ut_list = ['0']
jsi = JSIWrapper(self, url, ['dom'], timeout=120)
# bid 0 as an initial format checker
dash_paths = self._parse_json(PhantomJSwrapper(self, timeout=120_000).get(
url, note2='Executing signature code (this may take a couple minutes)',
html='<!DOCTYPE html>', video_id=video_id, jscode=self._DASH_JS % {
'tvid': video_info['tvId'],
'vid': video_info['vid'],
'src': traverse_obj(next_props, ('initialProps', 'pageProps', 'ptid'),
expected_type=str, default='04022001010011000000'),
'uid': uid,
'dfp': self._get_cookie('dfp', ''),
'mode': self._get_cookie('mod', 'intl'),
'lang': self._get_cookie('lang', 'en_us'),
'bid_list': '[' + ','.join(['0', *self._BID_TAGS.keys()]) + ']',
'ut_list': '[' + ','.join(ut_list) + ']',
'cmd5x_func': self._extract_cmd5x_function(webpage, video_id),
})[1].strip(), video_id)
dash_paths = self._parse_json(jsi.execute(self._DASH_JS % {
'tvid': video_info['tvId'],
'vid': video_info['vid'],
'src': traverse_obj(next_props, ('initialProps', 'pageProps', 'ptid'),
expected_type=str, default='04022001010011000000'),
'uid': uid,
'dfp': self._get_cookie('dfp', ''),
'mode': self._get_cookie('mod', 'intl'),
'lang': self._get_cookie('lang', 'en_us'),
'bid_list': '[' + ','.join(['0', *self._BID_TAGS.keys()]) + ']',
'ut_list': '[' + ','.join(ut_list) + ']',
'cmd5x_func': self._extract_cmd5x_function(webpage, video_id),
}, video_id, html='<!DOCTYPE html>'), video_id)
formats, subtitles = [], {}
initial_format_data = self._download_json(