mirror of
https://github.com/ytdl-org/youtube-dl
synced 2025-07-16 00:14:17 +09:00
Compare commits
4 Commits
be4891b229
...
2c795e0ba1
Author | SHA1 | Date | |
---|---|---|---|
![]() |
2c795e0ba1 | ||
![]() |
da7223d4aa | ||
![]() |
37c2440d6a | ||
![]() |
ddbd545101 |
@ -69,10 +69,10 @@ def _file_md5(fn):
|
|||||||
return hashlib.md5(f.read()).hexdigest()
|
return hashlib.md5(f.read()).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
defs = gettestcases()
|
ie_testcases = gettestcases()
|
||||||
|
|
||||||
|
|
||||||
class TestDownload(unittest.TestCase):
|
class BaseDownloadTCase(unittest.TestCase):
|
||||||
# Parallel testing in nosetests. See
|
# Parallel testing in nosetests. See
|
||||||
# http://nose.readthedocs.org/en/latest/doc_tests/test_multiprocess/multiprocess.html
|
# http://nose.readthedocs.org/en/latest/doc_tests/test_multiprocess/multiprocess.html
|
||||||
_multiprocess_shared_ = True
|
_multiprocess_shared_ = True
|
||||||
@ -91,8 +91,9 @@ class TestDownload(unittest.TestCase):
|
|||||||
strclass(self.__class__),
|
strclass(self.__class__),
|
||||||
' [%s]' % add_ie if add_ie else '')
|
' [%s]' % add_ie if add_ie else '')
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
self.defs = defs
|
TestDownload = unittest.TestSuite()
|
||||||
|
|
||||||
|
|
||||||
# Dynamically generate tests
|
# Dynamically generate tests
|
||||||
|
|
||||||
@ -275,20 +276,42 @@ def generator(test_case, tname):
|
|||||||
return test_template
|
return test_template
|
||||||
|
|
||||||
|
|
||||||
|
cache = {}
|
||||||
|
|
||||||
# And add them to TestDownload
|
# And add them to TestDownload
|
||||||
for n, test_case in enumerate(defs):
|
for test_case in ie_testcases:
|
||||||
tname = 'test_' + str(test_case['name'])
|
# Get or create a sub-test for the extractor file
|
||||||
i = 1
|
module_name = test_case.get('module_name', 'unknown').rsplit('.', 1)[-1] # type: str
|
||||||
while hasattr(TestDownload, tname):
|
extractor_file_name = str('test_%s' % module_name)
|
||||||
tname = 'test_%s_%d' % (test_case['name'], i)
|
extractor_file_suite = getattr(TestDownload, extractor_file_name, None)
|
||||||
|
if extractor_file_suite is None:
|
||||||
|
extractor_file_suite = type(extractor_file_name, (unittest.TestSuite,), {})()
|
||||||
|
setattr(TestDownload, extractor_file_name, extractor_file_suite)
|
||||||
|
TestDownload.addTest(extractor_file_suite)
|
||||||
|
|
||||||
|
# Get or create a sub-test for the info extractor
|
||||||
|
# This class contains the actual tests
|
||||||
|
extractor_class_name = str('test_%s' % test_case['name'])
|
||||||
|
ExtractorClass = getattr(extractor_file_suite, extractor_class_name, None)
|
||||||
|
if ExtractorClass is None:
|
||||||
|
ExtractorClass = type(extractor_class_name, (BaseDownloadTCase,), {})
|
||||||
|
setattr(extractor_file_suite, extractor_class_name, ExtractorClass)
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
tname = 'test_%d' % i
|
||||||
|
while hasattr(ExtractorClass, tname):
|
||||||
|
tname = 'test_%d' % i
|
||||||
i += 1
|
i += 1
|
||||||
test_method = generator(test_case, tname)
|
test_method = generator(test_case, tname)
|
||||||
test_method.__name__ = str(tname)
|
test_method.__name__ = str(tname)
|
||||||
ie_list = test_case.get('add_ie')
|
ie_list = test_case.get('add_ie')
|
||||||
test_method.add_ie = ie_list and ','.join(ie_list)
|
test_method.add_ie = ie_list and ','.join(ie_list)
|
||||||
setattr(TestDownload, test_method.__name__, test_method)
|
|
||||||
del test_method
|
setattr(ExtractorClass, test_method.__name__, test_method)
|
||||||
|
extractor_file_suite.addTest(ExtractorClass(test_method.__name__))
|
||||||
|
|
||||||
|
del test_method, test_case
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main(argv=['TestDownload'])
|
||||||
|
@ -232,8 +232,32 @@ _NSIG_TESTS = [
|
|||||||
'W9HJZKktxuYoDTqW', 'jHbbkcaxm54',
|
'W9HJZKktxuYoDTqW', 'jHbbkcaxm54',
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'https://www.youtube.com/s/player/91201489/player_ias_tce.vflset/en_US/base.js',
|
'https://www.youtube.com/s/player/643afba4/player_ias.vflset/en_US/base.js',
|
||||||
'W9HJZKktxuYoDTqW', 'U48vOZHaeYS6vO',
|
'W9HJZKktxuYoDTqW', 'larxUlagTRAcSw',
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'https://www.youtube.com/s/player/e7567ecf/player_ias_tce.vflset/en_US/base.js',
|
||||||
|
'Sy4aDGc0VpYRR9ew_', '5UPOT1VhoZxNLQ',
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'https://www.youtube.com/s/player/d50f54ef/player_ias_tce.vflset/en_US/base.js',
|
||||||
|
'Ha7507LzRmH3Utygtj', 'XFTb2HoeOE5MHg',
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'https://www.youtube.com/s/player/074a8365/player_ias_tce.vflset/en_US/base.js',
|
||||||
|
'Ha7507LzRmH3Utygtj', 'ufTsrE0IVYrkl8v',
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'https://www.youtube.com/s/player/643afba4/player_ias.vflset/en_US/base.js',
|
||||||
|
'N5uAlLqm0eg1GyHO', 'dCBQOejdq5s-ww',
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'https://www.youtube.com/s/player/69f581a5/tv-player-ias.vflset/tv-player-ias.js',
|
||||||
|
'-qIP447rVlTTwaZjY', 'KNcGOksBAvwqQg',
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'https://www.youtube.com/s/player/643afba4/tv-player-ias.vflset/tv-player-ias.js',
|
||||||
|
'ir9-V6cdbCiyKxhr', '2PL7ZDYAALMfmA',
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -3263,6 +3263,7 @@ class InfoExtractor(object):
|
|||||||
if not include_onlymatching and t.get('only_matching', False):
|
if not include_onlymatching and t.get('only_matching', False):
|
||||||
continue
|
continue
|
||||||
t['name'] = type(self).__name__[:-len('IE')]
|
t['name'] = type(self).__name__[:-len('IE')]
|
||||||
|
t['module_name'] = type(self).__module__
|
||||||
yield t
|
yield t
|
||||||
|
|
||||||
def is_suitable(self, age_limit):
|
def is_suitable(self, age_limit):
|
||||||
|
@ -91,12 +91,12 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
|
|||||||
'INNERTUBE_CONTEXT': {
|
'INNERTUBE_CONTEXT': {
|
||||||
'client': {
|
'client': {
|
||||||
'clientName': 'IOS',
|
'clientName': 'IOS',
|
||||||
'clientVersion': '19.45.4',
|
'clientVersion': '20.10.4',
|
||||||
'deviceMake': 'Apple',
|
'deviceMake': 'Apple',
|
||||||
'deviceModel': 'iPhone16,2',
|
'deviceModel': 'iPhone16,2',
|
||||||
'userAgent': 'com.google.ios.youtube/19.45.4 (iPhone16,2; U; CPU iOS 18_1_0 like Mac OS X;)',
|
'userAgent': 'com.google.ios.youtube/20.10.4 (iPhone16,2; U; CPU iOS 18_3_2 like Mac OS X;)',
|
||||||
'osName': 'iPhone',
|
'osName': 'iPhone',
|
||||||
'osVersion': '18.1.0.22B83',
|
'osVersion': '18.3.2.22D82',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'INNERTUBE_CONTEXT_CLIENT_NAME': 5,
|
'INNERTUBE_CONTEXT_CLIENT_NAME': 5,
|
||||||
@ -109,7 +109,7 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
|
|||||||
'INNERTUBE_CONTEXT': {
|
'INNERTUBE_CONTEXT': {
|
||||||
'client': {
|
'client': {
|
||||||
'clientName': 'MWEB',
|
'clientName': 'MWEB',
|
||||||
'clientVersion': '2.20241202.07.00',
|
'clientVersion': '2.20250311.03.00',
|
||||||
# mweb previously did not require PO Token with this UA
|
# mweb previously did not require PO Token with this UA
|
||||||
'userAgent': 'Mozilla/5.0 (iPad; CPU OS 16_7_10 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1,gzip(gfe)',
|
'userAgent': 'Mozilla/5.0 (iPad; CPU OS 16_7_10 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1,gzip(gfe)',
|
||||||
},
|
},
|
||||||
@ -122,7 +122,7 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
|
|||||||
'INNERTUBE_CONTEXT': {
|
'INNERTUBE_CONTEXT': {
|
||||||
'client': {
|
'client': {
|
||||||
'clientName': 'TVHTML5',
|
'clientName': 'TVHTML5',
|
||||||
'clientVersion': '7.20250120.19.00',
|
'clientVersion': '7.20250312.16.00',
|
||||||
'userAgent': 'Mozilla/5.0 (ChromiumStylePlatform) Cobalt/Version',
|
'userAgent': 'Mozilla/5.0 (ChromiumStylePlatform) Cobalt/Version',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -133,7 +133,7 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
|
|||||||
'INNERTUBE_CONTEXT': {
|
'INNERTUBE_CONTEXT': {
|
||||||
'client': {
|
'client': {
|
||||||
'clientName': 'WEB',
|
'clientName': 'WEB',
|
||||||
'clientVersion': '2.20241126.01.00',
|
'clientVersion': '2.20250312.04.00',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'INNERTUBE_CONTEXT_CLIENT_NAME': 1,
|
'INNERTUBE_CONTEXT_CLIENT_NAME': 1,
|
||||||
@ -692,7 +692,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
|||||||
'invidious': '|'.join(_INVIDIOUS_SITES),
|
'invidious': '|'.join(_INVIDIOUS_SITES),
|
||||||
}
|
}
|
||||||
_PLAYER_INFO_RE = (
|
_PLAYER_INFO_RE = (
|
||||||
r'/s/player/(?P<id>[a-zA-Z0-9_-]{8,})/player',
|
r'/s/player/(?P<id>[a-zA-Z0-9_-]{8,})//(?:tv-)?player',
|
||||||
r'/(?P<id>[a-zA-Z0-9_-]{8,})/player(?:_ias\.vflset(?:/[a-zA-Z]{2,3}_[a-zA-Z]{2,3})?|-plasma-ias-(?:phone|tablet)-[a-z]{2}_[A-Z]{2}\.vflset)/base\.js$',
|
r'/(?P<id>[a-zA-Z0-9_-]{8,})/player(?:_ias\.vflset(?:/[a-zA-Z]{2,3}_[a-zA-Z]{2,3})?|-plasma-ias-(?:phone|tablet)-[a-z]{2}_[A-Z]{2}\.vflset)/base\.js$',
|
||||||
r'\b(?P<id>vfl[a-zA-Z0-9_-]+)\b.*?\.js$',
|
r'\b(?P<id>vfl[a-zA-Z0-9_-]+)\b.*?\.js$',
|
||||||
)
|
)
|
||||||
@ -1857,7 +1857,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
|||||||
def _extract_n_function_code_jsi(self, video_id, jsi, player_id=None):
|
def _extract_n_function_code_jsi(self, video_id, jsi, player_id=None):
|
||||||
|
|
||||||
var_ay = self._search_regex(
|
var_ay = self._search_regex(
|
||||||
r'(?:[;\s]|^)\s*(var\s*[\w$]+\s*=\s*"[^"]+"\s*\.\s*split\("\{"\))(?=\s*[,;])',
|
r'(?:[;\s]|^)\s*(var\s*[\w$]+\s*=\s*"(?:\\"|[^"])+"\s*\.\s*split\("\W+"\))(?=\s*[,;])',
|
||||||
jsi.code, 'useful values', default='')
|
jsi.code, 'useful values', default='')
|
||||||
|
|
||||||
func_name = self._extract_n_function_name(jsi.code)
|
func_name = self._extract_n_function_name(jsi.code)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user