[movieclips] Fix extraction (fixes #7404)
[youtube-dl] / youtube_dl / extractor / movieclips.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4 from ..compat import (
5     compat_urllib_request,
6 )
7
8
9 class MovieClipsIE(InfoExtractor):
10     _VALID_URL = r'https?://(?:www.)?movieclips\.com/videos/(?P<id>[^/?#]+)'
11     _TEST = {
12         'url': 'http://www.movieclips.com/videos/warcraft-trailer-1-561180739597?autoPlay=true&playlistId=5',
13         'info_dict': {
14             'id': 'pKIGmG83AqD9',
15             'display_id': 'warcraft-trailer-1-561180739597',
16             'ext': 'mp4',
17             'title': 'Warcraft Trailer 1',
18             'description': 'Watch Trailer 1 from Warcraft (2016). Legendary’s WARCRAFT is a 3D epic adventure of world-colliding conflict based.',
19             'thumbnail': 're:^https?://.*\.jpg$',
20         },
21         'add_ie': ['ThePlatform'],
22     }
23
24     def _real_extract(self, url):
25         display_id = self._match_id(url)
26
27         req = compat_urllib_request.Request(url)
28         # it doesn't work if it thinks the browser it's too old
29         req.add_header('User-Agent', 'Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20150101 Firefox/43.0 (Chrome)')
30         webpage = self._download_webpage(req, display_id)
31         theplatform_link = self._html_search_regex(r'src="(http://player.theplatform.com/p/.*?)"', webpage, 'theplatform link')
32         title = self._html_search_regex(r'<title[^>]*>([^>]+)-\s*\d+\s*|\s*Movieclips.com</title>', webpage, 'title')
33         description = self._html_search_meta('description', webpage)
34
35         return {
36             '_type': 'url_transparent',
37             'url': theplatform_link,
38             'title': title,
39             'display_id': display_id,
40             'description': description,
41         }