From ec6e9ed8cd11179f7067f7ee64b31523e289eef9 Mon Sep 17 00:00:00 2001 From: Patrick Menschel Date: Fri, 19 May 2023 20:31:52 +0200 Subject: [PATCH] [PikSel] Feat: Add variable host support _call_api function was using hardcoded hosts --- youtube_dl/extractor/piksel.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/youtube_dl/extractor/piksel.py b/youtube_dl/extractor/piksel.py index ecf56ff8f..aad4e7f7d 100644 --- a/youtube_dl/extractor/piksel.py +++ b/youtube_dl/extractor/piksel.py @@ -12,6 +12,7 @@ from ..utils import ( parse_iso8601, try_get, unescapeHTML, + urljoin ) @@ -73,10 +74,9 @@ class PikselIE(InfoExtractor): if mobj: return mobj.group('url') - def _call_api(self, app_token, resource, display_id, query, fatal=True): - response = (self._download_json( - 'http://player.piksel.com/ws/ws_%s/api/%s/mode/json/apiv/5' % (resource, app_token), - display_id, query=query, fatal=fatal) or {}).get('response') + def _call_api(self, app_token, resource, display_id, query, host="https://player.piksel.com", fatal=True): + url = urljoin(base=host, path='/ws/ws_%s/api/%s/mode/json/apiv/5' % (resource, app_token)) + response = (self._download_json(url, display_id, query=query, fatal=fatal) or {}).get('response') failure = try_get(response, lambda x: x['failure']['reason']) if failure: if fatal: @@ -93,7 +93,7 @@ class PikselIE(InfoExtractor): ], webpage, 'app token') query = {'refid': ref_id, 'prefid': display_id} if ref_id else {'v': display_id} program = self._call_api( - app_token, 'program', display_id, query)['WsProgramResponse']['program'] + app_token, 'program', display_id, query, url)['WsProgramResponse']['program'] video_id = program['uuid'] video_data = program['asset'] title = video_data['title'] @@ -143,7 +143,7 @@ class PikselIE(InfoExtractor): process_asset_files(try_get(self._call_api( app_token, 'asset_file', display_id, { 'assetid': asset_id, - }, False), lambda x: x['WsAssetFileResponse']['AssetFiles'])) + }, url, False), lambda x: x['WsAssetFileResponse']['AssetFiles'])) m3u8_url = dict_get(video_data, [ 'm3u8iPadURL',