mirror of
https://codeberg.org/polarisfm/youtube-dl
synced 2024-11-23 00:54:31 +01:00
[dailymotion] Improve metadata extraction (closes #17706)
This commit is contained in:
parent
f60b9803a4
commit
0082f44a08
@ -22,9 +22,11 @@ from ..utils import (
|
|||||||
parse_iso8601,
|
parse_iso8601,
|
||||||
sanitized_Request,
|
sanitized_Request,
|
||||||
str_to_int,
|
str_to_int,
|
||||||
unescapeHTML,
|
|
||||||
urlencode_postdata,
|
|
||||||
try_get,
|
try_get,
|
||||||
|
unescapeHTML,
|
||||||
|
update_url_query,
|
||||||
|
url_or_none,
|
||||||
|
urlencode_postdata,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -172,15 +174,25 @@ class DailymotionIE(DailymotionBaseInfoExtractor):
|
|||||||
r'__PLAYER_CONFIG__\s*=\s*({.+?});'],
|
r'__PLAYER_CONFIG__\s*=\s*({.+?});'],
|
||||||
webpage, 'player v5', default=None)
|
webpage, 'player v5', default=None)
|
||||||
if player_v5:
|
if player_v5:
|
||||||
player = self._parse_json(player_v5, video_id)
|
player = self._parse_json(player_v5, video_id, fatal=False) or {}
|
||||||
metadata = try_get(
|
metadata = try_get(player, lambda x: x['metadata'], dict)
|
||||||
player, lambda x: x['metadata'], dict) or self._download_json(
|
if not metadata:
|
||||||
'http://www.dailymotion.com/player/metadata/video/%s' % video_id, video_id, query={
|
metadata_url = url_or_none(try_get(
|
||||||
'integration': 'inline',
|
player, lambda x: x['context']['metadata_template_url1']))
|
||||||
'GK_PV5_NEON': '1',
|
if metadata_url:
|
||||||
})
|
metadata_url = metadata_url.replace(':videoId', video_id)
|
||||||
|
else:
|
||||||
|
metadata_url = update_url_query(
|
||||||
|
'https://www.dailymotion.com/player/metadata/video/%s'
|
||||||
|
% video_id, {
|
||||||
|
'embedder': url,
|
||||||
|
'integration': 'inline',
|
||||||
|
'GK_PV5_NEON': '1',
|
||||||
|
})
|
||||||
|
metadata = self._download_json(
|
||||||
|
metadata_url, video_id, 'Downloading metadata JSON')
|
||||||
|
|
||||||
if metadata.get('error', {}).get('type') == 'password_protected':
|
if try_get(metadata, lambda x: x['error']['type']) == 'password_protected':
|
||||||
password = self._downloader.params.get('videopassword')
|
password = self._downloader.params.get('videopassword')
|
||||||
if password:
|
if password:
|
||||||
r = int(metadata['id'][1:], 36)
|
r = int(metadata['id'][1:], 36)
|
||||||
|
Loading…
Reference in New Issue
Block a user