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.

100 lines
3.8 KiB

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
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
  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..compat import (
  5. compat_str,
  6. compat_urlparse,
  7. )
  8. from ..utils import (
  9. ExtractorError,
  10. determine_ext,
  11. int_or_none,
  12. sanitized_Request,
  13. )
  14. class VoiceRepublicIE(InfoExtractor):
  15. _VALID_URL = r'https?://voicerepublic\.com/(?:talks|embed)/(?P<id>[0-9a-z-]+)'
  16. _TESTS = [{
  17. 'url': 'http://voicerepublic.com/talks/watching-the-watchers-building-a-sousveillance-state',
  18. 'md5': 'b9174d651323f17783000876347116e3',
  19. 'info_dict': {
  20. 'id': '2296',
  21. 'display_id': 'watching-the-watchers-building-a-sousveillance-state',
  22. 'ext': 'm4a',
  23. 'title': 'Watching the Watchers: Building a Sousveillance State',
  24. 'description': 'Secret surveillance programs have metadata too. The people and companies that operate secret surveillance programs can be surveilled.',
  25. 'thumbnail': 're:^https?://.*\.(?:png|jpg)$',
  26. 'duration': 1800,
  27. 'view_count': int,
  28. }
  29. }, {
  30. 'url': 'http://voicerepublic.com/embed/watching-the-watchers-building-a-sousveillance-state',
  31. 'only_matching': True,
  32. }]
  33. def _real_extract(self, url):
  34. display_id = self._match_id(url)
  35. req = sanitized_Request(
  36. compat_urlparse.urljoin(url, '/talks/%s' % display_id))
  37. # Older versions of Firefox get redirected to an "upgrade browser" page
  38. req.add_header('User-Agent', 'youtube-dl')
  39. webpage = self._download_webpage(req, display_id)
  40. if '>Queued for processing, please stand by...<' in webpage:
  41. raise ExtractorError(
  42. 'Audio is still queued for processing', expected=True)
  43. config = self._search_regex(
  44. r'(?s)return ({.+?});\s*\n', webpage,
  45. 'data', default=None)
  46. data = self._parse_json(config, display_id, fatal=False) if config else None
  47. if data:
  48. title = data['title']
  49. description = data.get('teaser')
  50. talk_id = compat_str(data.get('talk_id') or display_id)
  51. talk = data['talk']
  52. duration = int_or_none(talk.get('duration'))
  53. formats = [{
  54. 'url': compat_urlparse.urljoin(url, talk_url),
  55. 'format_id': format_id,
  56. 'ext': determine_ext(talk_url) or format_id,
  57. 'vcodec': 'none',
  58. } for format_id, talk_url in talk['links'].items()]
  59. else:
  60. title = self._og_search_title(webpage)
  61. description = self._html_search_regex(
  62. r"(?s)<div class='talk-teaser'[^>]*>(.+?)</div>",
  63. webpage, 'description', fatal=False)
  64. talk_id = self._search_regex(
  65. [r"id='jc-(\d+)'", r"data-shareable-id='(\d+)'"],
  66. webpage, 'talk id', default=None) or display_id
  67. duration = None
  68. player = self._search_regex(
  69. r"class='vr-player jp-jplayer'([^>]+)>", webpage, 'player')
  70. formats = [{
  71. 'url': compat_urlparse.urljoin(url, talk_url),
  72. 'format_id': format_id,
  73. 'ext': determine_ext(talk_url) or format_id,
  74. 'vcodec': 'none',
  75. } for format_id, talk_url in re.findall(r"data-([^=]+)='([^']+)'", player)]
  76. self._sort_formats(formats)
  77. thumbnail = self._og_search_thumbnail(webpage)
  78. view_count = int_or_none(self._search_regex(
  79. r"class='play-count[^']*'>\s*(\d+) plays",
  80. webpage, 'play count', fatal=False))
  81. return {
  82. 'id': talk_id,
  83. 'display_id': display_id,
  84. 'title': title,
  85. 'description': description,
  86. 'thumbnail': thumbnail,
  87. 'duration': duration,
  88. 'view_count': view_count,
  89. 'formats': formats,
  90. }