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.

128 lines
4.8 KiB

11 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
11 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
11 years ago
11 years ago
  1. from __future__ import unicode_literals
  2. import re
  3. import json
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. int_or_none,
  7. ExtractorError,
  8. sanitized_Request,
  9. )
  10. class VeohIE(InfoExtractor):
  11. _VALID_URL = r'https?://(?:www\.)?veoh\.com/(?:watch|iphone/#_Watch)/(?P<id>(?:v|yapi-)[\da-zA-Z]+)'
  12. _TESTS = [
  13. {
  14. 'url': 'http://www.veoh.com/watch/v56314296nk7Zdmz3',
  15. 'md5': '620e68e6a3cff80086df3348426c9ca3',
  16. 'info_dict': {
  17. 'id': '56314296',
  18. 'ext': 'mp4',
  19. 'title': 'Straight Backs Are Stronger',
  20. 'uploader': 'LUMOback',
  21. 'description': 'At LUMOback, we believe straight backs are stronger. The LUMOback Posture & Movement Sensor: It gently vibrates when you slouch, inspiring improved posture and mobility. Use the app to track your data and improve your posture over time. ',
  22. },
  23. },
  24. {
  25. 'url': 'http://www.veoh.com/watch/v27701988pbTc4wzN?h1=Chile+workers+cover+up+to+avoid+skin+damage',
  26. 'md5': '4a6ff84b87d536a6a71e6aa6c0ad07fa',
  27. 'info_dict': {
  28. 'id': '27701988',
  29. 'ext': 'mp4',
  30. 'title': 'Chile workers cover up to avoid skin damage',
  31. 'description': 'md5:2bd151625a60a32822873efc246ba20d',
  32. 'uploader': 'afp-news',
  33. 'duration': 123,
  34. },
  35. 'skip': 'This video has been deleted.',
  36. },
  37. {
  38. 'url': 'http://www.veoh.com/watch/v69525809F6Nc4frX',
  39. 'md5': '4fde7b9e33577bab2f2f8f260e30e979',
  40. 'note': 'Embedded ooyala video',
  41. 'info_dict': {
  42. 'id': '69525809',
  43. 'ext': 'mp4',
  44. 'title': 'Doctors Alter Plan For Preteen\'s Weight Loss Surgery',
  45. 'description': 'md5:f5a11c51f8fb51d2315bca0937526891',
  46. 'uploader': 'newsy-videos',
  47. },
  48. 'skip': 'This video has been deleted.',
  49. },
  50. ]
  51. def _extract_formats(self, source):
  52. formats = []
  53. link = source.get('aowPermalink')
  54. if link:
  55. formats.append({
  56. 'url': link,
  57. 'ext': 'mp4',
  58. 'format_id': 'aow',
  59. })
  60. link = source.get('fullPreviewHashLowPath')
  61. if link:
  62. formats.append({
  63. 'url': link,
  64. 'format_id': 'low',
  65. })
  66. link = source.get('fullPreviewHashHighPath')
  67. if link:
  68. formats.append({
  69. 'url': link,
  70. 'format_id': 'high',
  71. })
  72. return formats
  73. def _extract_video(self, source):
  74. return {
  75. 'id': source.get('videoId'),
  76. 'title': source.get('title'),
  77. 'description': source.get('description'),
  78. 'thumbnail': source.get('highResImage') or source.get('medResImage'),
  79. 'uploader': source.get('username'),
  80. 'duration': int_or_none(source.get('length')),
  81. 'view_count': int_or_none(source.get('views')),
  82. 'age_limit': 18 if source.get('isMature') == 'true' or source.get('isSexy') == 'true' else 0,
  83. 'formats': self._extract_formats(source),
  84. }
  85. def _real_extract(self, url):
  86. mobj = re.match(self._VALID_URL, url)
  87. video_id = mobj.group('id')
  88. if video_id.startswith('v'):
  89. rsp = self._download_xml(
  90. r'http://www.veoh.com/api/findByPermalink?permalink=%s' % video_id, video_id, 'Downloading video XML')
  91. stat = rsp.get('stat')
  92. if stat == 'ok':
  93. return self._extract_video(rsp.find('./videoList/video'))
  94. elif stat == 'fail':
  95. raise ExtractorError(
  96. '%s said: %s' % (self.IE_NAME, rsp.find('./errorList/error').get('errorMessage')), expected=True)
  97. webpage = self._download_webpage(url, video_id)
  98. age_limit = 0
  99. if 'class="adultwarning-container"' in webpage:
  100. self.report_age_confirmation()
  101. age_limit = 18
  102. request = sanitized_Request(url)
  103. request.add_header('Cookie', 'confirmedAdult=true')
  104. webpage = self._download_webpage(request, video_id)
  105. m_youtube = re.search(r'http://www\.youtube\.com/v/(.*?)(\&|"|\?)', webpage)
  106. if m_youtube is not None:
  107. youtube_id = m_youtube.group(1)
  108. self.to_screen('%s: detected Youtube video.' % video_id)
  109. return self.url_result(youtube_id, 'Youtube')
  110. info = json.loads(
  111. self._search_regex(r'videoDetailsJSON = \'({.*?})\';', webpage, 'info').replace('\\\'', '\''))
  112. video = self._extract_video(info)
  113. video['age_limit'] = age_limit
  114. return video