]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/thescene.py
debian/changelog: Prepare for release.
[youtubedl] / youtube_dl / extractor / thescene.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4
5 from ..compat import compat_urlparse
6 from ..utils import qualities
7
8
9 class TheSceneIE(InfoExtractor):
10 _VALID_URL = r'https?://thescene\.com/watch/[^/]+/(?P<id>[^/#?]+)'
11
12 _TEST = {
13 'url': 'https://thescene.com/watch/vogue/narciso-rodriguez-spring-2013-ready-to-wear',
14 'info_dict': {
15 'id': '520e8faac2b4c00e3c6e5f43',
16 'ext': 'mp4',
17 'title': 'Narciso Rodriguez: Spring 2013 Ready-to-Wear',
18 'display_id': 'narciso-rodriguez-spring-2013-ready-to-wear',
19 },
20 }
21
22 def _real_extract(self, url):
23 display_id = self._match_id(url)
24
25 webpage = self._download_webpage(url, display_id)
26
27 player_url = compat_urlparse.urljoin(
28 url,
29 self._html_search_regex(
30 r'id=\'js-player-script\'[^>]+src=\'(.+?)\'', webpage, 'player url'))
31
32 player = self._download_webpage(player_url, display_id)
33 info = self._parse_json(
34 self._search_regex(
35 r'(?m)var\s+video\s+=\s+({.+?});$', player, 'info json'),
36 display_id)
37
38 qualities_order = qualities(('low', 'high'))
39 formats = [{
40 'format_id': '{0}-{1}'.format(f['type'].split('/')[0], f['quality']),
41 'url': f['src'],
42 'quality': qualities_order(f['quality']),
43 } for f in info['sources'][0]]
44 self._sort_formats(formats)
45
46 return {
47 'id': info['id'],
48 'display_id': display_id,
49 'title': info['title'],
50 'formats': formats,
51 'thumbnail': info.get('poster_frame'),
52 }