mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-10-31 22:55:18 +00: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:
@@ -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):
|
||||
|
||||
@@ -933,21 +933,6 @@ class GenericIE(InfoExtractor):
|
||||
'skip_download': True,
|
||||
}
|
||||
},
|
||||
# YouTube <object> embed
|
||||
{
|
||||
'url': 'http://www.improbable.com/2017/04/03/untrained-modern-youths-and-ancient-masters-in-selfie-portraits/',
|
||||
'md5': '516718101ec834f74318df76259fb3cc',
|
||||
'info_dict': {
|
||||
'id': 'msN87y-iEx0',
|
||||
'ext': 'webm',
|
||||
'title': 'Feynman: Mirrors FUN TO IMAGINE 6',
|
||||
'upload_date': '20080526',
|
||||
'description': 'md5:0ffc78ea3f01b2e2c247d5f8d1d3c18d',
|
||||
'uploader': 'Christopher Sykes',
|
||||
'uploader_id': 'ChristopherJSykes',
|
||||
},
|
||||
'add_ie': ['Youtube'],
|
||||
},
|
||||
# Camtasia studio
|
||||
{
|
||||
'url': 'http://www.ll.mit.edu/workshops/education/videocourses/antennas/lecture1/video/',
|
||||
|
||||
@@ -2266,6 +2266,42 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
||||
}
|
||||
]
|
||||
|
||||
_WEBPAGE_TESTS = [
|
||||
# YouTube <object> embed
|
||||
{
|
||||
'url': 'http://www.improbable.com/2017/04/03/untrained-modern-youths-and-ancient-masters-in-selfie-portraits/',
|
||||
'md5': '873c81d308b979f0e23ee7e620b312a3',
|
||||
'info_dict': {
|
||||
'id': 'msN87y-iEx0',
|
||||
'ext': 'mp4',
|
||||
'title': 'Feynman: Mirrors FUN TO IMAGINE 6',
|
||||
'upload_date': '20080526',
|
||||
'description': 'md5:873c81d308b979f0e23ee7e620b312a3',
|
||||
'uploader': 'Christopher Sykes',
|
||||
'uploader_id': 'ChristopherJSykes',
|
||||
'age_limit': 0,
|
||||
'tags': ['feynman', 'mirror', 'science', 'physics', 'imagination', 'fun', 'cool', 'puzzle'],
|
||||
'channel_id': 'UCCeo--lls1vna5YJABWAcVA',
|
||||
'playable_in_embed': True,
|
||||
'thumbnail': 'https://i.ytimg.com/vi/msN87y-iEx0/hqdefault.jpg',
|
||||
'like_count': int,
|
||||
'comment_count': int,
|
||||
'channel': 'Christopher Sykes',
|
||||
'live_status': 'not_live',
|
||||
'channel_url': 'https://www.youtube.com/channel/UCCeo--lls1vna5YJABWAcVA',
|
||||
'availability': 'public',
|
||||
'duration': 195,
|
||||
'view_count': int,
|
||||
'categories': ['Science & Technology'],
|
||||
'channel_follower_count': int,
|
||||
'uploader_url': 'http://www.youtube.com/user/ChristopherJSykes',
|
||||
},
|
||||
'params': {
|
||||
'skip_download': True,
|
||||
}
|
||||
},
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def suitable(cls, url):
|
||||
from ..utils import parse_qs
|
||||
|
||||
Reference in New Issue
Block a user