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:
11
views.py
11
views.py
@@ -54,4 +54,15 @@ def gucProxy(received_request):
|
||||
guc.raw.decode_content = True
|
||||
response = Response(guc.raw, mimetype=guc.headers['content-type'], status=guc.status_code)
|
||||
|
||||
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
|
||||
1
ythdd.py
1
ythdd.py
@@ -66,6 +66,7 @@ def setup():
|
||||
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('/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)
|
||||
|
||||
with app.app_context():
|
||||
|
||||
@@ -23,11 +23,10 @@ import ythdd_struct_parser
|
||||
# [✓] /vi/videoIdXXXX/maxresdefault.jpg (todo: add a fallback for 404s)
|
||||
# [✓] /api/v1/search?q=... (videos and playlists)
|
||||
# [✓] /api/v1/search/suggestions?q=...&pq=...
|
||||
# [✓] /api/v1/channels/:ucid
|
||||
# [✓] /api/v1/channels/:ucid/videos, shorts, playlists
|
||||
# [✓] /api/v1/channel/:ucid
|
||||
# [✓] /api/v1/channel/:ucid/videos, shorts, playlists, streams
|
||||
# [✓] /api/v1/comments/:videoid?continuation=...
|
||||
# [✓] /api/v1/videos/videoIdXXXX
|
||||
# [X] /api/v1/channels/:ucid/streams
|
||||
# [X] /api/v1/playlists/:plid
|
||||
# [X] /api/v1/storyboards/:videoIdXXXX
|
||||
# [*] /api/v1/auth/subscriptions (stub? db?)
|
||||
@@ -35,6 +34,7 @@ import ythdd_struct_parser
|
||||
# [*] /api/v1/auth/playlists (stub? db?)
|
||||
|
||||
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():
|
||||
ythdd_globals.apiFailedRequests += 1
|
||||
|
||||
Reference in New Issue
Block a user