]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/onionstudios.py
   2 from __future__ 
import unicode_literals
 
   6 from .common 
import InfoExtractor
 
  13 class OnionStudiosIE(InfoExtractor
): 
  14     _VALID_URL 
= r
'https?://(?:www\.)?onionstudios\.com/(?:videos/[^/]+-|embed\?.*\bid=)(?P<id>\d+)(?!-)' 
  17         'url': 'http://www.onionstudios.com/videos/hannibal-charges-forward-stops-for-a-cocktail-2937', 
  18         'md5': 'd4851405d31adfadf71cd7a487b765bb', 
  22             'title': 'Hannibal charges forward, stops for a cocktail', 
  23             'description': 'md5:e786add7f280b7f0fe237b64cc73df76', 
  24             'thumbnail': 're:^https?://.*\.jpg$', 
  25             'uploader': 'The A.V. Club', 
  26             'uploader_id': 'TheAVClub', 
  29         'url': 'http://www.onionstudios.com/embed?id=2855&autoplay=true', 
  30         'only_matching': True, 
  34     def _extract_url(webpage
): 
  36             r
'<iframe[^>]+?src=(["\'])(?P
<url
>(?
:https?
:)?
//(?
:www\
.)?onionstudios\
.com
/embed
.+?
)\
1', webpage) 
  38             return mobj.group('url
') 
  40     def _real_extract(self, url): 
  41         video_id = self._match_id(url) 
  43         webpage = self._download_webpage( 
  44             'http
://www
.onionstudios
.com
/embed?
id=%s' % video_id, video_id) 
  47         for src in re.findall(r'<source
[^
>]+src
="([^"]+)"', webpage): 
  48             ext = determine_ext(src) 
  50                 formats.extend(self._extract_m3u8_formats( 
  51                     src, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False)) 
  53                 height = int_or_none(self._search_regex( 
  54                     r'/(\d+)\.%s' % ext, src, 'height', default=None)) 
  56                     'format_id': ext + ('-%sp' % height if height else ''), 
  62         self._sort_formats(formats) 
  64         title = self._search_regex( 
  65             r'share_title\s*=\s*(["\'])(?P
<title
>[^\
1]+?
)\
1', 
  66             webpage, 'title
', group='title
') 
  67         description = self._search_regex( 
  68             r'share_description\s
*=\s
*(["\'])(?P<description>[^\'"]+?
)\
1', 
  69             webpage, 'description
', default=None, group='description
') 
  70         thumbnail = self._search_regex( 
  71             r'poster\s
*=\s
*(["\'])(?P<thumbnail>[^\1]+?)\1', 
  72             webpage, 'thumbnail', default=False, group='thumbnail') 
  74         uploader_id = self._search_regex( 
  75             r'twitter_handle\s*=\s*(["\'])(?P
<uploader_id
>[^\
1]+?
)\
1', 
  76             webpage, 'uploader 
id', fatal=False, group='uploader_id
') 
  77         uploader = self._search_regex( 
  78             r'window\
.channelName\s
*=\s
*(["\'])Embedded:(?P<uploader>[^\1]+?)\1', 
  79             webpage, 'uploader', default=False, group='uploader') 
  84             'description': description, 
  85             'thumbnail': thumbnail, 
  87             'uploader_id': uploader_id,