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"
This commit is contained in:
@@ -890,8 +890,8 @@ def playlists(data, req, only_json: bool = False):
|
|||||||
|
|
||||||
# todo: make clipious stop spamming requests for paginated response
|
# todo: make clipious stop spamming requests for paginated response
|
||||||
page = req.args.get('page')
|
page = req.args.get('page')
|
||||||
if page is not None and page != '1':
|
# if page is not None and page != '1':
|
||||||
return send(404, {"error": "Paginated queries are not supported."})
|
# return send(404, {"error": "Paginated queries are not supported."})
|
||||||
|
|
||||||
plid = data[3]
|
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
|
# 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.config['general']['cache'] and plid in ythdd_globals.general_cache['playlists']:
|
||||||
if ythdd_globals.general_cache['playlists'][plid]['cacheTime'] + 1 * 60 * 60 > time():
|
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:
|
if only_json:
|
||||||
return response
|
return response
|
||||||
else:
|
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
|
# todo: cache videos and metadata separately, so that paginated queries can be supported as well
|
||||||
if ythdd_globals.config['general']['cache']:
|
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()
|
ythdd_globals.general_cache['playlists'][plid]['cacheTime'] = time()
|
||||||
|
|
||||||
|
if page is not None or page == '1':
|
||||||
|
response['videos'] = []
|
||||||
|
|
||||||
if only_json:
|
if only_json:
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user