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.

177 lines
6.1 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
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
  1. from __future__ import unicode_literals
  2. import binascii
  3. import base64
  4. import hashlib
  5. import re
  6. import json
  7. from .common import InfoExtractor
  8. from ..compat import (
  9. compat_ord,
  10. compat_urllib_parse_unquote,
  11. compat_urllib_parse_urlencode,
  12. )
  13. from ..utils import (
  14. ExtractorError,
  15. sanitized_Request,
  16. )
  17. class MyVideoIE(InfoExtractor):
  18. _WORKING = False
  19. _VALID_URL = r'https?://(?:www\.)?myvideo\.de/(?:[^/]+/)?watch/(?P<id>[0-9]+)/[^?/]+.*'
  20. IE_NAME = 'myvideo'
  21. _TEST = {
  22. 'url': 'http://www.myvideo.de/watch/8229274/bowling_fail_or_win',
  23. 'md5': '2d2753e8130479ba2cb7e0a37002053e',
  24. 'info_dict': {
  25. 'id': '8229274',
  26. 'ext': 'flv',
  27. 'title': 'bowling-fail-or-win',
  28. }
  29. }
  30. # Original Code from: https://github.com/dersphere/plugin.video.myvideo_de.git
  31. # Released into the Public Domain by Tristan Fischer on 2013-05-19
  32. # https://github.com/rg3/youtube-dl/pull/842
  33. def __rc4crypt(self, data, key):
  34. x = 0
  35. box = list(range(256))
  36. for i in list(range(256)):
  37. x = (x + box[i] + compat_ord(key[i % len(key)])) % 256
  38. box[i], box[x] = box[x], box[i]
  39. x = 0
  40. y = 0
  41. out = ''
  42. for char in data:
  43. x = (x + 1) % 256
  44. y = (y + box[x]) % 256
  45. box[x], box[y] = box[y], box[x]
  46. out += chr(compat_ord(char) ^ box[(box[x] + box[y]) % 256])
  47. return out
  48. def __md5(self, s):
  49. return hashlib.md5(s).hexdigest().encode()
  50. def _real_extract(self, url):
  51. mobj = re.match(self._VALID_URL, url)
  52. video_id = mobj.group('id')
  53. GK = (
  54. b'WXpnME1EZGhNRGhpTTJNM01XVmhOREU0WldNNVpHTTJOakpt'
  55. b'TW1FMU5tVTBNR05pWkRaa05XRXhNVFJoWVRVd1ptSXhaVEV3'
  56. b'TnpsbA0KTVRkbU1tSTRNdz09'
  57. )
  58. # Get video webpage
  59. webpage_url = 'http://www.myvideo.de/watch/%s' % video_id
  60. webpage = self._download_webpage(webpage_url, video_id)
  61. mobj = re.search('source src=\'(.+?)[.]([^.]+)\'', webpage)
  62. if mobj is not None:
  63. self.report_extraction(video_id)
  64. video_url = mobj.group(1) + '.flv'
  65. video_title = self._html_search_regex('<title>([^<]+)</title>',
  66. webpage, 'title')
  67. return {
  68. 'id': video_id,
  69. 'url': video_url,
  70. 'title': video_title,
  71. }
  72. mobj = re.search(r'data-video-service="/service/data/video/%s/config' % video_id, webpage)
  73. if mobj is not None:
  74. request = sanitized_Request('http://www.myvideo.de/service/data/video/%s/config' % video_id, '')
  75. response = self._download_webpage(request, video_id,
  76. 'Downloading video info')
  77. info = json.loads(base64.b64decode(response).decode('utf-8'))
  78. return {
  79. 'id': video_id,
  80. 'title': info['title'],
  81. 'url': info['streaming_url'].replace('rtmpe', 'rtmpt'),
  82. 'play_path': info['filename'],
  83. 'ext': 'flv',
  84. 'thumbnail': info['thumbnail'][0]['url'],
  85. }
  86. # try encxml
  87. mobj = re.search('var flashvars={(.+?)}', webpage)
  88. if mobj is None:
  89. raise ExtractorError('Unable to extract video')
  90. params = {}
  91. encxml = ''
  92. sec = mobj.group(1)
  93. for (a, b) in re.findall('(.+?):\'(.+?)\',?', sec):
  94. if not a == '_encxml':
  95. params[a] = b
  96. else:
  97. encxml = compat_urllib_parse_unquote(b)
  98. if not params.get('domain'):
  99. params['domain'] = 'www.myvideo.de'
  100. xmldata_url = '%s?%s' % (encxml, compat_urllib_parse_urlencode(params))
  101. if 'flash_playertype=MTV' in xmldata_url:
  102. self._downloader.report_warning('avoiding MTV player')
  103. xmldata_url = (
  104. 'http://www.myvideo.de/dynamic/get_player_video_xml.php'
  105. '?flash_playertype=D&ID=%s&_countlimit=4&autorun=yes'
  106. ) % video_id
  107. # get enc data
  108. enc_data = self._download_webpage(xmldata_url, video_id).split('=')[1]
  109. enc_data_b = binascii.unhexlify(enc_data)
  110. sk = self.__md5(
  111. base64.b64decode(base64.b64decode(GK)) +
  112. self.__md5(
  113. str(video_id).encode('utf-8')
  114. )
  115. )
  116. dec_data = self.__rc4crypt(enc_data_b, sk)
  117. # extracting infos
  118. self.report_extraction(video_id)
  119. video_url = None
  120. mobj = re.search('connectionurl=\'(.*?)\'', dec_data)
  121. if mobj:
  122. video_url = compat_urllib_parse_unquote(mobj.group(1))
  123. if 'myvideo2flash' in video_url:
  124. self.report_warning(
  125. 'Rewriting URL to use unencrypted rtmp:// ...',
  126. video_id)
  127. video_url = video_url.replace('rtmpe://', 'rtmp://')
  128. if not video_url:
  129. # extract non rtmp videos
  130. mobj = re.search('path=\'(http.*?)\' source=\'(.*?)\'', dec_data)
  131. if mobj is None:
  132. raise ExtractorError('unable to extract url')
  133. video_url = compat_urllib_parse_unquote(mobj.group(1)) + compat_urllib_parse_unquote(mobj.group(2))
  134. video_file = self._search_regex('source=\'(.*?)\'', dec_data, 'video file')
  135. video_file = compat_urllib_parse_unquote(video_file)
  136. if not video_file.endswith('f4m'):
  137. ppath, prefix = video_file.split('.')
  138. video_playpath = '%s:%s' % (prefix, ppath)
  139. else:
  140. video_playpath = ''
  141. video_swfobj = self._search_regex('swfobject.embedSWF\(\'(.+?)\'', webpage, 'swfobj')
  142. video_swfobj = compat_urllib_parse_unquote(video_swfobj)
  143. video_title = self._html_search_regex("<h1(?: class='globalHd')?>(.*?)</h1>",
  144. webpage, 'title')
  145. return {
  146. 'id': video_id,
  147. 'url': video_url,
  148. 'tc_url': video_url,
  149. 'title': video_title,
  150. 'ext': 'flv',
  151. 'play_path': video_playpath,
  152. 'player_url': video_swfobj,
  153. }