1
0
Fork 0
mirror of https://git.sr.ht/~cadence/NewLeaf synced 2026-05-04 16:41:37 +00:00

Remove with requests when it is unnecessary

This commit is contained in:
Cadence Ember 2022-01-16 21:51:26 +13:00
parent 73b4fbabf7
commit 68cfbb809f
No known key found for this signature in database
GPG key ID: BC1C2C61CF521B17
6 changed files with 244 additions and 244 deletions

View file

@ -123,17 +123,17 @@ class NewLeaf(object):
@cherrypy.expose
def vi(self, id, file):
with requests.get("https://i.ytimg.com/vi/{}/{}".format(id, file), stream=True) as r:
r.raise_for_status()
cherrypy.response.headers["content-type"] = r.headers["content-type"]
return next(r.iter_content(chunk_size=None))
r = requests.get("https://i.ytimg.com/vi/{}/{}".format(id, file), stream=True)
r.raise_for_status()
cherrypy.response.headers["content-type"] = r.headers["content-type"]
return next(r.iter_content(chunk_size=None))
@cherrypy.expose
def ggpht(self, *path):
with requests.get("https://yt3.ggpht.com/{}".format("/".join(path)), stream=True) as r:
r.raise_for_status()
cherrypy.response.headers["content-type"] = r.headers["content-type"]
return next(r.iter_content(chunk_size=None))
r = requests.get("https://yt3.ggpht.com/{}".format("/".join(path)), stream=True)
r.raise_for_status()
cherrypy.response.headers["content-type"] = r.headers["content-type"]
return next(r.iter_content(chunk_size=None))
bind_port = getattr(configuration, "bind_port", 3000)
bind_host = getattr(configuration, "bind_host", "0.0.0.0")