]>
Commit | Line | Data |
---|---|---|
cb28e033 | 1 | from .common import InfoExtractor |
3c12a027 S |
2 | from ..utils import ( |
3 | int_or_none, | |
4 | parse_age_limit, | |
5 | parse_iso8601, | |
63e0c574 | 6 | time_seconds, |
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: |
63e0c574 | 14 | # https://indavideo.hu/video/Vicces_cica_1 |
15 | # https://index.indavideo.hu/video/Hod_Nemetorszagban | |
16 | # https://auto.indavideo.hu/video/Sajat_utanfutoban_a_kis_tacsko | |
17 | # https://film.indavideo.hu/video/f_farkaslesen | |
18 | # https://palyazat.indavideo.hu/video/Embertelen_dal_Dodgem_egyuttes | |
19 | _EMBED_REGEX = [r'<iframe[^>]+\bsrc=["\'](?P<url>(?:https?:)//embed\.indavideo\.hu/player/video/[\da-f]+)'] | |
3c12a027 | 20 | _TESTS = [{ |
63e0c574 | 21 | 'url': 'https://indavideo.hu/player/video/1bdc3c6d80/', |
2a7c6bef | 22 | 'md5': 'c8a507a1c7410685f83a06eaeeaafeab', |
3c12a027 S |
23 | 'info_dict': { |
24 | 'id': '1837039', | |
25 | 'ext': 'mp4', | |
26 | 'title': 'Cicatánc', | |
27 | 'description': '', | |
ec85ded8 | 28 | 'thumbnail': r're:^https?://.*\.jpg$', |
3c12a027 S |
29 | 'uploader': 'cukiajanlo', |
30 | 'uploader_id': '83729', | |
31 | 'timestamp': 1439193826, | |
32 | 'upload_date': '20150810', | |
33 | 'duration': 72, | |
34 | 'age_limit': 0, | |
35 | 'tags': ['tánc', 'cica', 'cuki', 'cukiajanlo', 'newsroom'], | |
cb28e033 | 36 | }, |
3c12a027 | 37 | }, { |
63e0c574 | 38 | 'url': 'https://embed.indavideo.hu/player/video/1bdc3c6d80?autostart=1&hide=1', |
3c12a027 S |
39 | 'only_matching': True, |
40 | }] | |
63e0c574 | 41 | _WEBPAGE_TESTS = [{ |
42 | 'url': 'https://indavideo.hu/video/Vicces_cica_1', | |
43 | 'info_dict': { | |
44 | 'id': '1335611', | |
45 | 'ext': 'mp4', | |
46 | 'title': 'Vicces cica', | |
47 | 'description': 'Játszik a tablettel. :D', | |
48 | 'thumbnail': r're:^https?://.*\.jpg$', | |
49 | 'uploader': 'Jet_Pack', | |
50 | 'uploader_id': '491217', | |
51 | 'timestamp': 1390821212, | |
52 | 'upload_date': '20140127', | |
53 | 'duration': 7, | |
54 | 'age_limit': 0, | |
55 | 'tags': ['cica', 'Jet_Pack'], | |
56 | }, | |
57 | }] | |
cb28e033 | 58 | |
59 | def _real_extract(self, url): | |
3c12a027 S |
60 | video_id = self._match_id(url) |
61 | ||
62 | video = self._download_json( | |
63e0c574 | 63 | f'https://amfphp.indavideo.hu/SYm0json.php/player.playerHandler.getVideoData/{video_id}/', |
64 | video_id, query={'_': time_seconds()})['data'] | |
cb28e033 | 65 | |
2a7c6bef S |
66 | video_urls = [] |
67 | ||
68 | video_files = video.get('video_files') | |
69 | if isinstance(video_files, list): | |
70 | video_urls.extend(video_files) | |
71 | elif isinstance(video_files, dict): | |
72 | video_urls.extend(video_files.values()) | |
73 | ||
3c12a027 | 74 | video_urls = list(set(video_urls)) |
cb28e033 | 75 | |
63e0c574 | 76 | filesh = video.get('filesh') or {} |
2a7c6bef S |
77 | |
78 | formats = [] | |
79 | for video_url in video_urls: | |
80 | height = int_or_none(self._search_regex( | |
81 | r'\.(\d{3,4})\.mp4(?:\?|$)', video_url, 'height', default=None)) | |
63e0c574 | 82 | if not height and len(filesh) == 1: |
add96eb9 | 83 | height = int_or_none(next(iter(filesh.keys()))) |
63e0c574 | 84 | token = filesh.get(str(height)) |
85 | if token is None: | |
86 | continue | |
2a7c6bef | 87 | formats.append({ |
63e0c574 | 88 | 'url': update_url_query(video_url, {'token': token}), |
2a7c6bef S |
89 | 'height': height, |
90 | }) | |
3c12a027 S |
91 | |
92 | timestamp = video.get('date') | |
93 | if timestamp: | |
94 | # upload date is in CEST | |
95 | timestamp = parse_iso8601(timestamp + ' +0200', ' ') | |
96 | ||
97 | thumbnails = [{ | |
add96eb9 | 98 | 'url': self._proto_relative_url(thumbnail), |
3c12a027 S |
99 | } for thumbnail in video.get('thumbnails', [])] |
100 | ||
d0ff690d | 101 | tags = [tag['title'] for tag in video.get('tags') or []] |
cb28e033 | 102 | |
103 | return { | |
a34e1962 | 104 | 'id': video.get('id') or video_id, |
63e0c574 | 105 | 'title': video.get('title'), |
3c12a027 | 106 | 'description': video.get('description'), |
cb28e033 | 107 | 'thumbnails': thumbnails, |
3c12a027 S |
108 | 'uploader': video.get('user_name'), |
109 | 'uploader_id': video.get('user_id'), | |
110 | 'timestamp': timestamp, | |
111 | 'duration': int_or_none(video.get('length')), | |
112 | 'age_limit': parse_age_limit(video.get('age_limit')), | |
cb28e033 | 113 | 'tags': tags, |
3c12a027 S |
114 | 'formats': formats, |
115 | } |