]>
Commit | Line | Data |
---|---|---|
50451f2a JMF |
1 | # encoding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
2a1321a2 S |
4 | import re |
5 | ||
01c10ca2 | 6 | from .common import InfoExtractor |
cd29eaab | 7 | from ..utils import urlencode_postdata |
01c10ca2 PH |
8 | |
9 | ||
10 | class Vbox7IE(InfoExtractor): | |
9c0fa60b | 11 | _VALID_URL = r'https?://(?:www\.)?vbox7\.com/(?:play:|emb/external\.php\?.*?\bvid=)(?P<id>[\da-fA-F]+)' |
cb55908e S |
12 | _TESTS = [{ |
13 | 'url': 'http://vbox7.com/play:0946fff23c', | |
14 | 'md5': 'a60f9ab3a3a2f013ef9a967d5f7be5bf', | |
15 | 'info_dict': { | |
16 | 'id': '0946fff23c', | |
17 | 'ext': 'mp4', | |
18 | 'title': 'Борисов: Притеснен съм за бъдещето на България', | |
19 | }, | |
20 | }, { | |
50451f2a JMF |
21 | 'url': 'http://vbox7.com/play:249bb972c2', |
22 | 'md5': '99f65c0c9ef9b682b97313e052734c3f', | |
23 | 'info_dict': { | |
24 | 'id': '249bb972c2', | |
8e6f8051 | 25 | 'ext': 'mp4', |
50451f2a JMF |
26 | 'title': 'Смях! Чудо - чист за секунди - Скрита камера', |
27 | }, | |
cb55908e | 28 | 'skip': 'georestricted', |
9c0fa60b S |
29 | }, { |
30 | 'url': 'http://vbox7.com/emb/external.php?vid=a240d20f9c&autoplay=1', | |
31 | 'only_matching': True, | |
cb55908e | 32 | }] |
01c10ca2 | 33 | |
2a1321a2 S |
34 | @staticmethod |
35 | def _extract_url(webpage): | |
36 | mobj = re.search( | |
37 | '<iframe[^>]+src=(?P<q>["\'])(?P<url>(?:https?:)?//vbox7\.com/emb/external\.php.+?)(?P=q)', | |
38 | webpage) | |
39 | if mobj: | |
40 | return mobj.group('url') | |
41 | ||
50451f2a | 42 | def _real_extract(self, url): |
1cc79574 | 43 | video_id = self._match_id(url) |
01c10ca2 | 44 | |
9c0fa60b S |
45 | webpage = self._download_webpage( |
46 | 'http://vbox7.com/play:%s' % video_id, video_id) | |
cb55908e S |
47 | |
48 | title = self._html_search_regex( | |
9c0fa60b | 49 | r'<title>(.+?)</title>', webpage, 'title').split('/')[0].strip() |
cb55908e S |
50 | |
51 | video_url = self._search_regex( | |
52 | r'src\s*:\s*(["\'])(?P<url>.+?.mp4.*?)\1', | |
53 | webpage, 'video url', default=None, group='url') | |
54 | ||
55 | thumbnail_url = self._og_search_thumbnail(webpage) | |
56 | ||
57 | if not video_url: | |
58 | info_response = self._download_webpage( | |
59 | 'http://vbox7.com/play/magare.do', video_id, | |
60 | 'Downloading info webpage', | |
61 | data=urlencode_postdata({'as3': '1', 'vid': video_id}), | |
62 | headers={'Content-Type': 'application/x-www-form-urlencoded'}) | |
63 | final_url, thumbnail_url = map( | |
64 | lambda x: x.split('=')[1], info_response.split('&')) | |
65 | ||
66 | if '/na.mp4' in video_url: | |
67 | self.raise_geo_restricted() | |
01c10ca2 | 68 | |
50451f2a JMF |
69 | return { |
70 | 'id': video_id, | |
cb55908e | 71 | 'url': self._proto_relative_url(video_url, 'http:'), |
50451f2a | 72 | 'title': title, |
01c10ca2 | 73 | 'thumbnail': thumbnail_url, |
50451f2a | 74 | } |