tecuts commited on
Commit
38fa80f
·
verified ·
1 Parent(s): 6c4045b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -70,6 +70,7 @@ app = FastAPI(
70
  DOWNLOADS_DIR = "downloads"
71
  os.makedirs(DOWNLOADS_DIR, exist_ok=True)
72
 
 
73
  # Mount the downloads directory with cache control headers
74
  class CacheControlStaticFiles(StaticFiles):
75
  def __init__(self, directory: str):
@@ -94,6 +95,10 @@ class DownloadResponse(BaseModel):
94
  download_url: str = None
95
  file_size: int = None # Include file size in the response
96
 
 
 
 
 
97
 
98
  @app.post("/download", response_model=DownloadResponse)
99
  async def download_file(request: DownloadRequest):
@@ -146,6 +151,10 @@ async def download_file(request: DownloadRequest):
146
 
147
  # Get the file size
148
  file_size = os.path.getsize(downloaded_file)
 
 
 
 
149
 
150
  # Generate the download URL and URL encode the filename
151
  space_url = os.getenv("SPACE_URL", "https://tecuts-vob.hf.space")
@@ -183,7 +192,6 @@ async def download_file(request: DownloadRequest):
183
 
184
 
185
 
186
-
187
  @app.get("/test")
188
  async def test():
189
  """Test endpoint to verify setup"""
 
70
  DOWNLOADS_DIR = "downloads"
71
  os.makedirs(DOWNLOADS_DIR, exist_ok=True)
72
 
73
+
74
  # Mount the downloads directory with cache control headers
75
  class CacheControlStaticFiles(StaticFiles):
76
  def __init__(self, directory: str):
 
95
  download_url: str = None
96
  file_size: int = None # Include file size in the response
97
 
98
+ def env_to_cookies_from_env(cookie_path: str):
99
+ # Placeholder function for creating cookies file from environment variable
100
+ with open(cookie_path, "w") as f:
101
+ f.write("dummy_cookie_data")
102
 
103
  @app.post("/download", response_model=DownloadResponse)
104
  async def download_file(request: DownloadRequest):
 
151
 
152
  # Get the file size
153
  file_size = os.path.getsize(downloaded_file)
154
+
155
+ # Check for encryption or corruption issues
156
+ if process.stderr:
157
+ raise Exception(f"Error in downloaded file: {process.stderr}")
158
 
159
  # Generate the download URL and URL encode the filename
160
  space_url = os.getenv("SPACE_URL", "https://tecuts-vob.hf.space")
 
192
 
193
 
194
 
 
195
  @app.get("/test")
196
  async def test():
197
  """Test endpoint to verify setup"""