Spaces:
Sleeping
Sleeping
Create main.py
Browse files
main.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
|
3 |
+
import yt_dlp
|
4 |
+
app = FastAPI()
|
5 |
+
|
6 |
+
|
7 |
+
@app.get("/")
|
8 |
+
async def root():
|
9 |
+
return {"message": "Hello World"}
|
10 |
+
@app.get("/dailymo/")
|
11 |
+
async def read_item(reqUrl: str = 'https://www.dailymotion.com/video/x8pdo3p', vidFormat: str='http-720-0'):
|
12 |
+
|
13 |
+
video_url = reqUrl
|
14 |
+
desired_format = vidFormat
|
15 |
+
ydl_opts = {
|
16 |
+
'quiet': True,
|
17 |
+
'format': desired_format,
|
18 |
+
}
|
19 |
+
ydl = yt_dlp.YoutubeDL(ydl_opts)
|
20 |
+
info_dict = ydl.extract_info(video_url, download=False)
|
21 |
+
format_url = info_dict.get('url')
|
22 |
+
if format_url:
|
23 |
+
return {"url":format_url,"reqUrl":reqUrl,"vidFormat":vidFormat}
|
24 |
+
else:
|
25 |
+
return {"url":"Not found","reqUrl":reqUrl,"vidFormat":vidFormat}
|