]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/movieclips.py
Import Upstream version 2020.01.24
[youtubedl] / youtube_dl / extractor / movieclips.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..utils import (
6 smuggle_url,
7 float_or_none,
8 parse_iso8601,
9 update_url_query,
10 )
11
12
13 class MovieClipsIE(InfoExtractor):
14 _VALID_URL = r'https?://(?:www\.)?movieclips\.com/videos/.+-(?P<id>\d+)(?:\?|$)'
15 _TEST = {
16 'url': 'http://www.movieclips.com/videos/warcraft-trailer-1-561180739597',
17 'md5': '42b5a0352d4933a7bd54f2104f481244',
18 'info_dict': {
19 'id': 'pKIGmG83AqD9',
20 'ext': 'mp4',
21 'title': 'Warcraft Trailer 1',
22 'description': 'Watch Trailer 1 from Warcraft (2016). Legendary’s WARCRAFT is a 3D epic adventure of world-colliding conflict based.',
23 'thumbnail': r're:^https?://.*\.jpg$',
24 'timestamp': 1446843055,
25 'upload_date': '20151106',
26 'uploader': 'Movieclips',
27 },
28 'add_ie': ['ThePlatform'],
29 }
30
31 def _real_extract(self, url):
32 video_id = self._match_id(url)
33 webpage = self._download_webpage(url, video_id)
34 video = next(v for v in self._parse_json(self._search_regex(
35 r'var\s+__REACT_ENGINE__\s*=\s*({.+});',
36 webpage, 'react engine'), video_id)['playlist']['videos'] if v['id'] == video_id)
37
38 return {
39 '_type': 'url_transparent',
40 'ie_key': 'ThePlatform',
41 'url': smuggle_url(update_url_query(
42 video['contentUrl'], {'mbr': 'true'}), {'force_smil_url': True}),
43 'title': self._og_search_title(webpage),
44 'description': self._html_search_meta('description', webpage),
45 'duration': float_or_none(video.get('duration')),
46 'timestamp': parse_iso8601(video.get('dateCreated')),
47 'thumbnail': video.get('defaultImage'),
48 'uploader': video.get('provider'),
49 }