tecuts commited on
Commit
40bd669
·
verified ·
1 Parent(s): b642c37

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -5,12 +5,15 @@ import os
5
  import logging
6
  from typing import Optional
7
  from fastapi.staticfiles import StaticFiles
 
8
 
9
  # Set up logging
10
  logging.basicConfig(level=logging.INFO)
11
  logger = logging.getLogger(__name__)
12
 
13
  app = FastAPI(title="Deezer API")
 
 
14
 
15
  # Mount a static files directory to serve downloaded files
16
  os.makedirs("downloads", exist_ok=True)
@@ -20,12 +23,12 @@ app.mount("/downloads", StaticFiles(directory="downloads"), name="downloads")
20
  DEEZER_API_URL = "https://api.deezer.com"
21
 
22
  # Deezer ARL token (required for deezspot downloads)
23
- ARL_TOKEN = "9850d663715d56830e6cdb4d28d19491d8c9d9a8ee31c160a0f5e06116b6d8035fb01c5323ec9690e49a32c0580c0a84e484366df2d6a8ac5786d30a95dc660771fbb372735cb2b39d4081bf30284f08319c0f73f6ad34d3d6bcb4449226877c" # Replace with your ARL token
24
  dl = DeeLogin(arl=ARL_TOKEN)
25
 
26
  @app.get("/")
27
  def read_root():
28
- return {"message": "Deezer API Endpoints - Use /track/{track_id}"}
29
 
30
  # Fetch track metadata from Deezer API
31
  @app.get("/track/{track_id}")
@@ -75,7 +78,7 @@ def download_track(track_id: str, quality: str = "MP3_320"):
75
 
76
  # Try to find the file with a similar name
77
  for file in downloaded_files:
78
- if track_title.lower() in file.lower() and artist_name.lower() in file.lower():
79
  filepath = os.path.join("downloads", file)
80
  logger.info(f"Found matching file: {filepath}")
81
  break
 
5
  import logging
6
  from typing import Optional
7
  from fastapi.staticfiles import StaticFiles
8
+ from dotenv import load_dotenv
9
 
10
  # Set up logging
11
  logging.basicConfig(level=logging.INFO)
12
  logger = logging.getLogger(__name__)
13
 
14
  app = FastAPI(title="Deezer API")
15
+ # Load environment variables
16
+ load_dotenv()
17
 
18
  # Mount a static files directory to serve downloaded files
19
  os.makedirs("downloads", exist_ok=True)
 
23
  DEEZER_API_URL = "https://api.deezer.com"
24
 
25
  # Deezer ARL token (required for deezspot downloads)
26
+ ARL_TOKEN = os.get_env('ARL')
27
  dl = DeeLogin(arl=ARL_TOKEN)
28
 
29
  @app.get("/")
30
  def read_root():
31
+ return {"message": "running}"}
32
 
33
  # Fetch track metadata from Deezer API
34
  @app.get("/track/{track_id}")
 
78
 
79
  # Try to find the file with a similar name
80
  for file in downloaded_files:
81
+ if track_title.lower() in file.lower() or artist_name.lower() in file.lower():
82
  filepath = os.path.join("downloads", file)
83
  logger.info(f"Found matching file: {filepath}")
84
  break