Neo2902 commited on
Commit ·
173a387
1
Parent(s): ba9be6f
Projet complet avec chunking, extract_playlist et youtube_search
Browse files
app.py
CHANGED
|
@@ -1,5 +1,14 @@
|
|
| 1 |
import logging
|
| 2 |
import sys
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
# Configuration de base du logging
|
| 5 |
logging.basicConfig(
|
|
@@ -9,10 +18,24 @@ logging.basicConfig(
|
|
| 9 |
logging.StreamHandler(sys.stdout)
|
| 10 |
]
|
| 11 |
)
|
| 12 |
-
|
| 13 |
logger = logging.getLogger(__name__)
|
| 14 |
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
@app.post("/extract")
|
| 18 |
async def extract(request: Request):
|
|
@@ -27,7 +50,7 @@ async def extract(request: Request):
|
|
| 27 |
|
| 28 |
try:
|
| 29 |
logger.info("Début extraction playlist")
|
| 30 |
-
songs = await extract_playlist(playlist_url)
|
| 31 |
logger.info(f"{len(songs)} morceaux extraits")
|
| 32 |
|
| 33 |
batches = list(chunking.chunk_list(songs, 10))
|
|
|
|
| 1 |
import logging
|
| 2 |
import sys
|
| 3 |
+
import asyncio
|
| 4 |
+
|
| 5 |
+
from fastapi import FastAPI, Request
|
| 6 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 7 |
+
from fastapi.responses import JSONResponse
|
| 8 |
+
|
| 9 |
+
import chunking
|
| 10 |
+
import extract_playlist_playwright
|
| 11 |
+
import youtube_search
|
| 12 |
|
| 13 |
# Configuration de base du logging
|
| 14 |
logging.basicConfig(
|
|
|
|
| 18 |
logging.StreamHandler(sys.stdout)
|
| 19 |
]
|
| 20 |
)
|
|
|
|
| 21 |
logger = logging.getLogger(__name__)
|
| 22 |
|
| 23 |
+
app = FastAPI()
|
| 24 |
+
|
| 25 |
+
origins = [
|
| 26 |
+
"http://localhost:8000",
|
| 27 |
+
"https://ton-front-netlify-url",
|
| 28 |
+
"file://",
|
| 29 |
+
"*"
|
| 30 |
+
]
|
| 31 |
+
|
| 32 |
+
app.add_middleware(
|
| 33 |
+
CORSMiddleware,
|
| 34 |
+
allow_origins=origins,
|
| 35 |
+
allow_credentials=True,
|
| 36 |
+
allow_methods=["*"],
|
| 37 |
+
allow_headers=["*"],
|
| 38 |
+
)
|
| 39 |
|
| 40 |
@app.post("/extract")
|
| 41 |
async def extract(request: Request):
|
|
|
|
| 50 |
|
| 51 |
try:
|
| 52 |
logger.info("Début extraction playlist")
|
| 53 |
+
songs = await extract_playlist_playwright.extract_playlist(playlist_url)
|
| 54 |
logger.info(f"{len(songs)} morceaux extraits")
|
| 55 |
|
| 56 |
batches = list(chunking.chunk_list(songs, 10))
|