]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/viqeo.py
   2 from __future__ 
import unicode_literals
 
   6 from .common 
import InfoExtractor
 
  14 class ViqeoIE(InfoExtractor
): 
  18                             https?://cdn\.viqeo\.tv/embed/*\?.*?\bvid=| 
  19                             https?://api\.viqeo\.tv/v\d+/data/startup?.*?\bvideo(?:%5B%5D|\[\])= 
  24         'url': 'https://cdn.viqeo.tv/embed/?vid=cde96f09d25f39bee837', 
  25         'md5': 'a169dd1a6426b350dca4296226f21e76', 
  27             'id': 'cde96f09d25f39bee837', 
  29             'title': 'cde96f09d25f39bee837', 
  30             'thumbnail': r
're:^https?://.*\.jpg$', 
  34         'url': 'viqeo:cde96f09d25f39bee837', 
  35         'only_matching': True, 
  37         'url': 'https://api.viqeo.tv/v1/data/startup?video%5B%5D=71bbec412ade45c3216c&profile=112', 
  38         'only_matching': True, 
  42     def _extract_urls(webpage
): 
  45             for mobj 
in re
.finditer( 
  46                 r
'<iframe[^>]+\bsrc=(["\'])(?P
<url
>(?
:https?
:)?
//cdn\
.viqeo\
.tv
/embed
/*\?.*?
\bvid
=[\da
-f
]+.*?
)\
1', 
  49     def _real_extract(self, url): 
  50         video_id = self._match_id(url) 
  52         webpage = self._download_webpage( 
  53             'https
://cdn
.viqeo
.tv
/embed
/?vid
=%s' % video_id, video_id) 
  55         data = self._parse_json( 
  57                 r'SLOT_DATA\s
*=\s
*({.+?
})\s
*;', webpage, 'slot data
'), 
  62         for media_file in data['mediaFiles
']: 
  63             if not isinstance(media_file, dict): 
  65             media_url = url_or_none(media_file.get('url
')) 
  66             if not media_url or not media_url.startswith(('http
', '//')): 
  68             media_type = str_or_none(media_file.get('type')) 
  71             media_kind = media_type.split('/')[0].lower() 
  74                 'width
': int_or_none(media_file.get('width
')), 
  75                 'height
': int_or_none(media_file.get('height
')), 
  77             format_id = str_or_none(media_file.get('quality
')) 
  78             if media_kind == 'image
': 
  81             elif media_kind in ('video
', 'audio
'): 
  82                 is_audio = media_kind == 'audio
' 
  84                     'format_id
': 'audio
' if is_audio else format_id, 
  85                     'fps
': int_or_none(media_file.get('fps
')), 
  86                     'vcodec
': 'none
' if is_audio else None, 
  89         self._sort_formats(formats) 
  91         duration = int_or_none(data.get('duration
')) 
  97             'thumbnails
': thumbnails,