You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

146 lines
5.1 KiB

10 years ago
10 years ago
Switch codebase to use sanitized_Request instead of compat_urllib_request.Request [downloader/dash] Use sanitized_Request [downloader/http] Use sanitized_Request [atresplayer] Use sanitized_Request [bambuser] Use sanitized_Request [bliptv] Use sanitized_Request [brightcove] Use sanitized_Request [cbs] Use sanitized_Request [ceskatelevize] Use sanitized_Request [collegerama] Use sanitized_Request [extractor/common] Use sanitized_Request [crunchyroll] Use sanitized_Request [dailymotion] Use sanitized_Request [dcn] Use sanitized_Request [dramafever] Use sanitized_Request [dumpert] Use sanitized_Request [eitb] Use sanitized_Request [escapist] Use sanitized_Request [everyonesmixtape] Use sanitized_Request [extremetube] Use sanitized_Request [facebook] Use sanitized_Request [fc2] Use sanitized_Request [flickr] Use sanitized_Request [4tube] Use sanitized_Request [gdcvault] Use sanitized_Request [extractor/generic] Use sanitized_Request [hearthisat] Use sanitized_Request [hotnewhiphop] Use sanitized_Request [hypem] Use sanitized_Request [iprima] Use sanitized_Request [ivi] Use sanitized_Request [keezmovies] Use sanitized_Request [letv] Use sanitized_Request [lynda] Use sanitized_Request [metacafe] Use sanitized_Request [minhateca] Use sanitized_Request [miomio] Use sanitized_Request [meovideo] Use sanitized_Request [mofosex] Use sanitized_Request [moniker] Use sanitized_Request [mooshare] Use sanitized_Request [movieclips] Use sanitized_Request [mtv] Use sanitized_Request [myvideo] Use sanitized_Request [neteasemusic] Use sanitized_Request [nfb] Use sanitized_Request [niconico] Use sanitized_Request [noco] Use sanitized_Request [nosvideo] Use sanitized_Request [novamov] Use sanitized_Request [nowness] Use sanitized_Request [nuvid] Use sanitized_Request [played] Use sanitized_Request [pluralsight] Use sanitized_Request [pornhub] Use sanitized_Request [pornotube] Use sanitized_Request [primesharetv] Use sanitized_Request [promptfile] Use sanitized_Request [qqmusic] Use sanitized_Request [rtve] Use sanitized_Request [safari] Use sanitized_Request [sandia] Use sanitized_Request [shared] Use sanitized_Request [sharesix] Use sanitized_Request [sina] Use sanitized_Request [smotri] Use sanitized_Request [sohu] Use sanitized_Request [spankwire] Use sanitized_Request [sportdeutschland] Use sanitized_Request [streamcloud] Use sanitized_Request [streamcz] Use sanitized_Request [tapely] Use sanitized_Request [tube8] Use sanitized_Request [tubitv] Use sanitized_Request [twitch] Use sanitized_Request [twitter] Use sanitized_Request [udemy] Use sanitized_Request [vbox7] Use sanitized_Request [veoh] Use sanitized_Request [vessel] Use sanitized_Request [vevo] Use sanitized_Request [viddler] Use sanitized_Request [videomega] Use sanitized_Request [viewvster] Use sanitized_Request [viki] Use sanitized_Request [vk] Use sanitized_Request [vodlocker] Use sanitized_Request [voicerepublic] Use sanitized_Request [wistia] Use sanitized_Request [xfileshare] Use sanitized_Request [xtube] Use sanitized_Request [xvideos] Use sanitized_Request [yandexmusic] Use sanitized_Request [youku] Use sanitized_Request [youporn] Use sanitized_Request [youtube] Use sanitized_Request [patreon] Use sanitized_Request [extractor/common] Remove unused import [nfb] PEP 8
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..compat import (
  4. compat_urllib_parse_urlencode,
  5. compat_urlparse,
  6. )
  7. from ..utils import (
  8. float_or_none,
  9. int_or_none,
  10. sanitized_Request,
  11. )
  12. class ViddlerIE(InfoExtractor):
  13. _VALID_URL = r'https?://(?:www\.)?viddler\.com/(?:v|embed|player)/(?P<id>[a-z0-9]+)'
  14. _TESTS = [{
  15. 'url': 'http://www.viddler.com/v/43903784',
  16. 'md5': '9eee21161d2c7f5b39690c3e325fab2f',
  17. 'info_dict': {
  18. 'id': '43903784',
  19. 'ext': 'mov',
  20. 'title': 'Video Made Easy',
  21. 'description': 'md5:6a697ebd844ff3093bd2e82c37b409cd',
  22. 'uploader': 'viddler',
  23. 'timestamp': 1335371429,
  24. 'upload_date': '20120425',
  25. 'duration': 100.89,
  26. 'thumbnail': r're:^https?://.*\.jpg$',
  27. 'view_count': int,
  28. 'comment_count': int,
  29. 'categories': ['video content', 'high quality video', 'video made easy', 'how to produce video with limited resources', 'viddler'],
  30. }
  31. }, {
  32. 'url': 'http://www.viddler.com/v/4d03aad9/',
  33. 'md5': 'f12c5a7fa839c47a79363bfdf69404fb',
  34. 'info_dict': {
  35. 'id': '4d03aad9',
  36. 'ext': 'ts',
  37. 'title': 'WALL-TO-GORTAT',
  38. 'upload_date': '20150126',
  39. 'uploader': 'deadspin',
  40. 'timestamp': 1422285291,
  41. 'view_count': int,
  42. 'comment_count': int,
  43. }
  44. }, {
  45. 'url': 'http://www.viddler.com/player/221ebbbd/0/',
  46. 'md5': '740511f61d3d1bb71dc14a0fe01a1c10',
  47. 'info_dict': {
  48. 'id': '221ebbbd',
  49. 'ext': 'mov',
  50. 'title': 'LETeens-Grammar-snack-third-conditional',
  51. 'description': ' ',
  52. 'upload_date': '20140929',
  53. 'uploader': 'BCLETeens',
  54. 'timestamp': 1411997190,
  55. 'view_count': int,
  56. 'comment_count': int,
  57. }
  58. }, {
  59. # secret protected
  60. 'url': 'http://www.viddler.com/v/890c0985?secret=34051570',
  61. 'info_dict': {
  62. 'id': '890c0985',
  63. 'ext': 'mp4',
  64. 'title': 'Complete Property Training - Traineeships',
  65. 'description': ' ',
  66. 'upload_date': '20130606',
  67. 'uploader': 'TiffanyBowtell',
  68. 'timestamp': 1370496993,
  69. 'view_count': int,
  70. 'comment_count': int,
  71. },
  72. 'params': {
  73. 'skip_download': True,
  74. },
  75. }]
  76. def _real_extract(self, url):
  77. video_id = self._match_id(url)
  78. query = {
  79. 'video_id': video_id,
  80. 'key': 'v0vhrt7bg2xq1vyxhkct',
  81. }
  82. qs = compat_urlparse.parse_qs(compat_urlparse.urlparse(url).query)
  83. secret = qs.get('secret', [None])[0]
  84. if secret:
  85. query['secret'] = secret
  86. headers = {'Referer': 'http://static.cdn-ec.viddler.com/js/arpeggio/v2/embed.html'}
  87. request = sanitized_Request(
  88. 'http://api.viddler.com/api/v2/viddler.videos.getPlaybackDetails.json?%s'
  89. % compat_urllib_parse_urlencode(query), None, headers)
  90. data = self._download_json(request, video_id)['video']
  91. formats = []
  92. for filed in data['files']:
  93. if filed.get('status', 'ready') != 'ready':
  94. continue
  95. format_id = filed.get('profile_id') or filed['profile_name']
  96. f = {
  97. 'format_id': format_id,
  98. 'format_note': filed['profile_name'],
  99. 'url': self._proto_relative_url(filed['url']),
  100. 'width': int_or_none(filed.get('width')),
  101. 'height': int_or_none(filed.get('height')),
  102. 'filesize': int_or_none(filed.get('size')),
  103. 'ext': filed.get('ext'),
  104. 'source_preference': -1,
  105. }
  106. formats.append(f)
  107. if filed.get('cdn_url'):
  108. f = f.copy()
  109. f['url'] = self._proto_relative_url(filed['cdn_url'], 'http:')
  110. f['format_id'] = format_id + '-cdn'
  111. f['source_preference'] = 1
  112. formats.append(f)
  113. if filed.get('html5_video_source'):
  114. f = f.copy()
  115. f['url'] = self._proto_relative_url(filed['html5_video_source'])
  116. f['format_id'] = format_id + '-html5'
  117. f['source_preference'] = 0
  118. formats.append(f)
  119. self._sort_formats(formats)
  120. categories = [
  121. t.get('text') for t in data.get('tags', []) if 'text' in t]
  122. return {
  123. 'id': video_id,
  124. 'title': data['title'],
  125. 'formats': formats,
  126. 'description': data.get('description'),
  127. 'timestamp': int_or_none(data.get('upload_time')),
  128. 'thumbnail': self._proto_relative_url(data.get('thumbnail_url')),
  129. 'uploader': data.get('author'),
  130. 'duration': float_or_none(data.get('length')),
  131. 'view_count': int_or_none(data.get('view_count')),
  132. 'comment_count': int_or_none(data.get('comment_count')),
  133. 'categories': categories,
  134. }