Spaces:
Sleeping
Sleeping
rename getSubtitle to fetchSubtitle.
Browse files- fetchYoutubeSubtitle.py +1 -1
- main.py +2 -2
fetchYoutubeSubtitle.py
CHANGED
@@ -10,7 +10,7 @@ def getVttUrlFromSubtitles(item, lang='en', vttType="vtt"):
|
|
10 |
return item.get("url")
|
11 |
return None
|
12 |
|
13 |
-
async def
|
14 |
ydl_opts = {
|
15 |
"writesubtitles": True,
|
16 |
"allsubtitles": True,
|
|
|
10 |
return item.get("url")
|
11 |
return None
|
12 |
|
13 |
+
async def fetchSubtitle(url: str, lang: Optional[str] = 'en', vttType="vtt") -> Optional[str]:
|
14 |
ydl_opts = {
|
15 |
"writesubtitles": True,
|
16 |
"allsubtitles": True,
|
main.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
from fastapi import FastAPI
|
2 |
from fastapi.responses import JSONResponse
|
3 |
-
from fetchYoutubeSubtitle import
|
4 |
|
5 |
app = FastAPI()
|
6 |
|
@@ -16,7 +16,7 @@ def read_json():
|
|
16 |
|
17 |
@app.get("/subtitle/")
|
18 |
async def get_subtitle(url: str):
|
19 |
-
subtitle = await
|
20 |
return JSONResponse(content=subtitle)
|
21 |
|
22 |
|
|
|
1 |
from fastapi import FastAPI
|
2 |
from fastapi.responses import JSONResponse
|
3 |
+
from fetchYoutubeSubtitle import fetchSubtitle, fetchSubtitleUrls
|
4 |
|
5 |
app = FastAPI()
|
6 |
|
|
|
16 |
|
17 |
@app.get("/subtitle/")
|
18 |
async def get_subtitle(url: str):
|
19 |
+
subtitle = await fetchSubtitle(url)
|
20 |
return JSONResponse(content=subtitle)
|
21 |
|
22 |
|