From adb5dc93d54208b5a1f64e844400cd2827800ba5 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Fri, 15 Jan 2021 01:07:05 +1300 Subject: [PATCH] Add ggpht proxy (channel-related images) --- index.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/index.py b/index.py index 620068c..3c25edf 100644 --- a/index.py +++ b/index.py @@ -1,15 +1,7 @@ -import configuration import cherrypy import json -import youtube_dlc -import datetime -import dateutil.parser -import os -import re -import json -import traceback import requests -import xml.etree.ElementTree as ET +import youtube_dlc from extractors.video import extract_video from extractors.channel import extract_channel, extract_channel_videos, extract_channel_latest from extractors.manifest import extract_manifest @@ -106,6 +98,13 @@ class Second(object): 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.expose + def ggpht(self, *path): + with requests.get("https://yt3.ggpht.com/{}".format("/".join(path))) as r: + cherrypy.response.headers["content-type"] = r.headers["content-type"] + r.raise_for_status() + return r + cherrypy.config.update({"server.socket_port": 3000, "server.socket_host": "0.0.0.0"}) cherrypy.quickstart(Second(), "/", { "/": {