]>
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,})'
17 # Quality: Large, from iframe
19 'url': 'http://player.vimple.ru/iframe/b132bdfd71b546d3972f9ab9a25f201c',
21 'id': 'b132bdfd71b546d3972f9ab9a25f201c',
22 'title': 'great-escape-minecraft.flv',
25 'webpage_url': 'http://vimple.ru/b132bdfd71b546d3972f9ab9a25f201c',
28 # Quality: Medium, from mainpage
30 'url': 'http://vimple.ru/a15950562888453b8e6f9572dc8600cd',
32 'id': 'a15950562888453b8e6f9572dc8600cd',
36 'webpage_url': 'http://vimple.ru/a15950562888453b8e6f9572dc8600cd',
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
(
49 note
='Downloading iframe', errnote
='unable to fetch iframe')
50 player_url
= self
._html
_search
_regex
(
51 r
'"(http://player.vimple.ru/flash/.+?)"', iframe
, 'player url')
53 player
= self
._request
_webpage
(
54 player_url
, video_id
, note
='Downloading swf player').read()
56 player
= zlib
.decompress(player
[8:])
58 xml_pieces
= re
.findall(b
'([a-zA-Z0-9 =+/]{500})', player
)
59 xml_pieces
= [piece
[1:-1] for piece
in xml_pieces
]
61 xml_data
= b
''.join(xml_pieces
)
62 xml_data
= base64
.b64decode(xml_data
)
64 xml_data
= xml
.etree
.ElementTree
.fromstring(xml_data
)
66 video
= xml_data
.find('Video')
67 quality
= video
.get('quality')
68 q_tag
= video
.find(quality
.capitalize())
72 'url': q_tag
.get('url'),
73 'tbr': int(q_tag
.get('bitrate')),
74 'filesize': int(q_tag
.get('filesize')),
81 'title': video
.find('Title').text
,
83 'thumbnail': video
.find('Poster').get('url'),
84 'duration': int_or_none(video
.get('duration')),
85 'webpage_url': video
.find('Share').get('videoPageUrl'),