]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/vimple.py
2 from __future__
import unicode_literals
6 import xml
.etree
.ElementTree
8 from .common
import InfoExtractor
11 class VimpleIE(InfoExtractor
):
13 _VALID_URL
= r
'https?://(player.vimple.ru/iframe|vimple.ru)/(?P<id>[a-f0-9]{10,})'
15 # Quality: Large, from iframe
17 'url': 'http://player.vimple.ru/iframe/b132bdfd71b546d3972f9ab9a25f201c',
19 'id': 'b132bdfd71b546d3972f9ab9a25f201c',
20 'title': 'great-escape-minecraft.flv',
23 'webpage_url': 'http://vimple.ru/b132bdfd71b546d3972f9ab9a25f201c',
26 # Quality: Medium, from mainpage
28 'url': 'http://vimple.ru/a15950562888453b8e6f9572dc8600cd',
30 'id': 'a15950562888453b8e6f9572dc8600cd',
34 'webpage_url': 'http://vimple.ru/a15950562888453b8e6f9572dc8600cd',
39 # http://jsunpack-n.googlecode.com/svn-history/r63/trunk/swf.py
41 def _real_extract(self
, url
):
42 mobj
= re
.match(self
._VALID
_URL
, url
)
43 video_id
= mobj
.group('id')
45 iframe_url
= 'http://player.vimple.ru/iframe/%s' % video_id
47 iframe
= self
._download
_webpage
(iframe_url
, video_id
, note
='Downloading iframe', errnote
='unable to fetch iframe')
48 player_url
= self
._html
_search
_regex
(r
'"(http://player.vimple.ru/flash/.+?)"', iframe
, 'player url')
50 player
= self
._request
_webpage
(player_url
, video_id
, note
='Downloading swf player').read()
52 # http://stackoverflow.com/a/6804758
53 # http://stackoverflow.com/a/12073686
54 player
= zlib
.decompress(player
[8:])
56 xml_pieces
= re
.findall(b
'([a-zA-Z0-9 =+/]{500})', player
)
57 xml_pieces
= [piece
[1:-1] for piece
in xml_pieces
]
59 xml_data
= b
''.join(xml_pieces
)
60 xml_data
= base64
.b64decode(xml_data
)
62 xml_data
= xml
.etree
.ElementTree
.fromstring(xml_data
)
64 video
= xml_data
.find('Video')
65 quality
= video
.get('quality')
66 q_tag
= video
.find(quality
.capitalize())
70 'url': q_tag
.get('url'),
71 'tbr': int(q_tag
.get('bitrate')),
72 'filesize': int(q_tag
.get('filesize')),
79 'title': video
.find('Title').text
,
81 'thumbnail': video
.find('Poster').get('url'),
82 'duration': int(video
.get('duration')),
83 'webpage_url': video
.find('Share').get('videoPageUrl'),