From 352b1576e42d58824ef6e8a69d5dc2d03ec35992 Mon Sep 17 00:00:00 2001 From: Nuno Costa Date: Tue, 6 Jan 2026 12:49:22 +0000 Subject: [PATCH] aplied requested changes --- yt_dlp/extractor/tviplayer.py | 111 +++++++++------------------------- 1 file changed, 29 insertions(+), 82 deletions(-) diff --git a/yt_dlp/extractor/tviplayer.py b/yt_dlp/extractor/tviplayer.py index d0eb101729..4b3e4ec5e1 100644 --- a/yt_dlp/extractor/tviplayer.py +++ b/yt_dlp/extractor/tviplayer.py @@ -1,111 +1,58 @@ -from __future__ import annotations - -import re - from .common import InfoExtractor from ..utils import ( ExtractorError, + filter_dict, + int_or_none, js_to_json, + url_or_none, ) -from ..utils.traversal import ( - traverse_obj, -) +from ..utils.traversal import traverse_obj class TVIPlayerIE(InfoExtractor): - _VALID_URL = ( - r'https?://tviplayer\.iol\.pt(?:/programa/[\w-]+/[a-f0-9]+)?/\w+/(?P\w+)' - ) - _TESTS = [ - { - 'url': 'https://tviplayer.iol.pt/programa/a-protegida/67a63479d34ef72ee441fa79/episodio/t1e120', - 'info_dict': { - 'id': '689683000cf20ac1d5f35341', - 'ext': 'mp4', - 'duration': 1593, - 'title': 'A Protegida - Clarice descobre o que une Óscar a Gonçalo e Mónica', - 'thumbnail': 'https://img.iol.pt/image/id/68971037d34ef72ee44941a6/', - 'season_number': 1, - }, + _VALID_URL = r'https?://tviplayer\.iol\.pt(?:/programa/[\w-]+/[a-f0-9]+)?/\w+/(?P\w+)' + _TESTS = [{ + 'url': 'https://tviplayer.iol.pt/programa/a-protegida/67a63479d34ef72ee441fa79/episodio/t1e120', + 'info_dict': { + 'id': '689683000cf20ac1d5f35341', + 'ext': 'mp4', + 'duration': 1593, + 'title': 'A Protegida - Clarice descobre o que une Óscar a Gonçalo e Mónica', + 'thumbnail': 'https://img.iol.pt/image/id/68971037d34ef72ee44941a6/', + 'season_number': 1, }, - ] + }] def _real_initialize(self): - # Obtain the wmsAuthSign token (non-fatal) self.wms_auth_sign_token = self._download_webpage( - 'https://services.iol.pt/matrix?userId=', - 'wmsAuthSign', - note='Downloading wmsAuthSign token', - fatal=False, - ) + '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) - # Try to locate a JS "video: [ {...} ]" block json_data = self._search_json( r'(?