]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/myvideo.py
a89153985984a6d36e88c8290124203c20c4abb2
1 from __future__
import unicode_literals
9 from .common
import InfoExtractor
10 from ..compat
import (
13 compat_urllib_request
,
20 class MyVideoIE(InfoExtractor
):
21 _VALID_URL
= r
'http://(?:www\.)?myvideo\.de/(?:[^/]+/)?watch/(?P<id>[0-9]+)/[^?/]+.*'
24 'url': 'http://www.myvideo.de/watch/8229274/bowling_fail_or_win',
25 'md5': '2d2753e8130479ba2cb7e0a37002053e',
29 'title': 'bowling-fail-or-win',
33 # Original Code from: https://github.com/dersphere/plugin.video.myvideo_de.git
34 # Released into the Public Domain by Tristan Fischer on 2013-05-19
35 # https://github.com/rg3/youtube-dl/pull/842
36 def __rc4crypt(self
,data
, key
):
38 box
= list(range(256))
39 for i
in list(range(256)):
40 x
= (x
+ box
[i
] + compat_ord(key
[i
% len(key
)])) % 256
41 box
[i
], box
[x
] = box
[x
], box
[i
]
47 y
= (y
+ box
[x
]) % 256
48 box
[x
], box
[y
] = box
[y
], box
[x
]
49 out
+= chr(compat_ord(char
) ^ box
[(box
[x
] + box
[y
]) % 256])
53 return hashlib
.md5(s
).hexdigest().encode()
55 def _real_extract(self
,url
):
56 mobj
= re
.match(self
._VALID
_URL
, url
)
57 video_id
= mobj
.group('id')
60 b
'WXpnME1EZGhNRGhpTTJNM01XVmhOREU0WldNNVpHTTJOakpt'
61 b
'TW1FMU5tVTBNR05pWkRaa05XRXhNVFJoWVRVd1ptSXhaVEV3'
62 b
'TnpsbA0KTVRkbU1tSTRNdz09'
66 webpage_url
= 'http://www.myvideo.de/watch/%s' % video_id
67 webpage
= self
._download
_webpage
(webpage_url
, video_id
)
69 mobj
= re
.search('source src=\'(.+?)[.]([^.]+)\'', webpage
)
71 self
.report_extraction(video_id
)
72 video_url
= mobj
.group(1) + '.flv'
74 video_title
= self
._html
_search
_regex
('<title>([^<]+)</title>',
83 mobj
= re
.search(r
'data-video-service="/service/data/video/%s/config' % video_id
, webpage
)
85 request
= compat_urllib_request
.Request('http://www.myvideo.de/service/data/video/%s/config' % video_id
, '')
86 response
= self
._download
_webpage
(request
, video_id
,
87 'Downloading video info')
88 info
= json
.loads(base64
.b64decode(response
).decode('utf-8'))
91 'title': info
['title'],
92 'url': info
['streaming_url'].replace('rtmpe', 'rtmpt'),
93 'play_path': info
['filename'],
95 'thumbnail': info
['thumbnail'][0]['url'],
99 mobj
= re
.search('var flashvars={(.+?)}', webpage
)
101 raise ExtractorError('Unable to extract video')
106 for (a
, b
) in re
.findall('(.+?):\'(.+?)\',?', sec
):
107 if not a
== '_encxml':
110 encxml
= compat_urllib_parse
.unquote(b
)
111 if not params
.get('domain'):
112 params
['domain'] = 'www.myvideo.de'
113 xmldata_url
= '%s?%s' % (encxml
, compat_urllib_parse
.urlencode(params
))
114 if 'flash_playertype=MTV' in xmldata_url
:
115 self
._downloader
.report_warning('avoiding MTV player')
117 'http://www.myvideo.de/dynamic/get_player_video_xml.php'
118 '?flash_playertype=D&ID=%s&_countlimit=4&autorun=yes'
122 enc_data
= self
._download
_webpage
(xmldata_url
, video_id
).split('=')[1]
123 enc_data_b
= binascii
.unhexlify(enc_data
)
125 base64
.b64decode(base64
.b64decode(GK
)) +
127 str(video_id
).encode('utf-8')
130 dec_data
= self
.__rc
4crypt
(enc_data_b
, sk
)
133 self
.report_extraction(video_id
)
136 mobj
= re
.search('connectionurl=\'(.*?)\'', dec_data
)
138 video_url
= compat_urllib_parse
.unquote(mobj
.group(1))
139 if 'myvideo2flash' in video_url
:
141 'Rewriting URL to use unencrypted rtmp:// ...',
143 video_url
= video_url
.replace('rtmpe://', 'rtmp://')
146 # extract non rtmp videos
147 mobj
= re
.search('path=\'(http.*?)\' source=\'(.*?)\'', dec_data
)
149 raise ExtractorError('unable to extract url')
150 video_url
= compat_urllib_parse
.unquote(mobj
.group(1)) + compat_urllib_parse
.unquote(mobj
.group(2))
152 video_file
= self
._search
_regex
('source=\'(.*?)\'', dec_data
, 'video file')
153 video_file
= compat_urllib_parse
.unquote(video_file
)
155 if not video_file
.endswith('f4m'):
156 ppath
, prefix
= video_file
.split('.')
157 video_playpath
= '%s:%s' % (prefix
, ppath
)
161 video_swfobj
= self
._search
_regex
('swfobject.embedSWF\(\'(.+?)\'', webpage
, 'swfobj')
162 video_swfobj
= compat_urllib_parse
.unquote(video_swfobj
)
164 video_title
= self
._html
_search
_regex
("<h1(?: class='globalHd')?>(.*?)</h1>",
171 'title': video_title
,
173 'play_path': video_playpath
,
174 'player_url': video_swfobj
,