]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/onionstudios.py
c6e3d5640da8f4f0040e862a9641fb73deb391a4
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
15 class OnionStudiosIE(InfoExtractor
):
16 _VALID_URL
= r
'https?://(?:www\.)?onionstudios\.com/(?:video(?:s/[^/]+-|/)|embed\?.*\bid=)(?P<id>\d+)(?!-)'
19 'url': 'http://www.onionstudios.com/videos/hannibal-charges-forward-stops-for-a-cocktail-2937',
20 'md5': '719d1f8c32094b8c33902c17bcae5e34',
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,
33 'url': 'http://www.onionstudios.com/video/6139.json',
34 'only_matching': True,
38 def _extract_url(webpage
):
40 r
'(?s)<(?:iframe|bulbs-video)[^>]+?src=(["\'])(?P
<url
>(?
:https?
:)?
//(?
:www\
.)?onionstudios\
.com
/(?
:embed
.+?|video
/\d
+\
.json
))\
1', webpage)
42 return mobj.group('url
')
44 def _real_extract(self, url):
45 video_id = self._match_id(url)
47 video_data = self._download_json(
48 'http
://www
.onionstudios
.com
/video
/%s.json
' % video_id, video_id)
50 title = video_data['title
']
53 for source in video_data.get('sources
', []):
54 source_url = source.get('url
')
57 ext = mimetype2ext(source.get('content_type
')) or determine_ext(source_url)
59 formats.extend(self._extract_m3u8_formats(
60 source_url, video_id, 'mp4
', 'm3u8_native
', m3u8_id='hls
', fatal=False))
62 tbr = int_or_none(source.get('bitrate
'))
64 'format_id
': ext + ('-%d' % tbr if tbr else ''),
66 'width
': int_or_none(source.get('width
')),
70 self._sort_formats(formats)
75 'thumbnail
': video_data.get('poster_url
'),
76 'uploader
': video_data.get('channel_name
'),
77 'uploader_id
': video_data.get('channel_slug
'),
78 'duration
': float_or_none(video_data.get('duration
', 1000)),
79 'tags
': video_data.get('tags
'),