]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/myvideo.py
7 from .common
import InfoExtractor
11 compat_urllib_request
,
18 class MyVideoIE(InfoExtractor
):
19 """Information Extractor for myvideo.de."""
21 _VALID_URL
= r
'(?:http://)?(?:www\.)?myvideo\.de/(?:[^/]+/)?watch/([0-9]+)/([^?/]+).*'
24 u
'url': u
'http://www.myvideo.de/watch/8229274/bowling_fail_or_win',
25 u
'file': u
'8229274.flv',
26 u
'md5': u
'2d2753e8130479ba2cb7e0a37002053e',
28 u
"title": u
"bowling-fail-or-win"
32 # Original Code from: https://github.com/dersphere/plugin.video.myvideo_de.git
33 # Released into the Public Domain by Tristan Fischer on 2013-05-19
34 # https://github.com/rg3/youtube-dl/pull/842
35 def __rc4crypt(self
,data
, key
):
37 box
= list(range(256))
38 for i
in list(range(256)):
39 x
= (x
+ box
[i
] + compat_ord(key
[i
% len(key
)])) % 256
40 box
[i
], box
[x
] = box
[x
], box
[i
]
46 y
= (y
+ box
[x
]) % 256
47 box
[x
], box
[y
] = box
[y
], box
[x
]
48 out
+= chr(compat_ord(char
) ^ box
[(box
[x
] + box
[y
]) % 256])
52 return hashlib
.md5(s
).hexdigest().encode()
54 def _real_extract(self
,url
):
55 mobj
= re
.match(self
._VALID
_URL
, url
)
57 raise ExtractorError(u
'invalid URL: %s' % url
)
59 video_id
= mobj
.group(1)
62 b
'WXpnME1EZGhNRGhpTTJNM01XVmhOREU0WldNNVpHTTJOakpt'
63 b
'TW1FMU5tVTBNR05pWkRaa05XRXhNVFJoWVRVd1ptSXhaVEV3'
64 b
'TnpsbA0KTVRkbU1tSTRNdz09'
68 webpage_url
= 'http://www.myvideo.de/watch/%s' % video_id
69 webpage
= self
._download
_webpage
(webpage_url
, video_id
)
71 mobj
= re
.search('source src=\'(.+?)[.]([^.]+)\'', webpage
)
73 self
.report_extraction(video_id
)
74 video_url
= mobj
.group(1) + '.flv'
76 video_title
= self
._html
_search
_regex
('<title>([^<]+)</title>',
79 video_ext
= self
._search
_regex
('[.](.+?)$', video_url
, u
'extension')
90 mobj
= re
.search(r
'data-video-service="/service/data/video/%s/config' % video_id
, webpage
)
92 request
= compat_urllib_request
.Request('http://www.myvideo.de/service/data/video/%s/config' % video_id
, '')
93 response
= self
._download
_webpage
(request
, video_id
,
94 u
'Downloading video info')
95 info
= json
.loads(base64
.b64decode(response
).decode('utf-8'))
96 return {'id': video_id
,
97 'title': info
['title'],
98 'url': info
['streaming_url'].replace('rtmpe', 'rtmpt'),
99 'play_path': info
['filename'],
101 'thumbnail': info
['thumbnail'][0]['url'],
105 mobj
= re
.search('var flashvars={(.+?)}', webpage
)
107 raise ExtractorError(u
'Unable to extract video')
112 for (a
, b
) in re
.findall('(.+?):\'(.+?)\',?', sec
):
113 if not a
== '_encxml':
116 encxml
= compat_urllib_parse
.unquote(b
)
117 if not params
.get('domain'):
118 params
['domain'] = 'www.myvideo.de'
119 xmldata_url
= '%s?%s' % (encxml
, compat_urllib_parse
.urlencode(params
))
120 if 'flash_playertype=MTV' in xmldata_url
:
121 self
._downloader
.report_warning(u
'avoiding MTV player')
123 'http://www.myvideo.de/dynamic/get_player_video_xml.php'
124 '?flash_playertype=D&ID=%s&_countlimit=4&autorun=yes'
128 enc_data
= self
._download
_webpage
(xmldata_url
, video_id
).split('=')[1]
129 enc_data_b
= binascii
.unhexlify(enc_data
)
131 base64
.b64decode(base64
.b64decode(GK
)) +
133 str(video_id
).encode('utf-8')
136 dec_data
= self
.__rc
4crypt
(enc_data_b
, sk
)
139 self
.report_extraction(video_id
)
142 mobj
= re
.search('connectionurl=\'(.*?)\'', dec_data
)
144 video_url
= compat_urllib_parse
.unquote(mobj
.group(1))
145 if 'myvideo2flash' in video_url
:
147 u
'Rewriting URL to use unencrypted rtmp:// ...',
149 video_url
= video_url
.replace('rtmpe://', 'rtmp://')
152 # extract non rtmp videos
153 mobj
= re
.search('path=\'(http.*?)\' source=\'(.*?)\'', dec_data
)
155 raise ExtractorError(u
'unable to extract url')
156 video_url
= compat_urllib_parse
.unquote(mobj
.group(1)) + compat_urllib_parse
.unquote(mobj
.group(2))
158 video_file
= self
._search
_regex
('source=\'(.*?)\'', dec_data
, u
'video file')
159 video_file
= compat_urllib_parse
.unquote(video_file
)
161 if not video_file
.endswith('f4m'):
162 ppath
, prefix
= video_file
.split('.')
163 video_playpath
= '%s:%s' % (prefix
, ppath
)
164 video_hls_playlist
= ''
167 video_hls_playlist
= (
169 ).replace('.f4m', '.m3u8')
171 video_swfobj
= self
._search
_regex
('swfobject.embedSWF\(\'(.+?)\'', webpage
, u
'swfobj')
172 video_swfobj
= compat_urllib_parse
.unquote(video_swfobj
)
174 video_title
= self
._html
_search
_regex
("<h1(?: class='globalHd')?>(.*?)</h1>",
183 'title': video_title
,
185 'play_path': video_playpath
,
186 'video_file': video_file
,
187 'video_hls_playlist': video_hls_playlist
,
188 'player_url': video_swfobj
,