From e7ae42f28976080713c4a6734343c3f09b989922 Mon Sep 17 00:00:00 2001 From: sherl Date: Thu, 2 Oct 2025 02:27:51 +0200 Subject: [PATCH] fix: simulate pagination for clients that rely on it some clients (like clipious) use pagination on playlists and rely on videos field to tell if the playlist has no more videos. here all videos are returned for non-paginated queries, with empty video field returned for every paginated query, which page is not equal to "1" --- ythdd_inv_tl.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ythdd_inv_tl.py b/ythdd_inv_tl.py index 8e76a70..94a042f 100644 --- a/ythdd_inv_tl.py +++ b/ythdd_inv_tl.py @@ -890,8 +890,8 @@ def playlists(data, req, only_json: bool = False): # todo: make clipious stop spamming requests for paginated response page = req.args.get('page') - if page is not None and page != '1': - return send(404, {"error": "Paginated queries are not supported."}) + # if page is not None and page != '1': + # return send(404, {"error": "Paginated queries are not supported."}) plid = data[3] @@ -907,7 +907,9 @@ def playlists(data, req, only_json: bool = False): # check if request has been cached within the last hour if ythdd_globals.config['general']['cache'] and plid in ythdd_globals.general_cache['playlists']: if ythdd_globals.general_cache['playlists'][plid]['cacheTime'] + 1 * 60 * 60 > time(): - response = ythdd_globals.general_cache['playlists'][plid] + response = ythdd_globals.general_cache['playlists'][plid].copy() + if page is not None and page != '1': + response['videos'] = [] if only_json: return response else: @@ -979,9 +981,12 @@ def playlists(data, req, only_json: bool = False): # todo: cache videos and metadata separately, so that paginated queries can be supported as well if ythdd_globals.config['general']['cache']: - ythdd_globals.general_cache['playlists'][plid] = response + ythdd_globals.general_cache['playlists'][plid] = response.copy() ythdd_globals.general_cache['playlists'][plid]['cacheTime'] = time() + if page is not None or page == '1': + response['videos'] = [] + if only_json: return response