|
|
|
@ -82,6 +82,14 @@ _NSIG_TESTS = [
|
|
|
|
|
'https://www.youtube.com/s/player/f1ca6900/player_ias.vflset/en_US/base.js',
|
|
|
|
|
'cu3wyu6LQn2hse', 'jvxetvmlI9AN9Q',
|
|
|
|
|
),
|
|
|
|
|
(
|
|
|
|
|
'https://www.youtube.com/s/player/8040e515/player_ias.vflset/en_US/base.js',
|
|
|
|
|
'wvOFaY-yjgDuIEg5', 'HkfBFDHmgw4rsw',
|
|
|
|
|
),
|
|
|
|
|
(
|
|
|
|
|
'https://www.youtube.com/s/player/e06dea74/player_ias.vflset/en_US/base.js',
|
|
|
|
|
'AiuodmaDDYw8d3y4bf', 'ankd8eza2T6Qmw',
|
|
|
|
|
),
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -110,10 +118,17 @@ class TestPlayerInfo(unittest.TestCase):
|
|
|
|
|
class TestSignature(unittest.TestCase):
|
|
|
|
|
def setUp(self):
|
|
|
|
|
TEST_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
|
self.TESTDATA_DIR = os.path.join(TEST_DIR, 'testdata')
|
|
|
|
|
self.TESTDATA_DIR = os.path.join(TEST_DIR, 'testdata/sigs')
|
|
|
|
|
if not os.path.exists(self.TESTDATA_DIR):
|
|
|
|
|
os.mkdir(self.TESTDATA_DIR)
|
|
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
|
try:
|
|
|
|
|
for f in os.listdir(self.TESTDATA_DIR):
|
|
|
|
|
os.remove(f)
|
|
|
|
|
except OSError:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def t_factory(name, sig_func, url_pattern):
|
|
|
|
|
def make_tfunc(url, sig_input, expected_sig):
|
|
|
|
@ -145,12 +160,7 @@ def signature(jscode, sig_input):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def n_sig(jscode, sig_input):
|
|
|
|
|
# Pending implementation of _extract_n_function_name() or similar in
|
|
|
|
|
# youtube.py, hard-code here
|
|
|
|
|
# funcname = YoutubeIE(FakeYDL())._extract_n_function_name(jscode)
|
|
|
|
|
import re
|
|
|
|
|
funcname = re.search(r'[=(,&|](\w+)\(\w+\),\w+\.set\("n",', jscode)
|
|
|
|
|
funcname = funcname and funcname.group(1)
|
|
|
|
|
funcname = YoutubeIE(FakeYDL())._extract_n_function_name(jscode)
|
|
|
|
|
return JSInterpreter(jscode).call_function(funcname, sig_input)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|