]>
Commit | Line | Data |
---|---|---|
1 | from .common import InfoExtractor | |
2 | from ..utils import traverse_obj | |
3 | ||
4 | ||
5 | class TVIPlayerIE(InfoExtractor): | |
6 | _VALID_URL = r'https?://tviplayer\.iol\.pt(/programa/[\w-]+/[a-f0-9]+)?/\w+/(?P<id>\w+)' | |
7 | _TESTS = [{ | |
8 | 'url': 'https://tviplayer.iol.pt/programa/jornal-das-8/53c6b3903004dc006243d0cf/video/61c8e8b90cf2c7ea0f0f71a9', | |
9 | 'info_dict': { | |
10 | 'id': '61c8e8b90cf2c7ea0f0f71a9', | |
11 | 'ext': 'mp4', | |
12 | 'duration': 4167, | |
13 | 'title': 'Jornal das 8 - 26 de dezembro de 2021', | |
14 | 'thumbnail': 'https://www.iol.pt/multimedia/oratvi/multimedia/imagem/id/61c8ee630cf2cc58e7d98d9f/', | |
15 | 'season_number': 8, | |
16 | 'season': 'Season 8', | |
17 | }, | |
18 | }, { | |
19 | 'url': 'https://tviplayer.iol.pt/programa/isabel/62b471090cf26256cd2a8594/video/62be445f0cf2ea4f0a5218e5', | |
20 | 'info_dict': { | |
21 | 'id': '62be445f0cf2ea4f0a5218e5', | |
22 | 'ext': 'mp4', | |
23 | 'duration': 3255, | |
24 | 'season': 'Season 1', | |
25 | 'title': 'Isabel - Episódio 1', | |
26 | 'thumbnail': 'https://www.iol.pt/multimedia/oratvi/multimedia/imagem/id/62beac200cf2f9a86eab856b/', | |
27 | 'season_number': 1, | |
28 | }, | |
29 | }, { | |
30 | # no /programa/ | |
31 | 'url': 'https://tviplayer.iol.pt/video/62c4131c0cf2f9a86eac06bb', | |
32 | 'info_dict': { | |
33 | 'id': '62c4131c0cf2f9a86eac06bb', | |
34 | 'ext': 'mp4', | |
35 | 'title': 'David e Mickael Carreira respondem: «Qual é o próximo a ser pai?»', | |
36 | 'thumbnail': 'https://www.iol.pt/multimedia/oratvi/multimedia/imagem/id/62c416490cf2ea367d4433fd/', | |
37 | 'season': 'Season 2', | |
38 | 'duration': 148, | |
39 | 'season_number': 2, | |
40 | }, | |
41 | }, { | |
42 | # episodio url | |
43 | 'url': 'https://tviplayer.iol.pt/programa/para-sempre/61716c360cf2365a5ed894c4/episodio/t1e187', | |
44 | 'info_dict': { | |
45 | 'id': 't1e187', | |
46 | 'ext': 'mp4', | |
47 | 'season': 'Season 1', | |
48 | 'title': 'Quem denunciou Pedro?', | |
49 | 'thumbnail': 'https://www.iol.pt/multimedia/oratvi/multimedia/imagem/id/62eda30b0cf2ea367d48973b/', | |
50 | 'duration': 1250, | |
51 | 'season_number': 1, | |
52 | }, | |
53 | }] | |
54 | ||
55 | def _real_initialize(self): | |
56 | self.wms_auth_sign_token = self._download_webpage( | |
57 | 'https://services.iol.pt/matrix?userId=', 'wmsAuthSign', | |
58 | note='Trying to get wmsAuthSign token') | |
59 | ||
60 | def _real_extract(self, url): | |
61 | video_id = self._match_id(url) | |
62 | webpage = self._download_webpage(url, video_id) | |
63 | ||
64 | json_data = self._search_json( | |
65 | r'<script>\s*jsonData\s*=', webpage, 'json_data', video_id) | |
66 | ||
67 | formats, subtitles = self._extract_m3u8_formats_and_subtitles( | |
68 | f'{json_data["videoUrl"]}?wmsAuthSign={self.wms_auth_sign_token}', | |
69 | video_id, ext='mp4') | |
70 | return { | |
71 | 'id': video_id, | |
72 | 'title': json_data.get('title') or self._og_search_title(webpage), | |
73 | 'thumbnail': json_data.get('cover') or self._og_search_thumbnail(webpage), | |
74 | 'duration': json_data.get('duration'), | |
75 | 'formats': formats, | |
76 | 'subtitles': subtitles, | |
77 | 'season_number': traverse_obj(json_data, ('program', 'seasonNum')), | |
78 | } |