]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/vbox7.py
bef6394626d4eca25785d35199c1092f69f45b54
[youtubedl] / youtube_dl / extractor / vbox7.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7 from ..utils import ExtractorError
8
9
10 class Vbox7IE(InfoExtractor):
11 _VALID_URL = r'''(?x)
12 https?://
13 (?:[^/]+\.)?vbox7\.com/
14 (?:
15 play:|
16 (?:
17 emb/external\.php|
18 player/ext\.swf
19 )\?.*?\bvid=
20 )
21 (?P<id>[\da-fA-F]+)
22 '''
23 _TESTS = [{
24 'url': 'http://vbox7.com/play:0946fff23c',
25 'md5': 'a60f9ab3a3a2f013ef9a967d5f7be5bf',
26 'info_dict': {
27 'id': '0946fff23c',
28 'ext': 'mp4',
29 'title': 'Борисов: Притеснен съм за бъдещето на България',
30 'description': 'По думите му е опасно страната ни да бъде обявена за "сигурна"',
31 'thumbnail': r're:^https?://.*\.jpg$',
32 'timestamp': 1470982814,
33 'upload_date': '20160812',
34 'uploader': 'zdraveibulgaria',
35 },
36 'params': {
37 'proxy': '127.0.0.1:8118',
38 },
39 }, {
40 'url': 'http://vbox7.com/play:249bb972c2',
41 'md5': '99f65c0c9ef9b682b97313e052734c3f',
42 'info_dict': {
43 'id': '249bb972c2',
44 'ext': 'mp4',
45 'title': 'Смях! Чудо - чист за секунди - Скрита камера',
46 },
47 'skip': 'georestricted',
48 }, {
49 'url': 'http://vbox7.com/emb/external.php?vid=a240d20f9c&autoplay=1',
50 'only_matching': True,
51 }, {
52 'url': 'http://i49.vbox7.com/player/ext.swf?vid=0946fff23c&autoplay=1',
53 'only_matching': True,
54 }]
55
56 @staticmethod
57 def _extract_url(webpage):
58 mobj = re.search(
59 r'<iframe[^>]+src=(?P<q>["\'])(?P<url>(?:https?:)?//vbox7\.com/emb/external\.php.+?)(?P=q)',
60 webpage)
61 if mobj:
62 return mobj.group('url')
63
64 def _real_extract(self, url):
65 video_id = self._match_id(url)
66
67 response = self._download_json(
68 'https://www.vbox7.com/ajax/video/nextvideo.php?vid=%s' % video_id,
69 video_id)
70
71 if 'error' in response:
72 raise ExtractorError(
73 '%s said: %s' % (self.IE_NAME, response['error']), expected=True)
74
75 video = response['options']
76
77 title = video['title']
78 video_url = video['src']
79
80 if '/na.mp4' in video_url:
81 self.raise_geo_restricted()
82
83 uploader = video.get('uploader')
84
85 webpage = self._download_webpage(
86 'http://vbox7.com/play:%s' % video_id, video_id, fatal=None)
87
88 info = {}
89
90 if webpage:
91 info = self._search_json_ld(
92 webpage.replace('"/*@context"', '"@context"'), video_id,
93 fatal=False)
94
95 info.update({
96 'id': video_id,
97 'title': title,
98 'url': video_url,
99 'uploader': uploader,
100 'thumbnail': self._proto_relative_url(
101 info.get('thumbnail') or self._og_search_thumbnail(webpage),
102 'http:'),
103 })
104 return info