mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-07-01 10:58:34 +00:00
rename
This commit is contained in:
parent
567fb56a1c
commit
b58d59ec78
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
import math
|
import math
|
||||||
|
|
||||||
from yt_dlp.jsinterp.jsinterp import JS_Undefined, JSInterpreter
|
from yt_dlp.jsinterp.native import JS_Undefined, JSInterpreter
|
||||||
|
|
||||||
|
|
||||||
class NaN:
|
class NaN:
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
from test.helper import FakeYDL, is_download_test
|
from test.helper import FakeYDL, is_download_test
|
||||||
from yt_dlp.extractor import YoutubeIE
|
from yt_dlp.extractor import YoutubeIE
|
||||||
from yt_dlp.jsinterp import JSInterpreter
|
from yt_dlp.jsinterp import NativeJSI
|
||||||
|
|
||||||
_SIG_TESTS = [
|
_SIG_TESTS = [
|
||||||
(
|
(
|
||||||
@ -243,7 +243,7 @@ def signature(jscode, sig_input):
|
|||||||
|
|
||||||
def n_sig(jscode, sig_input):
|
def n_sig(jscode, sig_input):
|
||||||
funcname = YoutubeIE(FakeYDL())._extract_n_function_name(jscode)
|
funcname = YoutubeIE(FakeYDL())._extract_n_function_name(jscode)
|
||||||
return JSInterpreter(jscode).call_function(funcname, sig_input)
|
return NativeJSI(jscode).call_function(funcname, sig_input)
|
||||||
|
|
||||||
|
|
||||||
make_sig_test = t_factory(
|
make_sig_test = t_factory(
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
from .common import InfoExtractor, SearchInfoExtractor
|
from .common import InfoExtractor, SearchInfoExtractor
|
||||||
from ..jsinterp import PhantomJSwrapper
|
from ..jsinterp import PhantomJSwrapper
|
||||||
from ..jsinterp import JSInterpreter
|
from ..jsinterp import NativeJSI
|
||||||
from ..networking.exceptions import HTTPError, network_exceptions
|
from ..networking.exceptions import HTTPError, network_exceptions
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
NO_DEFAULT,
|
NO_DEFAULT,
|
||||||
@ -3067,7 +3067,7 @@ def _parse_sig_js(self, jscode):
|
|||||||
r'\bc\s*&&\s*[a-zA-Z0-9]+\.set\([^,]+\s*,\s*\([^)]*\)\s*\(\s*(?P<sig>[a-zA-Z0-9$]+)\('),
|
r'\bc\s*&&\s*[a-zA-Z0-9]+\.set\([^,]+\s*,\s*\([^)]*\)\s*\(\s*(?P<sig>[a-zA-Z0-9$]+)\('),
|
||||||
jscode, 'Initial JS player signature function name', group='sig')
|
jscode, 'Initial JS player signature function name', group='sig')
|
||||||
|
|
||||||
jsi = JSInterpreter(jscode)
|
jsi = NativeJSI(jscode)
|
||||||
initial_function = jsi.extract_function(funcname)
|
initial_function = jsi.extract_function(funcname)
|
||||||
return lambda s: initial_function([s])
|
return lambda s: initial_function([s])
|
||||||
|
|
||||||
@ -3111,7 +3111,7 @@ def _decrypt_nsig(self, s, video_id, player_url):
|
|||||||
try:
|
try:
|
||||||
extract_nsig = self._cached(self._extract_n_function_from_code, 'nsig func', player_url)
|
extract_nsig = self._cached(self._extract_n_function_from_code, 'nsig func', player_url)
|
||||||
ret = extract_nsig(jsi, func_code)(s)
|
ret = extract_nsig(jsi, func_code)(s)
|
||||||
except JSInterpreter.Exception as e:
|
except NativeJSI.Exception as e:
|
||||||
try:
|
try:
|
||||||
jsi = PhantomJSwrapper(self, timeout=5000)
|
jsi = PhantomJSwrapper(self, timeout=5000)
|
||||||
except ExtractorError:
|
except ExtractorError:
|
||||||
@ -3145,7 +3145,7 @@ def _extract_n_function_code(self, video_id, player_url):
|
|||||||
player_id = self._extract_player_info(player_url)
|
player_id = self._extract_player_info(player_url)
|
||||||
func_code = self.cache.load('youtube-nsig', player_id, min_ver='2024.07.09')
|
func_code = self.cache.load('youtube-nsig', player_id, min_ver='2024.07.09')
|
||||||
jscode = func_code or self._load_player(video_id, player_url)
|
jscode = func_code or self._load_player(video_id, player_url)
|
||||||
jsi = JSInterpreter(jscode)
|
jsi = NativeJSI(jscode)
|
||||||
|
|
||||||
if func_code:
|
if func_code:
|
||||||
return jsi, player_id, func_code
|
return jsi, player_id, func_code
|
||||||
@ -3163,13 +3163,13 @@ def _extract_n_function_from_code(self, jsi, func_code):
|
|||||||
def extract_nsig(s):
|
def extract_nsig(s):
|
||||||
try:
|
try:
|
||||||
ret = func([s])
|
ret = func([s])
|
||||||
except JSInterpreter.Exception:
|
except NativeJSI.Exception:
|
||||||
raise
|
raise
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise JSInterpreter.Exception(traceback.format_exc(), cause=e)
|
raise NativeJSI.Exception(traceback.format_exc(), cause=e)
|
||||||
|
|
||||||
if ret.startswith('enhanced_except_'):
|
if ret.startswith('enhanced_except_'):
|
||||||
raise JSInterpreter.Exception('Signature function returned an exception')
|
raise NativeJSI.Exception('Signature function returned an exception')
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
return extract_nsig
|
return extract_nsig
|
||||||
@ -3902,7 +3902,7 @@ def build_fragments(f):
|
|||||||
})
|
})
|
||||||
except ExtractorError as e:
|
except ExtractorError as e:
|
||||||
phantomjs_hint = ''
|
phantomjs_hint = ''
|
||||||
if isinstance(e, JSInterpreter.Exception):
|
if isinstance(e, NativeJSI.Exception):
|
||||||
phantomjs_hint = (f' Install {self._downloader._format_err("PhantomJS", self._downloader.Styles.EMPHASIS)} '
|
phantomjs_hint = (f' Install {self._downloader._format_err("PhantomJS", self._downloader.Styles.EMPHASIS)} '
|
||||||
f'to workaround the issue. {PhantomJSwrapper.INSTALL_HINT}\n')
|
f'to workaround the issue. {PhantomJSwrapper.INSTALL_HINT}\n')
|
||||||
if player_url:
|
if player_url:
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
from .jsinterp import JSInterpreter
|
from .native import JSInterpreter as NativeJSI
|
||||||
from .external import PhantomJSwrapper, DenoWrapper, PuppeteerWrapper
|
from .external import PhantomJSwrapper, DenoWrapper, PuppeteerWrapper
|
||||||
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
JSInterpreter,
|
NativeJSI,
|
||||||
PhantomJSwrapper,
|
PhantomJSwrapper,
|
||||||
DenoWrapper,
|
DenoWrapper,
|
||||||
PuppeteerWrapper,
|
PuppeteerWrapper,
|
||||||
|
Loading…
Reference in New Issue
Block a user