mirror of
https://git.srhtnin.garden/sarah/SaraView.git
synced 2026-10-15 02:43:17 +02:00
Added MP4 audio embeds for Discord in AudioEmbed.py
This commit is contained in:
1 parent
2d5ab15f52
commit
d778be91cd
4 files changed
+174
-8
No files matched your search
@@ -18,6 +18,7 @@ from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.responses import FileResponse, HTMLResponse, PlainTextResponse, StreamingResponse
|
||||
from starlette.background import BackgroundTask
|
||||
|
||||
import AudioEmbed
|
||||
from Auth import (
|
||||
CreateSession,
|
||||
DeleteSession,
|
||||
@@ -926,6 +927,28 @@ def GetPublicMediaEndpoint(RootName: str, FilePath: str, request: Request):
|
||||
return StreamBinaryFile(ResolvedPath, request.headers.get("range"))
|
||||
|
||||
|
||||
@Application.get("/public/embed/{RootName}/{FilePath:path}")
|
||||
def GetPublicEmbedEndpoint(RootName: str, FilePath: str, request: Request):
|
||||
"""A public audio file as an MP4 (still picture + track) for link embeds;
|
||||
see AudioEmbed.py."""
|
||||
if not IsPathAccessible(RootName, FilePath, "", [GuestGroupName]):
|
||||
raise HTTPException(status_code=404, detail="Not found.")
|
||||
|
||||
try:
|
||||
ResolvedPath = ResolvePath(RootName, FilePath)
|
||||
except ValueError as Error:
|
||||
raise HTTPException(status_code=400, detail=str(Error))
|
||||
|
||||
if not ResolvedPath.is_file() or ClassifyFile(ResolvedPath) != "audio":
|
||||
raise HTTPException(status_code=404, detail="Not an audio file.")
|
||||
|
||||
VideoPath = AudioEmbed.GetEmbedVideo(ResolvedPath)
|
||||
if VideoPath is None:
|
||||
raise HTTPException(status_code=503, detail="Couldn't make the embed video.")
|
||||
|
||||
return StreamBinaryFile(VideoPath, request.headers.get("range"))
|
||||
|
||||
|
||||
def GetForwardedScheme(request: Request) -> str:
|
||||
ForwardedProto = request.headers.get("x-forwarded-proto")
|
||||
if ForwardedProto:
|
||||
|
||||
Reference in new issue
Block a user