]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/myvideo.py
47a44e3e0ec0acce8bec22fe1c2622658549ae2f
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 # Original Code from: https://github.com/dersphere/plugin.video.myvideo_de.git
23 # Released into the Public Domain by Tristan Fischer on 2013-05-19
24 # https://github.com/rg3/youtube-dl/pull/842
25 def __rc4crypt(self
,data
, key
):
27 box
= list(range(256))
28 for i
in list(range(256)):
29 x
= (x
+ box
[i
] + compat_ord(key
[i
% len(key
)])) % 256
30 box
[i
], box
[x
] = box
[x
], box
[i
]
36 y
= (y
+ box
[x
]) % 256
37 box
[x
], box
[y
] = box
[y
], box
[x
]
38 out
+= chr(compat_ord(char
) ^ box
[(box
[x
] + box
[y
]) % 256])
42 return hashlib
.md5(s
).hexdigest().encode()
44 def _real_extract(self
,url
):
45 mobj
= re
.match(self
._VALID
_URL
, url
)
47 raise ExtractorError(u
'invalid URL: %s' % url
)
49 video_id
= mobj
.group(1)
52 b
'WXpnME1EZGhNRGhpTTJNM01XVmhOREU0WldNNVpHTTJOakpt'
53 b
'TW1FMU5tVTBNR05pWkRaa05XRXhNVFJoWVRVd1ptSXhaVEV3'
54 b
'TnpsbA0KTVRkbU1tSTRNdz09'
58 webpage_url
= 'http://www.myvideo.de/watch/%s' % video_id
59 webpage
= self
._download
_webpage
(webpage_url
, video_id
)
61 mobj
= re
.search('source src=\'(.+?)[.]([^.]+)\'', webpage
)
63 self
.report_extraction(video_id
)
64 video_url
= mobj
.group(1) + '.flv'
66 video_title
= self
._html
_search
_regex
('<title>([^<]+)</title>',
69 video_ext
= self
._search
_regex
('[.](.+?)$', video_url
, u
'extension')
81 mobj
= re
.search('var flashvars={(.+?)}', webpage
)
83 raise ExtractorError(u
'Unable to extract video')
88 for (a
, b
) in re
.findall('(.+?):\'(.+?)\',?', sec
):
89 if not a
== '_encxml':
92 encxml
= compat_urllib_parse
.unquote(b
)
93 if not params
.get('domain'):
94 params
['domain'] = 'www.myvideo.de'
95 xmldata_url
= '%s?%s' % (encxml
, compat_urllib_parse
.urlencode(params
))
96 if 'flash_playertype=MTV' in xmldata_url
:
97 self
._downloader
.report_warning(u
'avoiding MTV player')
99 'http://www.myvideo.de/dynamic/get_player_video_xml.php'
100 '?flash_playertype=D&ID=%s&_countlimit=4&autorun=yes'
104 enc_data
= self
._download
_webpage
(xmldata_url
, video_id
).split('=')[1]
105 enc_data_b
= binascii
.unhexlify(enc_data
)
107 base64
.b64decode(base64
.b64decode(GK
)) +
109 str(video_id
).encode('utf-8')
112 dec_data
= self
.__rc
4crypt
(enc_data_b
, sk
)
115 self
.report_extraction(video_id
)
118 mobj
= re
.search('connectionurl=\'(.*?)\'', dec_data
)
120 video_url
= compat_urllib_parse
.unquote(mobj
.group(1))
121 if 'myvideo2flash' in video_url
:
122 self
._downloader
.report_warning(u
'forcing RTMPT ...')
123 video_url
= video_url
.replace('rtmpe://', 'rtmpt://')
126 # extract non rtmp videos
127 mobj
= re
.search('path=\'(http.*?)\' source=\'(.*?)\'', dec_data
)
129 raise ExtractorError(u
'unable to extract url')
130 video_url
= compat_urllib_parse
.unquote(mobj
.group(1)) + compat_urllib_parse
.unquote(mobj
.group(2))
132 video_file
= self
._search
_regex
('source=\'(.*?)\'', dec_data
, u
'video file')
133 video_file
= compat_urllib_parse
.unquote(video_file
)
135 if not video_file
.endswith('f4m'):
136 ppath
, prefix
= video_file
.split('.')
137 video_playpath
= '%s:%s' % (prefix
, ppath
)
138 video_hls_playlist
= ''
141 video_hls_playlist
= (
143 ).replace('.f4m', '.m3u8')
145 video_swfobj
= self
._search
_regex
('swfobject.embedSWF\(\'(.+?)\'', webpage
, u
'swfobj')
146 video_swfobj
= compat_urllib_parse
.unquote(video_swfobj
)
148 video_title
= self
._html
_search
_regex
("<h1(?: class='globalHd')?>(.*?)</h1>",
157 'title': video_title
,
159 'play_path': video_playpath
,
160 'video_file': video_file
,
161 'video_hls_playlist': video_hls_playlist
,
162 'player_url': video_swfobj
,