]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/vzaar.py
   2 from __future__ 
import unicode_literals
 
   6 from .common 
import InfoExtractor
 
   7 from ..compat 
import compat_str
 
  16 class VzaarIE(InfoExtractor
): 
  17     _VALID_URL 
= r
'https?://(?:(?:www|view)\.)?vzaar\.com/(?:videos/)?(?P<id>\d+)' 
  20         'url': 'https://vzaar.com/videos/1152805', 
  21         'md5': 'bde5ddfeb104a6c56a93a06b04901dbf', 
  25             'title': 'sample video (public)', 
  28         'url': 'https://view.vzaar.com/27272/player', 
  29         'md5': '3b50012ac9bbce7f445550d54e0508f2', 
  38     def _extract_urls(webpage
): 
  40             r
'<iframe[^>]+src=["\']((?
:https?
:)?
//(?
:view\
.vzaar\
.com
)/[0-9]+)', 
  43     def _real_extract(self, url): 
  44         video_id = self._match_id(url) 
  45         video_data = self._download_json( 
  46             'http
://view
.vzaar
.com
/v2
/%s/video
' % video_id, video_id) 
  48         title = video_data['videoTitle
'] 
  52         source_url = url_or_none(video_data.get('sourceUrl
')) 
  58             if 'audio
' in source_url: 
  65                     'width
': int_or_none(video_data.get('width
')), 
  66                     'height
': int_or_none(video_data.get('height
')), 
  68                     'fps
': float_or_none(video_data.get('fps
')), 
  72         video_guid = video_data.get('guid
') 
  73         usp = video_data.get('usp
') 
  74         if isinstance(video_guid, compat_str) and isinstance(usp, dict): 
  75             m3u8_url = ('http
://fable
.vzaar
.com
/v4
/usp
/%s/%s.ism
/.m3u8?
' 
  76                         % (video_guid, video_id)) + '&'.join( 
  77                 '%s=%s' % (k, v) for k, v in usp.items()) 
  78             formats.extend(self._extract_m3u8_formats( 
  79                 m3u8_url, video_id, 'mp4
', entry_protocol='m3u8_native
', 
  80                 m3u8_id='hls
', fatal=False)) 
  82         self._sort_formats(formats) 
  87             'thumbnail
': self._proto_relative_url(video_data.get('poster
')), 
  88             'duration
': float_or_none(video_data.get('videoDuration
')), 
  89             'timestamp
': unified_timestamp(video_data.get('ts
')),