mirror of
https://github.com/LucBerge/yt-dlp.git
synced 2025-03-17 19:57:52 +03:00
[extractor, test] Basic framework for embed tests (#4307)
and split download tests so they can be more easily run in CI Authored by: coletdjnz
This commit is contained in:
parent
8f97a15d1c
commit
f2e8dbcc00
5 changed files with 89 additions and 53 deletions
|
@ -3665,11 +3665,18 @@ class InfoExtractor:
|
|||
t['name'] = cls.ie_key()
|
||||
yield t
|
||||
|
||||
@classmethod
|
||||
def get_webpage_testcases(cls):
|
||||
tests = getattr(cls, '_WEBPAGE_TESTS', [])
|
||||
for t in tests:
|
||||
t['name'] = cls.ie_key()
|
||||
return tests
|
||||
|
||||
@classproperty
|
||||
def age_limit(cls):
|
||||
"""Get age limit from the testcases"""
|
||||
return max(traverse_obj(
|
||||
tuple(cls.get_testcases(include_onlymatching=False)),
|
||||
(*cls.get_testcases(include_onlymatching=False), *cls.get_webpage_testcases()),
|
||||
(..., (('playlist', 0), None), 'info_dict', 'age_limit')) or [0])
|
||||
|
||||
@classmethod
|
||||
|
@ -3844,7 +3851,10 @@ class InfoExtractor:
|
|||
def extract_from_webpage(cls, ydl, url, webpage):
|
||||
ie = (cls if isinstance(cls._extract_from_webpage, types.MethodType)
|
||||
else ydl.get_info_extractor(cls.ie_key()))
|
||||
yield from ie._extract_from_webpage(url, webpage) or []
|
||||
for info in ie._extract_from_webpage(url, webpage) or []:
|
||||
# url = None since we do not want to set (webpage/original)_url
|
||||
ydl.add_default_extra_info(info, ie, None)
|
||||
yield info
|
||||
|
||||
@classmethod
|
||||
def _extract_from_webpage(cls, url, webpage):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue