INNER CODE UNIT · Python
_remove_file
xcodian/youtube-dl-web · server/src/server.py:66
def _remove_file(path: str) -> None:
if not (
path.endswith('.vtt')
or path.endswith('.srt')
or path.endswith('.ass')
):
# don't delete weird files
# better safe than sorry
return
os.remove(path)
@app.get("/sub/{video_id}")
async def api_sub(background_tasks: BackgroundTasks, video_id: str, l: str = "en", f: str = "vtt"):
if f not in ["vtt", "ass", "srt"] and not (l == "live_chat" and f == "json"):
raise HTTPException(
status_code=400,
detail="Invalid subtitle format, valid options are: vtt, ass, srt"
)