]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/onionstudios.py
1d336cf3069d8aae29eeb4e90a7c3f20241cab2e
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
15 class OnionStudiosIE(InfoExtractor
):
16 _VALID_URL
= r
'https?://(?:www\.)?onionstudios\.com/(?:videos/[^/]+-|embed\?.*\bid=)(?P<id>\d+)(?!-)'
19 'url': 'http://www.onionstudios.com/videos/hannibal-charges-forward-stops-for-a-cocktail-2937',
20 'md5': 'e49f947c105b8a78a675a0ee1bddedfe',
24 'title': 'Hannibal charges forward, stops for a cocktail',
25 'thumbnail': r
're:^https?://.*\.jpg$',
26 'uploader': 'The A.V. Club',
27 'uploader_id': 'the-av-club',
30 'url': 'http://www.onionstudios.com/embed?id=2855&autoplay=true',
31 'only_matching': True,
35 def _extract_url(webpage
):
37 r
'<iframe[^>]+?src=(["\'])(?P
<url
>(?
:https?
:)?
//(?
:www\
.)?onionstudios\
.com
/embed
.+?
)\
1', webpage)
39 return mobj.group('url
')
41 def _real_extract(self, url):
42 video_id = self._match_id(url)
44 video_data = self._download_json(
45 'http
://www
.onionstudios
.com
/video
/%s.json
' % video_id, video_id)
47 title = video_data['title
']
50 for source in video_data.get('sources
', []):
51 source_url = source.get('url
')
54 ext = mimetype2ext(source.get('content_type
')) or determine_ext(source_url)
56 formats.extend(self._extract_m3u8_formats(
57 source_url, video_id, 'mp4
', 'm3u8_native
', m3u8_id='hls
', fatal=False))
59 tbr = int_or_none(source.get('bitrate
'))
61 'format_id
': ext + ('-%d' % tbr if tbr else ''),
63 'width
': int_or_none(source.get('width
')),
67 self._sort_formats(formats)
72 'thumbnail
': video_data.get('poster_url
'),
73 'uploader
': video_data.get('channel_name
'),
74 'uploader_id
': video_data.get('channel_slug
'),
75 'duration
': float_or_none(video_data.get('duration
', 1000)),
76 'tags
': video_data.get('tags
'),