From f45c4efcd928a173e1300a8f1ce4258e70c969b1 Mon Sep 17 00:00:00 2001 From: bashonly <88596187+bashonly@users.noreply.github.com> Date: Sun, 24 Dec 2023 10:33:16 -0600 Subject: [PATCH] [ie/litv] Fix premium content extraction (#8842) Closes #8654 Authored by: bashonly --- yt_dlp/extractor/litv.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/yt_dlp/extractor/litv.py b/yt_dlp/extractor/litv.py index 2c7c7175e..1003fb2fd 100644 --- a/yt_dlp/extractor/litv.py +++ b/yt_dlp/extractor/litv.py @@ -6,6 +6,7 @@ from ..utils import ( int_or_none, smuggle_url, traverse_obj, + try_call, unsmuggle_url, ) @@ -96,13 +97,22 @@ class LiTVIE(InfoExtractor): r'uiHlsUrl\s*=\s*testBackendData\(([^;]+)\);', webpage, 'video data', default='{}'), video_id) if not video_data: - payload = { - 'assetId': program_info['assetId'], - 'watchDevices': program_info['watchDevices'], - 'contentType': program_info['contentType'], - } + payload = {'assetId': program_info['assetId']} + puid = try_call(lambda: self._get_cookies('https://www.litv.tv/')['PUID'].value) + if puid: + payload.update({ + 'type': 'auth', + 'puid': puid, + }) + endpoint = 'getUrl' + else: + payload.update({ + 'watchDevices': program_info['watchDevices'], + 'contentType': program_info['contentType'], + }) + endpoint = 'getMainUrlNoAuth' video_data = self._download_json( - 'https://www.litv.tv/vod/ajax/getMainUrlNoAuth', video_id, + f'https://www.litv.tv/vod/ajax/{endpoint}', video_id, data=json.dumps(payload).encode('utf-8'), headers={'Content-Type': 'application/json'})