]>
Commit | Line | Data |
---|---|---|
aee36ca8 S |
1 | import re |
2 | ||
cb28e033 | 3 | from .common import InfoExtractor |
b39f42ee | 4 | from ..compat import compat_str |
3c12a027 S |
5 | from ..utils import ( |
6 | int_or_none, | |
7 | parse_age_limit, | |
8 | parse_iso8601, | |
b39f42ee | 9 | update_url_query, |
3c12a027 | 10 | ) |
cb28e033 | 11 | |
12 | ||
3c12a027 S |
13 | class IndavideoEmbedIE(InfoExtractor): |
14 | _VALID_URL = r'https?://(?:(?:embed\.)?indavideo\.hu/player/video/|assets\.indavideo\.hu/swf/player\.swf\?.*\b(?:v(?:ID|id))=)(?P<id>[\da-f]+)' | |
15 | _TESTS = [{ | |
16 | 'url': 'http://indavideo.hu/player/video/1bdc3c6d80/', | |
2a7c6bef | 17 | 'md5': 'c8a507a1c7410685f83a06eaeeaafeab', |
3c12a027 S |
18 | 'info_dict': { |
19 | 'id': '1837039', | |
20 | 'ext': 'mp4', | |
21 | 'title': 'Cicatánc', | |
22 | 'description': '', | |
ec85ded8 | 23 | 'thumbnail': r're:^https?://.*\.jpg$', |
3c12a027 S |
24 | 'uploader': 'cukiajanlo', |
25 | 'uploader_id': '83729', | |
26 | 'timestamp': 1439193826, | |
27 | 'upload_date': '20150810', | |
28 | 'duration': 72, | |
29 | 'age_limit': 0, | |
30 | 'tags': ['tánc', 'cica', 'cuki', 'cukiajanlo', 'newsroom'], | |
cb28e033 | 31 | }, |
3c12a027 S |
32 | }, { |
33 | 'url': 'http://embed.indavideo.hu/player/video/1bdc3c6d80?autostart=1&hide=1', | |
34 | 'only_matching': True, | |
35 | }, { | |
36 | 'url': 'http://assets.indavideo.hu/swf/player.swf?v=fe25e500&vID=1bdc3c6d80&autostart=1&hide=1&i=1', | |
37 | 'only_matching': True, | |
38 | }] | |
cb28e033 | 39 | |
aee36ca8 S |
40 | # Some example URLs covered by generic extractor: |
41 | # http://indavideo.hu/video/Vicces_cica_1 | |
42 | # http://index.indavideo.hu/video/2015_0728_beregszasz | |
43 | # http://auto.indavideo.hu/video/Sajat_utanfutoban_a_kis_tacsko | |
44 | # http://erotika.indavideo.hu/video/Amator_tini_punci | |
45 | # http://film.indavideo.hu/video/f_hrom_nagymamm_volt | |
46 | # http://palyazat.indavideo.hu/video/Embertelen_dal_Dodgem_egyuttes | |
47 | ||
48 | @staticmethod | |
49 | def _extract_urls(webpage): | |
50 | return re.findall( | |
51 | r'<iframe[^>]+\bsrc=["\'](?P<url>(?:https?:)?//embed\.indavideo\.hu/player/video/[\da-f]+)', | |
52 | webpage) | |
53 | ||
cb28e033 | 54 | def _real_extract(self, url): |
3c12a027 S |
55 | video_id = self._match_id(url) |
56 | ||
57 | video = self._download_json( | |
9a269547 | 58 | 'https://amfphp.indavideo.hu/SYm0json.php/player.playerHandler.getVideoData/%s' % video_id, |
3c12a027 S |
59 | video_id)['data'] |
60 | ||
3c12a027 | 61 | title = video['title'] |
cb28e033 | 62 | |
2a7c6bef S |
63 | video_urls = [] |
64 | ||
65 | video_files = video.get('video_files') | |
66 | if isinstance(video_files, list): | |
67 | video_urls.extend(video_files) | |
68 | elif isinstance(video_files, dict): | |
69 | video_urls.extend(video_files.values()) | |
70 | ||
3c12a027 S |
71 | video_file = video.get('video_file') |
72 | if video: | |
73 | video_urls.append(video_file) | |
74 | video_urls = list(set(video_urls)) | |
cb28e033 | 75 | |
3c12a027 | 76 | video_prefix = video_urls[0].rsplit('/', 1)[0] |
cb28e033 | 77 | |
3c12a027 S |
78 | for flv_file in video.get('flv_files', []): |
79 | flv_url = '%s/%s' % (video_prefix, flv_file) | |
80 | if flv_url not in video_urls: | |
81 | video_urls.append(flv_url) | |
cb28e033 | 82 | |
b39f42ee | 83 | filesh = video.get('filesh') |
2a7c6bef S |
84 | |
85 | formats = [] | |
86 | for video_url in video_urls: | |
87 | height = int_or_none(self._search_regex( | |
88 | r'\.(\d{3,4})\.mp4(?:\?|$)', video_url, 'height', default=None)) | |
89 | if filesh: | |
90 | if not height: | |
91 | continue | |
92 | token = filesh.get(compat_str(height)) | |
93 | if token is None: | |
94 | continue | |
95 | video_url = update_url_query(video_url, {'token': token}) | |
96 | formats.append({ | |
97 | 'url': video_url, | |
98 | 'height': height, | |
99 | }) | |
3c12a027 S |
100 | self._sort_formats(formats) |
101 | ||
102 | timestamp = video.get('date') | |
103 | if timestamp: | |
104 | # upload date is in CEST | |
105 | timestamp = parse_iso8601(timestamp + ' +0200', ' ') | |
106 | ||
107 | thumbnails = [{ | |
108 | 'url': self._proto_relative_url(thumbnail) | |
109 | } for thumbnail in video.get('thumbnails', [])] | |
110 | ||
d0ff690d | 111 | tags = [tag['title'] for tag in video.get('tags') or []] |
cb28e033 | 112 | |
113 | return { | |
a34e1962 | 114 | 'id': video.get('id') or video_id, |
3c12a027 S |
115 | 'title': title, |
116 | 'description': video.get('description'), | |
cb28e033 | 117 | 'thumbnails': thumbnails, |
3c12a027 S |
118 | 'uploader': video.get('user_name'), |
119 | 'uploader_id': video.get('user_id'), | |
120 | 'timestamp': timestamp, | |
121 | 'duration': int_or_none(video.get('length')), | |
122 | 'age_limit': parse_age_limit(video.get('age_limit')), | |
cb28e033 | 123 | 'tags': tags, |
3c12a027 S |
124 | 'formats': formats, |
125 | } |