Update app.py
Browse files
app.py
CHANGED
@@ -27,8 +27,6 @@ DEEZER_API_URL = "https://api.deezer.com"
|
|
27 |
ARL_TOKEN = os.getenv('ARL')
|
28 |
dl = DeeLogin(arl=ARL_TOKEN)
|
29 |
|
30 |
-
Base_URL= "https://tecuts-depot.hf.space"
|
31 |
-
|
32 |
@app.get("/")
|
33 |
def read_root():
|
34 |
return {"message": "running"}
|
@@ -89,7 +87,12 @@ def download_track(track_id: str, quality: str = "MP3_320"):
|
|
89 |
if len(downloaded_files) == 0:
|
90 |
raise HTTPException(status_code=500, detail="File download failed")
|
91 |
|
92 |
-
|
|
|
|
|
|
|
|
|
|
|
93 |
found_filepath = os.path.join("downloads", found_file)
|
94 |
|
95 |
# Return the download URL
|
@@ -99,7 +102,6 @@ def download_track(track_id: str, quality: str = "MP3_320"):
|
|
99 |
except Exception as e:
|
100 |
logger.error(f"Error downloading track: {e}")
|
101 |
raise HTTPException(status_code=500, detail=str(e))
|
102 |
-
|
103 |
|
104 |
# Search tracks using Deezer API
|
105 |
@app.get("/search")
|
|
|
27 |
ARL_TOKEN = os.getenv('ARL')
|
28 |
dl = DeeLogin(arl=ARL_TOKEN)
|
29 |
|
|
|
|
|
30 |
@app.get("/")
|
31 |
def read_root():
|
32 |
return {"message": "running"}
|
|
|
87 |
if len(downloaded_files) == 0:
|
88 |
raise HTTPException(status_code=500, detail="File download failed")
|
89 |
|
90 |
+
# Find the MP3 file
|
91 |
+
mp3_files = [file for file in downloaded_files if file.endswith('.mp3')]
|
92 |
+
if len(mp3_files) == 0:
|
93 |
+
raise HTTPException(status_code=500, detail="MP3 file not found after download")
|
94 |
+
|
95 |
+
found_file = mp3_files[0]
|
96 |
found_filepath = os.path.join("downloads", found_file)
|
97 |
|
98 |
# Return the download URL
|
|
|
102 |
except Exception as e:
|
103 |
logger.error(f"Error downloading track: {e}")
|
104 |
raise HTTPException(status_code=500, detail=str(e))
|
|
|
105 |
|
106 |
# Search tracks using Deezer API
|
107 |
@app.get("/search")
|