1
0
mirror of https://git.sr.ht/~cadence/NewLeaf synced 2024-11-14 03:57:31 +00:00

Add thumbnail proxy

This commit is contained in:
Cadence Ember 2020-08-08 02:51:32 +12:00
parent 84dd940ac4
commit 582a19bd1f
No known key found for this signature in database
GPG Key ID: 128B99B1B74A6412

View File

@ -6,6 +6,7 @@ import os
import re import re
import json import json
import traceback import traceback
import requests
ytdl_opts = { ytdl_opts = {
"quiet": True, "quiet": True,
@ -294,5 +295,12 @@ class Second(object):
"isUpcoming": None "isUpcoming": None
} for video in info["entries"] if "title" in video) } 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.config.update({"server.socket_port": 3000})
cherrypy.quickstart(Second()) cherrypy.quickstart(Second())