diff --git a/views.py b/views.py index 8c7e833..00fa9f9 100644 --- a/views.py +++ b/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 \ No newline at end of file diff --git a/ythdd.py b/ythdd.py index 4d7cfb4..9e9582b 100644 --- a/ythdd.py +++ b/ythdd.py @@ -66,6 +66,7 @@ def setup(): app.add_url_rule('/vi/', view_func=views.thumbnailProxy) app.add_url_rule('/ggpht/', view_func=views.ggphtProxy) app.add_url_rule('/guc/', view_func=views.gucProxy) + app.add_url_rule('/img/', view_func=views.imgProxy) db = ythdd_db.initDB(app, config) with app.app_context(): diff --git a/ythdd_inv_tl.py b/ythdd_inv_tl.py index 30beb80..aa660d1 100644 --- a/ythdd_inv_tl.py +++ b/ythdd_inv_tl.py @@ -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