diff options
author | HobbyistDev <105957301+HobbyistDev@users.noreply.github.com> | 2022-07-14 02:56:57 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-13 23:26:57 +0530 |
commit | 26b92a919df60f30da199736a513b77415bc6cf2 (patch) | |
tree | 5e9304ecf6eec789af3c6e9968c0b38a12ea1894 | |
parent | 8f47b39b2700a0a6b9d863b6fda7e4334264d963 (diff) | |
download | hypervideo-pre-26b92a919df60f30da199736a513b77415bc6cf2.tar.lz hypervideo-pre-26b92a919df60f30da199736a513b77415bc6cf2.tar.xz hypervideo-pre-26b92a919df60f30da199736a513b77415bc6cf2.zip |
[extractor/tviplayer] Add extractor (#4281)
Closes #2134
Authored by: HobbyistDev
-rw-r--r-- | yt_dlp/extractor/_extractors.py | 1 | ||||
-rw-r--r-- | yt_dlp/extractor/tviplayer.py | 65 |
2 files changed, 66 insertions, 0 deletions
diff --git a/yt_dlp/extractor/_extractors.py b/yt_dlp/extractor/_extractors.py index 3ca99f3b8..44616352d 100644 --- a/yt_dlp/extractor/_extractors.py +++ b/yt_dlp/extractor/_extractors.py @@ -1834,6 +1834,7 @@ from .tvc import ( ) from .tver import TVerIE from .tvigle import TvigleIE +from .tviplayer import TVIPlayerIE from .tvland import TVLandIE from .tvn24 import TVN24IE from .tvnet import TVNetIE diff --git a/yt_dlp/extractor/tviplayer.py b/yt_dlp/extractor/tviplayer.py new file mode 100644 index 000000000..96a27a3a9 --- /dev/null +++ b/yt_dlp/extractor/tviplayer.py @@ -0,0 +1,65 @@ +from .common import InfoExtractor +from ..utils import traverse_obj + + +class TVIPlayerIE(InfoExtractor): + _VALID_URL = r'https?://tviplayer\.iol\.pt(/programa/[\w-]+/[a-f0-9]+)?/video/(?P<id>[a-f0-9]+)' + _TESTS = [{ + 'url': 'https://tviplayer.iol.pt/programa/jornal-das-8/53c6b3903004dc006243d0cf/video/61c8e8b90cf2c7ea0f0f71a9', + 'info_dict': { + 'id': '61c8e8b90cf2c7ea0f0f71a9', + 'ext': 'mp4', + 'duration': 4167, + 'title': 'Jornal das 8 - 26 de dezembro de 2021', + 'thumbnail': 'https://www.iol.pt/multimedia/oratvi/multimedia/imagem/id/61c8ee630cf2cc58e7d98d9f/', + 'season_number': 8, + 'season': 'Season 8', + } + }, { + 'url': 'https://tviplayer.iol.pt/programa/isabel/62b471090cf26256cd2a8594/video/62be445f0cf2ea4f0a5218e5', + 'info_dict': { + 'id': '62be445f0cf2ea4f0a5218e5', + 'ext': 'mp4', + 'duration': 3255, + 'season': 'Season 1', + 'title': 'Isabel - Episódio 1', + 'thumbnail': 'https://www.iol.pt/multimedia/oratvi/multimedia/imagem/id/62beac200cf2f9a86eab856b/', + 'season_number': 1, + } + }, { + 'url': 'https://tviplayer.iol.pt/video/62c4131c0cf2f9a86eac06bb', + 'info_dict': { + 'id': '62c4131c0cf2f9a86eac06bb', + 'ext': 'mp4', + 'title': 'David e Mickael Carreira respondem: «Qual é o próximo a ser pai?»', + 'thumbnail': 'https://www.iol.pt/multimedia/oratvi/multimedia/imagem/id/62c416490cf2ea367d4433fd/', + 'season': 'Season 2', + 'duration': 148, + 'season_number': 2, + } + }] + + def _real_initialize(self): + self.wms_auth_sign_token = self._download_webpage( + 'https://services.iol.pt/matrix?userId=', 'wmsAuthSign', + note='Trying to get wmsAuthSign token') + + def _real_extract(self, url): + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + + json_data = self._search_json( + r'<script>\s*jsonData\s*=\s*', webpage, 'json_data', video_id) + + formats, subtitles = self._extract_m3u8_formats_and_subtitles( + f'{json_data["videoUrl"]}?wmsAuthSign={self.wms_auth_sign_token}', + video_id, ext='mp4') + return { + 'id': video_id, + 'title': json_data.get('title') or self._og_search_title(webpage), + 'thumbnail': json_data.get('cover') or self._og_search_thumbnail(webpage), + 'duration': json_data.get('duration'), + 'formats': formats, + 'subtitles': subtitles, + 'season_number': traverse_obj(json_data, ('program', 'seasonNum')), + } |