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