From 5c0dc089bfa2c6cb4c12c8e4876733514ac8ba19 Mon Sep 17 00:00:00 2001 From: Christopher Usher Date: Sun, 3 Nov 2024 01:06:29 -0800 Subject: [PATCH] Get info on the thumbnails of all videos with a given tag --- thrimshim/thrimshim/main.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/thrimshim/thrimshim/main.py b/thrimshim/thrimshim/main.py index 72549f0..8c82e29 100644 --- a/thrimshim/thrimshim/main.py +++ b/thrimshim/thrimshim/main.py @@ -763,6 +763,26 @@ def get_thumbnail(ident): return '', 404 +@app.route('/thrimshim/playlist-thumbnails/') +@request_stats +def playlist_thumbnail_info(tag): + """Get info on the thumbnails of all videos with a given tag. + + Returns a JSON list of objects conntaining the event id, video_id, upload_location, thumbnail_mode and thumbnail_template name of each public video with that tag. + """ + with app.db_manager.get_conn() as conn: + query = """ + SELECT id, video_id, upload_location, thumbnail_mode, thumbnail_template + FROM events + WHERE %s = ANY (tags) AND state = 'DONE' AND public + """ + results = database.query(conn, query, tag) + videos = [row._asdict() for row in results] + if not videos: + return 'Tag {} not found'.format(tag), 404 + + return to_json(videos) + @app.route('/thrimshim/bus/') @request_stats