aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2018-10-05 02:02:58 +0700
committerSergey M․ <dstftw@gmail.com>2018-10-05 02:03:25 +0700
commit0082f44a08e33712fcd33ceabab15215c962eaac (patch)
treeadc660d97838938ac5014f42048785114d157fc5
parentf60b9803a473da8e324313d01af91e5676792c77 (diff)
[dailymotion] Improve metadata extraction (closes #17706)
-rw-r--r--youtube_dl/extractor/dailymotion.py32
1 files changed, 22 insertions, 10 deletions
diff --git a/youtube_dl/extractor/dailymotion.py b/youtube_dl/extractor/dailymotion.py
index 842d9a259..1816c559e 100644
--- a/youtube_dl/extractor/dailymotion.py
+++ b/youtube_dl/extractor/dailymotion.py
@@ -22,9 +22,11 @@ from ..utils import (
parse_iso8601,
sanitized_Request,
str_to_int,
+ try_get,
unescapeHTML,
+ update_url_query,
+ url_or_none,
urlencode_postdata,
- try_get,
)
@@ -172,15 +174,25 @@ class DailymotionIE(DailymotionBaseInfoExtractor):
r'__PLAYER_CONFIG__\s*=\s*({.+?});'],
webpage, 'player v5', default=None)
if player_v5:
- player = self._parse_json(player_v5, video_id)
- metadata = try_get(
- player, lambda x: x['metadata'], dict) or self._download_json(
- 'http://www.dailymotion.com/player/metadata/video/%s' % video_id, video_id, query={
- 'integration': 'inline',
- 'GK_PV5_NEON': '1',
- })
-
- if metadata.get('error', {}).get('type') == 'password_protected':
+ player = self._parse_json(player_v5, video_id, fatal=False) or {}
+ metadata = try_get(player, lambda x: x['metadata'], dict)
+ if not metadata:
+ metadata_url = url_or_none(try_get(
+ player, lambda x: x['context']['metadata_template_url1']))
+ 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 try_get(metadata, lambda x: x['error']['type']) == 'password_protected':
password = self._downloader.params.get('videopassword')
if password:
r = int(metadata['id'][1:], 36)