]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/vimple.py
2 from __future__
import unicode_literals
3 import re
, zlib
, base64
4 import xml
.etree
.ElementTree
6 from .common
import InfoExtractor
8 class VimpleIE(InfoExtractor
):
10 _VALID_URL
= r
'https?://player.vimple.ru/iframe/(?P<id>[a-f0-9]+)'
13 # Quality: Large, from iframe
14 'url': 'http://player.vimple.ru/iframe/b132bdfd71b546d3972f9ab9a25f201c',
16 'id': 'b132bdfd71b546d3972f9ab9a25f201c',
17 'title': 'great-escape-minecraft.flv',
20 'webpage_url': 'http://vimple.ru/b132bdfd71b546d3972f9ab9a25f201c',
25 #http://jsunpack-n.googlecode.com/svn-history/r63/trunk/swf.py
27 def _real_extract(self
, url
):
28 mobj
= re
.match(self
._VALID
_URL
, url
)
29 video_id
= mobj
.group('id')
31 iframe_url
= 'http://player.vimple.ru/iframe/%s' % video_id
33 iframe
= self
._download
_webpage
(iframe_url
, video_id
, note
='Downloading iframe', errnote
='unable to fetch iframe')
34 player_url
= self
._html
_search
_regex
(r
'"(http://player.vimple.ru/flash/.+?)"', iframe
, 'player url')
36 player
= self
._request
_webpage
(player_url
, video_id
, note
='Downloading swf player').read()
38 #http://stackoverflow.com/a/6804758
39 #http://stackoverflow.com/a/12073686
40 player
= zlib
.decompress(player
[8:])
43 xml_pieces
= re
.findall(b
'([a-zA-Z0-9 =+/]{500})', player
)
44 xml_pieces
= [piece
[1:-1] for piece
in xml_pieces
]
46 xml_data
= b
''.join(xml_pieces
)
47 xml_data
= base64
.b64decode(xml_data
)
49 xml_data
= xml
.etree
.ElementTree
.fromstring(xml_data
)
51 video
= xml_data
.find('Video')
52 quality
= video
.get('quality')
53 q_tag
= video
.find(quality
.capitalize())
57 'url': q_tag
.get('url'),
58 'tbr': int(q_tag
.get('bitrate')),
59 'filesize': int(q_tag
.get('filesize')),
66 'title': video
.find('Title').text
,
68 'thumbnail': video
.find('Poster').get('url'),
69 'duration': int(video
.get('duration')),
70 'webpage_url': video
.find('Share').get('videoPageUrl'),