]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/vimple.py
2 from __future__
import unicode_literals
6 import xml
.etree
.ElementTree
9 from .common
import InfoExtractor
10 from ..utils
import int_or_none
13 class VimpleIE(InfoExtractor
):
15 _VALID_URL
= r
'https?://(player.vimple.ru/iframe|vimple.ru)/(?P<id>[a-f0-9]{10,})'
18 'url': 'http://vimple.ru/c0f6b1687dcd4000a97ebe70068039cf',
19 'md5': '2e750a330ed211d3fd41821c6ad9a279',
21 'id': 'c0f6b1687dcd4000a97ebe70068039cf',
25 'thumbnail': 're:https?://.*?\.jpg',
30 def _real_extract(self
, url
):
31 mobj
= re
.match(self
._VALID
_URL
, url
)
32 video_id
= mobj
.group('id')
34 iframe_url
= 'http://player.vimple.ru/iframe/%s' % video_id
36 iframe
= self
._download
_webpage
(
38 note
='Downloading iframe', errnote
='unable to fetch iframe')
39 player_url
= self
._html
_search
_regex
(
40 r
'"(http://player.vimple.ru/flash/.+?)"', iframe
, 'player url')
42 player
= self
._request
_webpage
(
43 player_url
, video_id
, note
='Downloading swf player').read()
45 player
= zlib
.decompress(player
[8:])
47 xml_pieces
= re
.findall(b
'([a-zA-Z0-9 =+/]{500})', player
)
48 xml_pieces
= [piece
[1:-1] for piece
in xml_pieces
]
50 xml_data
= b
''.join(xml_pieces
)
51 xml_data
= base64
.b64decode(xml_data
)
53 xml_data
= xml
.etree
.ElementTree
.fromstring(xml_data
)
55 video
= xml_data
.find('Video')
56 quality
= video
.get('quality')
57 q_tag
= video
.find(quality
.capitalize())
61 'url': q_tag
.get('url'),
62 'tbr': int(q_tag
.get('bitrate')),
63 'filesize': int(q_tag
.get('filesize')),
70 'title': video
.find('Title').text
,
72 'thumbnail': video
.find('Poster').get('url'),
73 'duration': int_or_none(video
.get('duration')),
74 'webpage_url': video
.find('Share').get('videoPageUrl'),