This is a teeny tiny API/Proxy to run on my server so you can see what I'm listening to on my website.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix host and scheme fr fr

J0J0HA 05bd335a 57ca2c88

+10 -3
+10 -3
src/main.py
··· 140 140 TASK_UPDATE_METADATA = asyncio.create_task(update_metadata()) 141 141 142 142 143 + def get_base_url(request: Request): 144 + host = request.headers.get("x-forwarded-host") or request.headers.get("host") 145 + proto = request.headers.get("x-forwarded-proto") or request.url.scheme 146 + return f"{proto}://{host}" 147 + 148 + 143 149 @app.get("/") 144 150 async def root(request: Request, inline: int = 0): 145 151 await ensure_updating() 152 + print(request.url, file=sys.stderr) 146 153 actual_size = now_playing.get_cover_art_size(inline) 147 154 return { 148 155 "playing": now_playing.playing, ··· 152 159 "link": now_playing.metadata.get("link"), 153 160 }, 154 161 "coverArt": { 155 - "max": str(request.url_for("cover_art")), 162 + "max": f"{get_base_url(request)}/coverart", 156 163 **{ 157 - size: str(request.url_for("cover_art_res", res=size)) 164 + size: f"{get_base_url(request)}/coverart/{size}" 158 165 for size in now_playing.cover_art.keys() 159 166 }, 160 167 **( ··· 173 180 return Response(status_code=404) 174 181 return Response(status_code=307, headers={ 175 182 "Cache-Control": "no-cache", 176 - "Location": str(request.url_for("cover_art_res", res=size)), 183 + "Location": f"{get_base_url(request)}/coverart/{size}", 177 184 }) 178 185 179 186 @app.get("/coverart/{res}")