From: Lomanic <lomanic@hotmail.fr>
The chunk_size=None parameter to iter_content lets us consume data as
soon as it arrives
https://docs.python-requests.org/en/master/api/#requests.Response.iter_content
---
index.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/index.py b/index.py
index ffc35c7..bd9b7f7 100644
--- a/index.py+++ b/index.py
@@ -123,17 +123,19 @@ class NewLeaf(object):
@cherrypy.expose
def vi(self, id, file):
- with requests.get("https://i.ytimg.com/vi/{}/{}".format(id, file)) as r:+ 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 r # no idea if this is a good way to do it, but it definitely works! :D+ for chunk in r.iter_content(chunk_size=None):+ yield chunk @cherrypy.expose
def ggpht(self, *path):
- with requests.get("https://yt3.ggpht.com/{}".format("/".join(path))) as r:+ 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 r+ for chunk in r.iter_content(chunk_size=None):+ yield chunkbind_port = getattr(configuration, "bind_port", 3000)
bind_host = getattr(configuration, "bind_host", "0.0.0.0")
--
2.32.0
[PATCH NewLeaf 2/2] Fix #18 proxy videos through new /videoplayback endpoint
Export this patch