Chrunos commited on
Commit
0f2113c
·
verified ·
1 Parent(s): 171f368

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -17
app.py CHANGED
@@ -549,29 +549,30 @@ async def download_high_quality_video(request: Request):
549
  }
550
 
551
  if is_youtube_url:
552
- dl_url = await get_audio_download_url(video_url, quality)
 
553
  if dl_url and "http" in dl_url:
554
  return {"url": dl_url, "requests_remaining": rate_limiter.max_requests - rate_limiter.get_current_count(user_ip)}
555
  else:
556
  return {
557
  "error": "Failed to Fetch the video."
558
  }
559
-
560
- else:
561
- await run_in_threadpool(lambda: yt_dlp.YoutubeDL(ydl_opts).download([video_url]))
562
-
563
- downloaded_files = list(Path(global_download_dir).glob(f"*_{timestamp}.mp4"))
564
- if not downloaded_files:
565
- return {"error": "Download failed"}
566
-
567
- downloaded_file = downloaded_files[0]
568
- encoded_filename = urllib.parse.quote(downloaded_file.name)
569
- download_url = f"{BASE_URL}/file/{encoded_filename}"
570
-
571
-
572
- gc.collect()
573
-
574
- return {"url": download_url, "requests_remaining": rate_limiter.max_requests - rate_limiter.get_current_count(user_ip)}
575
 
576
 
577
 
 
549
  }
550
 
551
  if is_youtube_url:
552
+ ydl_opts["cookiefile"] = "firefox-cookies.txt"
553
+ '''dl_url = await get_audio_download_url(video_url, quality)
554
  if dl_url and "http" in dl_url:
555
  return {"url": dl_url, "requests_remaining": rate_limiter.max_requests - rate_limiter.get_current_count(user_ip)}
556
  else:
557
  return {
558
  "error": "Failed to Fetch the video."
559
  }
560
+ '''
561
+ # else:
562
+ await run_in_threadpool(lambda: yt_dlp.YoutubeDL(ydl_opts).download([video_url]))
563
+
564
+ downloaded_files = list(Path(global_download_dir).glob(f"*_{timestamp}.mp4"))
565
+ if not downloaded_files:
566
+ return {"error": "Download failed"}
567
+
568
+ downloaded_file = downloaded_files[0]
569
+ encoded_filename = urllib.parse.quote(downloaded_file.name)
570
+ download_url = f"{BASE_URL}/file/{encoded_filename}"
571
+
572
+
573
+ gc.collect()
574
+
575
+ return {"url": download_url, "requests_remaining": rate_limiter.max_requests - rate_limiter.get_current_count(user_ip)}
576
 
577
 
578