|
|
|
@ -92,21 +92,22 @@ class YouPornIE(InfoExtractor):
|
|
|
|
|
webpage = self._download_webpage(f'https://www.youporn.com/watch/{video_id}', video_id)
|
|
|
|
|
player_vars = self._search_json(r'\bplayervars\s*:', webpage, 'player vars', video_id)
|
|
|
|
|
|
|
|
|
|
definitions = {}
|
|
|
|
|
for type_ in ('hls', 'mp4'):
|
|
|
|
|
if info_url := traverse_obj(player_vars, (
|
|
|
|
|
'mediaDefinitions', lambda _, v: v['format'] == type_,
|
|
|
|
|
'videoUrl', {url_or_none}, any)):
|
|
|
|
|
definitions[type_] = self._download_json(
|
|
|
|
|
info_url, video_id, f'Downloading {type_} info JSON', fatal=False)
|
|
|
|
|
def get_format_data(type_):
|
|
|
|
|
info_url = traverse_obj(player_vars, (
|
|
|
|
|
'mediaDefinitions', lambda _, v: v['format'] == type_, 'videoUrl', {url_or_none}, any))
|
|
|
|
|
if not info_url:
|
|
|
|
|
return None
|
|
|
|
|
return traverse_obj(
|
|
|
|
|
self._download_json(info_url, video_id, f'Downloading {type_} info JSON', fatal=False),
|
|
|
|
|
lambda _, v: v['format'] == type_ and url_or_none(v['videoUrl']))
|
|
|
|
|
|
|
|
|
|
formats = []
|
|
|
|
|
# Try to extract only the actual master m3u8 first, avoiding the duplicate single resolution "master" m3u8s
|
|
|
|
|
for hls_url in traverse_obj(definitions.get('hls'), (
|
|
|
|
|
for hls_url in traverse_obj(get_format_data('hls'), (
|
|
|
|
|
lambda _, v: not isinstance(v['defaultQuality'], bool), 'videoUrl'), (..., 'videoUrl')):
|
|
|
|
|
formats.extend(self._extract_m3u8_formats(hls_url, video_id, 'mp4', fatal=False, m3u8_id='hls'))
|
|
|
|
|
|
|
|
|
|
for definition in traverse_obj(definitions, ('mp4', lambda _, v: url_or_none(v['videoUrl']))):
|
|
|
|
|
for definition in get_format_data('mp4'):
|
|
|
|
|
f = traverse_obj(definition, {
|
|
|
|
|
'url': 'videoUrl',
|
|
|
|
|
'filesize': ('videoSize', {int_or_none})
|
|
|
|
|