]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/viddler.py
   1 from __future__ 
import unicode_literals
 
   3 from .common 
import InfoExtractor
 
  15 class ViddlerIE(InfoExtractor
): 
  16     _VALID_URL 
= r
'https?://(?:www\.)?viddler\.com/(?:v|embed|player)/(?P<id>[a-z0-9]+)' 
  18         'url': 'http://www.viddler.com/v/43903784', 
  19         'md5': '9eee21161d2c7f5b39690c3e325fab2f', 
  23             'title': 'Video Made Easy', 
  24             'description': 'md5:6a697ebd844ff3093bd2e82c37b409cd', 
  25             'uploader': 'viddler', 
  26             'timestamp': 1335371429, 
  27             'upload_date': '20120425', 
  29             'thumbnail': 're:^https?://.*\.jpg$', 
  32             'categories': ['video content', 'high quality video', 'video made easy', 'how to produce video with limited resources', 'viddler'], 
  35         'url': 'http://www.viddler.com/v/4d03aad9/', 
  36         'md5': 'f12c5a7fa839c47a79363bfdf69404fb', 
  40             'title': 'WALL-TO-GORTAT', 
  41             'upload_date': '20150126', 
  42             'uploader': 'deadspin', 
  43             'timestamp': 1422285291, 
  48         'url': 'http://www.viddler.com/player/221ebbbd/0/', 
  49         'md5': '740511f61d3d1bb71dc14a0fe01a1c10', 
  53             'title': 'LETeens-Grammar-snack-third-conditional', 
  55             'upload_date': '20140929', 
  56             'uploader': 'BCLETeens', 
  57             'timestamp': 1411997190, 
  63         'url': 'http://www.viddler.com/v/890c0985?secret=34051570', 
  67             'title': 'Complete Property Training - Traineeships', 
  69             'upload_date': '20130606', 
  70             'uploader': 'TiffanyBowtell', 
  71             'timestamp': 1370496993, 
  76             'skip_download': True, 
  80     def _real_extract(self
, url
): 
  81         video_id 
= self
._match
_id
(url
) 
  85             'key': 'v0vhrt7bg2xq1vyxhkct', 
  88         qs 
= compat_urlparse
.parse_qs(compat_urlparse
.urlparse(url
).query
) 
  89         secret 
= qs
.get('secret', [None])[0] 
  91             query
['secret'] = secret
 
  93         headers 
= {'Referer': 'http://static.cdn-ec.viddler.com/js/arpeggio/v2/embed.html'} 
  94         request 
= sanitized_Request( 
  95             'http://api.viddler.com/api/v2/viddler.videos.getPlaybackDetails.json?%s' 
  96             % compat_urllib_parse
.urlencode(query
), None, headers
) 
  97         data 
= self
._download
_json
(request
, video_id
)['video'] 
 100         for filed 
in data
['files']: 
 101             if filed
.get('status', 'ready') != 'ready': 
 103             format_id 
= filed
.get('profile_id') or filed
['profile_name'] 
 105                 'format_id': format_id
, 
 106                 'format_note': filed
['profile_name'], 
 107                 'url': self
._proto
_relative
_url
(filed
['url']), 
 108                 'width': int_or_none(filed
.get('width')), 
 109                 'height': int_or_none(filed
.get('height')), 
 110                 'filesize': int_or_none(filed
.get('size')), 
 111                 'ext': filed
.get('ext'), 
 112                 'source_preference': -1, 
 116             if filed
.get('cdn_url'): 
 118                 f
['url'] = self
._proto
_relative
_url
(filed
['cdn_url'], 'http:') 
 119                 f
['format_id'] = format_id 
+ '-cdn' 
 120                 f
['source_preference'] = 1 
 123             if filed
.get('html5_video_source'): 
 125                 f
['url'] = self
._proto
_relative
_url
(filed
['html5_video_source']) 
 126                 f
['format_id'] = format_id 
+ '-html5' 
 127                 f
['source_preference'] = 0 
 129         self
._sort
_formats
(formats
) 
 132             t
.get('text') for t 
in data
.get('tags', []) if 'text' in t
] 
 136             'title': data
['title'], 
 138             'description': data
.get('description'), 
 139             'timestamp': int_or_none(data
.get('upload_time')), 
 140             'thumbnail': self
._proto
_relative
_url
(data
.get('thumbnail_url')), 
 141             'uploader': data
.get('author'), 
 142             'duration': float_or_none(data
.get('length')), 
 143             'view_count': int_or_none(data
.get('view_count')), 
 144             'comment_count': int_or_none(data
.get('comment_count')), 
 145             'categories': categories
,