feat: add a temporary proxy for no_thumbnail

ideally, this would be served from a local resource instead of proxying
This commit is contained in:
2025-09-25 06:36:23 +02:00
parent caa9e0c2b1
commit 509e81aafa
3 changed files with 15 additions and 3 deletions

View File

@@ -55,3 +55,14 @@ def gucProxy(received_request):
response = Response(guc.raw, mimetype=guc.headers['content-type'], status=guc.status_code) response = Response(guc.raw, mimetype=guc.headers['content-type'], status=guc.status_code)
return response return response
def imgProxy(received_request):
# will proxy /img/no_thumbnail.jpg
prefix = "https://i.ytimg.com/"
thumbnail = requests.get(prefix + "img/" + received_request, headers=ythdd_globals.getHeaders(caller='proxy'), stream=True)
thumbnail.raw.decode_content = True
response = Response(thumbnail.raw, mimetype=thumbnail.headers['content-type'], status=thumbnail.status_code)
return response

View File

@@ -66,6 +66,7 @@ def setup():
app.add_url_rule('/vi/<path:received_request>', view_func=views.thumbnailProxy) app.add_url_rule('/vi/<path:received_request>', view_func=views.thumbnailProxy)
app.add_url_rule('/ggpht/<path:received_request>', view_func=views.ggphtProxy) app.add_url_rule('/ggpht/<path:received_request>', view_func=views.ggphtProxy)
app.add_url_rule('/guc/<path:received_request>', view_func=views.gucProxy) app.add_url_rule('/guc/<path:received_request>', view_func=views.gucProxy)
app.add_url_rule('/img/<path:received_request>', view_func=views.imgProxy)
db = ythdd_db.initDB(app, config) db = ythdd_db.initDB(app, config)
with app.app_context(): with app.app_context():

View File

@@ -23,11 +23,10 @@ import ythdd_struct_parser
# [✓] /vi/videoIdXXXX/maxresdefault.jpg (todo: add a fallback for 404s) # [✓] /vi/videoIdXXXX/maxresdefault.jpg (todo: add a fallback for 404s)
# [✓] /api/v1/search?q=... (videos and playlists) # [✓] /api/v1/search?q=... (videos and playlists)
# [✓] /api/v1/search/suggestions?q=...&pq=... # [✓] /api/v1/search/suggestions?q=...&pq=...
# [✓] /api/v1/channels/:ucid # [✓] /api/v1/channel/:ucid
# [✓] /api/v1/channels/:ucid/videos, shorts, playlists # [✓] /api/v1/channel/:ucid/videos, shorts, playlists, streams
# [✓] /api/v1/comments/:videoid?continuation=... # [✓] /api/v1/comments/:videoid?continuation=...
# [✓] /api/v1/videos/videoIdXXXX # [✓] /api/v1/videos/videoIdXXXX
# [X] /api/v1/channels/:ucid/streams
# [X] /api/v1/playlists/:plid # [X] /api/v1/playlists/:plid
# [X] /api/v1/storyboards/:videoIdXXXX # [X] /api/v1/storyboards/:videoIdXXXX
# [*] /api/v1/auth/subscriptions (stub? db?) # [*] /api/v1/auth/subscriptions (stub? db?)
@@ -35,6 +34,7 @@ import ythdd_struct_parser
# [*] /api/v1/auth/playlists (stub? db?) # [*] /api/v1/auth/playlists (stub? db?)
DEFAULT_AVATAR = "https://yt3.ggpht.com/a/default-user=s176-c-k-c0x00ffffff-no-rj" DEFAULT_AVATAR = "https://yt3.ggpht.com/a/default-user=s176-c-k-c0x00ffffff-no-rj"
DEFAULT_VIDEO = "https://i.ytimg.com/img/no_thumbnail.jpg" # todo: replace this with a custom, local asset
def incrementBadRequests(): def incrementBadRequests():
ythdd_globals.apiFailedRequests += 1 ythdd_globals.apiFailedRequests += 1