]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/myvideo.py
6 from .common
import InfoExtractor
16 class MyVideoIE(InfoExtractor
):
17 """Information Extractor for myvideo.de."""
19 _VALID_URL
= r
'(?:http://)?(?:www\.)?myvideo\.de/watch/([0-9]+)/([^?/]+).*'
22 u
'url': u
'http://www.myvideo.de/watch/8229274/bowling_fail_or_win',
23 u
'file': u
'8229274.flv',
24 u
'md5': u
'2d2753e8130479ba2cb7e0a37002053e',
26 u
"title": u
"bowling-fail-or-win"
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
):
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
]
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])
50 return hashlib
.md5(s
).hexdigest().encode()
52 def _real_extract(self
,url
):
53 mobj
= re
.match(self
._VALID
_URL
, url
)
55 raise ExtractorError(u
'invalid URL: %s' % url
)
57 video_id
= mobj
.group(1)
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>',
77 video_ext
= self
._search
_regex
('[.](.+?)$', video_url
, u
'extension')
89 mobj
= re
.search('var flashvars={(.+?)}', webpage
)
91 raise ExtractorError(u
'Unable to extract video')
96 for (a
, b
) in re
.findall('(.+?):\'(.+?)\',?', sec
):
97 if not a
== '_encxml':
100 encxml
= compat_urllib_parse
.unquote(b
)
101 if not params
.get('domain'):
102 params
['domain'] = 'www.myvideo.de'
103 xmldata_url
= '%s?%s' % (encxml
, compat_urllib_parse
.urlencode(params
))
104 if 'flash_playertype=MTV' in xmldata_url
:
105 self
._downloader
.report_warning(u
'avoiding MTV player')
107 'http://www.myvideo.de/dynamic/get_player_video_xml.php'
108 '?flash_playertype=D&ID=%s&_countlimit=4&autorun=yes'
112 enc_data
= self
._download
_webpage
(xmldata_url
, video_id
).split('=')[1]
113 enc_data_b
= binascii
.unhexlify(enc_data
)
115 base64
.b64decode(base64
.b64decode(GK
)) +
117 str(video_id
).encode('utf-8')
120 dec_data
= self
.__rc
4crypt
(enc_data_b
, sk
)
123 self
.report_extraction(video_id
)
126 mobj
= re
.search('connectionurl=\'(.*?)\'', dec_data
)
128 video_url
= compat_urllib_parse
.unquote(mobj
.group(1))
129 if 'myvideo2flash' in video_url
:
130 self
._downloader
.report_warning(u
'forcing RTMPT ...')
131 video_url
= video_url
.replace('rtmpe://', 'rtmpt://')
134 # extract non rtmp videos
135 mobj
= re
.search('path=\'(http.*?)\' source=\'(.*?)\'', dec_data
)
137 raise ExtractorError(u
'unable to extract url')
138 video_url
= compat_urllib_parse
.unquote(mobj
.group(1)) + compat_urllib_parse
.unquote(mobj
.group(2))
140 video_file
= self
._search
_regex
('source=\'(.*?)\'', dec_data
, u
'video file')
141 video_file
= compat_urllib_parse
.unquote(video_file
)
143 if not video_file
.endswith('f4m'):
144 ppath
, prefix
= video_file
.split('.')
145 video_playpath
= '%s:%s' % (prefix
, ppath
)
146 video_hls_playlist
= ''
149 video_hls_playlist
= (
151 ).replace('.f4m', '.m3u8')
153 video_swfobj
= self
._search
_regex
('swfobject.embedSWF\(\'(.+?)\'', webpage
, u
'swfobj')
154 video_swfobj
= compat_urllib_parse
.unquote(video_swfobj
)
156 video_title
= self
._html
_search
_regex
("<h1(?: class='globalHd')?>(.*?)</h1>",
165 'title': video_title
,
167 'play_path': video_playpath
,
168 'video_file': video_file
,
169 'video_hls_playlist': video_hls_playlist
,
170 'player_url': video_swfobj
,