urstark commited on
Commit
17ec854
·
1 Parent(s): f974ede

feat: stabilize MTProto streaming and unify cache schema

Browse files

- Fixed ReferenceError in /stream/ route
- Unified Redis cdn_path schema to JSON metadata
- Updated proxy-stream to pass media type to HF Space
- Fixed admin data stripping in jsonResponse
- Cleaned up legacy music bot code

Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -167,7 +167,7 @@ async def vault_media(request: VaultRequest, background_tasks: BackgroundTasks,
167
  return {"status": "accepted", "message": "Vaulting started"}
168
 
169
  @app.get("/proxy-stream/{file_id}")
170
- async def proxy_stream(file_id: str, secret: str = Header(None)):
171
  if secret != SECRET_TOKEN:
172
  raise HTTPException(status_code=401, detail="Unauthorized")
173
 
@@ -179,7 +179,8 @@ async def proxy_stream(file_id: str, secret: str = Header(None)):
179
  except Exception as e:
180
  print(f"[Stream] MTProto Error: {str(e)}")
181
 
182
- return StreamingResponse(stream_generator(), media_type="audio/mpeg")
 
183
 
184
  @app.get("/health")
185
  async def health():
 
167
  return {"status": "accepted", "message": "Vaulting started"}
168
 
169
  @app.get("/proxy-stream/{file_id}")
170
+ async def proxy_stream(file_id: str, type: str = "audio", secret: str = Header(None)):
171
  if secret != SECRET_TOKEN:
172
  raise HTTPException(status_code=401, detail="Unauthorized")
173
 
 
179
  except Exception as e:
180
  print(f"[Stream] MTProto Error: {str(e)}")
181
 
182
+ media_type = "video/mp4" if type == "video" else "audio/mpeg"
183
+ return StreamingResponse(stream_generator(), media_type=media_type)
184
 
185
  @app.get("/health")
186
  async def health():