From 582a19bd1f7b8e4478c84d20aec974aa6fb343e0 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Sat, 8 Aug 2020 02:51:32 +1200 Subject: [PATCH] Add thumbnail proxy --- index.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/index.py b/index.py index 74077e5..2397eb7 100644 --- a/index.py +++ b/index.py @@ -6,6 +6,7 @@ import os import re import json import traceback +import requests ytdl_opts = { "quiet": True, @@ -294,5 +295,12 @@ class Second(object): "isUpcoming": None } for video in info["entries"] if "title" in video) + @cherrypy.expose + def vi(self, id, file): + with requests.get("https://i.ytimg.com/vi/{}/{}".format(id, file)) as r: + r.raise_for_status() + cherrypy.response.headers["content-type"] = r.headers["content-type"] + return r # no idea if this is a good way to do it, but it definitely works! :D + cherrypy.config.update({"server.socket_port": 3000}) cherrypy.quickstart(Second())