From f0b0cc63719c07c3422d3eb615c412ce46fabcc2 Mon Sep 17 00:00:00 2001 From: doe1080 <98906116+doe1080@users.noreply.github.com> Date: Fri, 13 Jun 2025 22:49:00 +0900 Subject: [PATCH] fix --- yt_dlp/extractor/ciscolive.py | 50 ++++++++++++++++------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/yt_dlp/extractor/ciscolive.py b/yt_dlp/extractor/ciscolive.py index 9b6c7d15f..2b8b689a9 100644 --- a/yt_dlp/extractor/ciscolive.py +++ b/yt_dlp/extractor/ciscolive.py @@ -10,29 +10,21 @@ try_call, urlencode_postdata, ) -from ..utils.traversal import traverse_obj +from ..utils.traversal import require, traverse_obj class CiscoLiveBaseIE(InfoExtractor): _BASE_URL = 'https://www.ciscolive.com' - _TOKEN = None - - def _real_initialize(self): - self._TOKEN = try_call(lambda: self._get_cookies(self._BASE_URL)['rfjwt'].value) - if not self._TOKEN: - self.raise_login_required() - - def _call_api(self, endpoint, some_id, payload=None, doseq=False, **kwargs): - if endpoint != 'search': - payload = {'id': some_id} + _HEADERS = { + 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', + 'Rfapiprofileid': 'HEedDIRblcZk7Ld3KHm1T0VUtZog9eG9', + 'Rfwidgetid': 'M7n14I8sz0pklW1vybwVRdKrgdREj8sR', + } + def _call_api(self, endpoint, payload, doseq=False, **kwargs): api_resp = self._download_json( - f'https://events.rainfocus.com/api/{endpoint}', some_id, headers={ - 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', - 'Rfapiprofileid': 'HEedDIRblcZk7Ld3KHm1T0VUtZog9eG9', - 'Rfauthtoken': self._TOKEN, - 'Rfwidgetid': 'M7n14I8sz0pklW1vybwVRdKrgdREj8sR', - }, data=urlencode_postdata(payload, doseq=doseq), **kwargs) + f'https://events.rainfocus.com/api/{endpoint}', payload.get('id'), + headers=self._HEADERS, data=urlencode_postdata(payload, doseq=doseq), **kwargs) if traverse_obj(api_resp, 'responseCode') != '0': msg = traverse_obj(api_resp, ('responseMessage', {str}, filter)) raise ExtractorError( @@ -58,12 +50,12 @@ class CiscoLiveSessionIE(CiscoLiveBaseIE): 'duration': 2921.387, 'series': 'Cisco Live On Demand', 'series_id': '1749591952508001pGUf', - 'tags': [], 'thumbnail': r're:https?://cf-images\.us-east-1\.prod\.boltdns\.net/.+\.jpg', 'timestamp': 1749602136, 'upload_date': '20250611', 'uploader_id': '5647924234001', }, + 'add_ie': ['BrightcoveNew'], }, { 'url': 'https://www.ciscolive.com/on-demand/on-demand-library.html#/video/1749603837855001eWhB', 'info_dict': { @@ -76,12 +68,12 @@ class CiscoLiveSessionIE(CiscoLiveBaseIE): 'duration': 2921.387, 'series': 'Cisco Live On Demand', 'series_id': '1749591952508001pGUf', - 'tags': [], 'thumbnail': r're:https?://cf-images\.us-east-1\.prod\.boltdns\.net/.+\.jpg', 'timestamp': 1749602136, 'upload_date': '20250611', 'uploader_id': '5647924234001', }, + 'add_ie': ['BrightcoveNew'], }, { 'url': 'https://www.ciscolive.com/on-demand/on-demand-library.html?search.sessiontype=Keynote#/session/1748956425383001aEIK', 'info_dict': { @@ -94,18 +86,23 @@ class CiscoLiveSessionIE(CiscoLiveBaseIE): 'duration': 4405.739, 'series': 'Cisco Live On Demand', 'series_id': '1748956425383001aEIK', - 'tags': [], 'thumbnail': r're:https?://cf-images\.us-east-1\.prod\.boltdns\.net/.+\.jpg', 'timestamp': 1748553118, 'upload_date': '20250529', 'uploader_id': '5647924234001', }, + 'add_ie': ['BrightcoveNew'], }] def _real_extract(self, url): url_type, display_id = self._match_valid_url(url).group('type', 'id') if url_type == 'video': - file = self._call_api('file', display_id) + auth_token = try_call(lambda: self._get_cookies(self._BASE_URL)['rfjwt'].value) + if not auth_token: + self.raise_login_required() + + self._HEADERS['Rfauthtoken'] = auth_token + file = self._call_api('file', {'id': display_id}) rf_id = traverse_obj(file, ('items', 'file', 'rainfocusId', {str})) else: rf_id = display_id @@ -114,13 +111,14 @@ def _real_extract(self, url): '_type': 'url_transparent', 'ie_key': 'BrightcoveNew', 'display_id': display_id, - **traverse_obj(self._call_api('session', rf_id), ('items', ..., { + **traverse_obj(self._call_api('session', {'id': rf_id}), ('items', ..., { 'title': ('title', {clean_html}), 'creators': ('participants', ..., 'fullName', {str}), 'description': ('abstract', {clean_html}), 'series': ('eventName', {clean_html}), 'series_id': ('sessionID', {str}), - 'url': ('videos', ..., 'url', {str_or_none}, {lambda x: self.BRIGHTCOVE_URL_TEMPLATE % x}, any), + 'url': ('videos', ..., 'url', {str_or_none}, + {lambda x: self.BRIGHTCOVE_URL_TEMPLATE % x}, any, {require('brightcove video ID')}), }, any)), } @@ -152,10 +150,8 @@ def _entries(self, payload): for page in itertools.count(1): search = self._call_api( - 'search', None, { - **payload, - 'from': from_val, - }, True, note=f'Downloading page {page}') + 'search', {**payload, 'from': from_val}, + doseq=True, note=f'Downloading page {page}') if not traverse_obj(search, 'sectionList'): return