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.

116 lines
4.2 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
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
  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. float_or_none,
  5. int_or_none,
  6. sanitized_Request,
  7. )
  8. class ViddlerIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:www\.)?viddler\.com/(?:v|embed|player)/(?P<id>[a-z0-9]+)'
  10. _TESTS = [{
  11. 'url': 'http://www.viddler.com/v/43903784',
  12. 'md5': 'ae43ad7cb59431ce043f0ff7fa13cbf4',
  13. 'info_dict': {
  14. 'id': '43903784',
  15. 'ext': 'mp4',
  16. 'title': 'Video Made Easy',
  17. 'description': 'md5:6a697ebd844ff3093bd2e82c37b409cd',
  18. 'uploader': 'viddler',
  19. 'timestamp': 1335371429,
  20. 'upload_date': '20120425',
  21. 'duration': 100.89,
  22. 'thumbnail': 're:^https?://.*\.jpg$',
  23. 'view_count': int,
  24. 'comment_count': int,
  25. 'categories': ['video content', 'high quality video', 'video made easy', 'how to produce video with limited resources', 'viddler'],
  26. }
  27. }, {
  28. 'url': 'http://www.viddler.com/v/4d03aad9/',
  29. 'md5': 'faa71fbf70c0bee7ab93076fd007f4b0',
  30. 'info_dict': {
  31. 'id': '4d03aad9',
  32. 'ext': 'mp4',
  33. 'title': 'WALL-TO-GORTAT',
  34. 'upload_date': '20150126',
  35. 'uploader': 'deadspin',
  36. 'timestamp': 1422285291,
  37. 'view_count': int,
  38. 'comment_count': int,
  39. }
  40. }, {
  41. 'url': 'http://www.viddler.com/player/221ebbbd/0/',
  42. 'md5': '0defa2bd0ea613d14a6e9bd1db6be326',
  43. 'info_dict': {
  44. 'id': '221ebbbd',
  45. 'ext': 'mp4',
  46. 'title': 'LETeens-Grammar-snack-third-conditional',
  47. 'description': ' ',
  48. 'upload_date': '20140929',
  49. 'uploader': 'BCLETeens',
  50. 'timestamp': 1411997190,
  51. 'view_count': int,
  52. 'comment_count': int,
  53. }
  54. }]
  55. def _real_extract(self, url):
  56. video_id = self._match_id(url)
  57. json_url = (
  58. 'http://api.viddler.com/api/v2/viddler.videos.getPlaybackDetails.json?video_id=%s&key=v0vhrt7bg2xq1vyxhkct' %
  59. video_id)
  60. headers = {'Referer': 'http://static.cdn-ec.viddler.com/js/arpeggio/v2/embed.html'}
  61. request = sanitized_Request(json_url, None, headers)
  62. data = self._download_json(request, video_id)['video']
  63. formats = []
  64. for filed in data['files']:
  65. if filed.get('status', 'ready') != 'ready':
  66. continue
  67. format_id = filed.get('profile_id') or filed['profile_name']
  68. f = {
  69. 'format_id': format_id,
  70. 'format_note': filed['profile_name'],
  71. 'url': self._proto_relative_url(filed['url']),
  72. 'width': int_or_none(filed.get('width')),
  73. 'height': int_or_none(filed.get('height')),
  74. 'filesize': int_or_none(filed.get('size')),
  75. 'ext': filed.get('ext'),
  76. 'source_preference': -1,
  77. }
  78. formats.append(f)
  79. if filed.get('cdn_url'):
  80. f = f.copy()
  81. f['url'] = self._proto_relative_url(filed['cdn_url'], 'http:')
  82. f['format_id'] = format_id + '-cdn'
  83. f['source_preference'] = 1
  84. formats.append(f)
  85. if filed.get('html5_video_source'):
  86. f = f.copy()
  87. f['url'] = self._proto_relative_url(filed['html5_video_source'])
  88. f['format_id'] = format_id + '-html5'
  89. f['source_preference'] = 0
  90. formats.append(f)
  91. self._sort_formats(formats)
  92. categories = [
  93. t.get('text') for t in data.get('tags', []) if 'text' in t]
  94. return {
  95. 'id': video_id,
  96. 'title': data['title'],
  97. 'formats': formats,
  98. 'description': data.get('description'),
  99. 'timestamp': int_or_none(data.get('upload_time')),
  100. 'thumbnail': self._proto_relative_url(data.get('thumbnail_url')),
  101. 'uploader': data.get('author'),
  102. 'duration': float_or_none(data.get('length')),
  103. 'view_count': int_or_none(data.get('view_count')),
  104. 'comment_count': int_or_none(data.get('comment_count')),
  105. 'categories': categories,
  106. }