prasanth.thangavel commited on
Commit
cda0e5d
·
1 Parent(s): 4789c01

Minor bug fix

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -112,16 +112,6 @@ def download_for_browser(url, mode='audio', quality='high'):
112
  # Create temporary directory that persists until file is served
113
  temp_dir = Path(tempfile.mkdtemp())
114
 
115
- if USE_FIREFOX_COOKIES == "True":
116
- # Convert cookie file to env and save locally
117
- #cookie_file = "cookies.firefox-private.txt"
118
- #env_content = cookies_to_env(cookie_file)
119
- #save_to_env_file(env_content)
120
-
121
- # Convert back to cookie file using .env
122
- cookiefile = "firefox-cookies.txt"
123
- env_to_cookies_from_env("firefox-cookies.txt")
124
-
125
  try:
126
  # Configure download options
127
  opts = {
@@ -150,11 +140,20 @@ def download_for_browser(url, mode='audio', quality='high'):
150
  'merge_output_format': 'mp4'
151
  })
152
 
153
- # Add cookies
154
  load_dotenv()
155
  USE_FIREFOX_COOKIES = os.getenv("USE_FIREFOX_COOKIES", "False")
156
- logger.info(f"Using Firefox cookies: {USE_FIREFOX_COOKIES}")
157
  if USE_FIREFOX_COOKIES == "True":
 
 
 
 
 
 
 
 
 
 
 
158
  opts["cookiefile"] = "firefox-cookies.txt" #create_temp_cookie_file()
159
  else:
160
  opts["no_cookies"] = True # Forces yt-dlp to access YouTube without any authentication
@@ -174,6 +173,7 @@ def download_for_browser(url, mode='audio', quality='high'):
174
  return None, f"File not found after download: {download_file.name}"
175
 
176
  # Return file while it exists in temp directory
 
177
  return str(download_file), f"Successfully converted: {download_file.name}"
178
 
179
  except Exception as e:
 
112
  # Create temporary directory that persists until file is served
113
  temp_dir = Path(tempfile.mkdtemp())
114
 
 
 
 
 
 
 
 
 
 
 
115
  try:
116
  # Configure download options
117
  opts = {
 
140
  'merge_output_format': 'mp4'
141
  })
142
 
 
143
  load_dotenv()
144
  USE_FIREFOX_COOKIES = os.getenv("USE_FIREFOX_COOKIES", "False")
 
145
  if USE_FIREFOX_COOKIES == "True":
146
+ # Convert cookie file to env and save locally
147
+ #cookie_file = "cookies.firefox-private.txt"
148
+ #env_content = cookies_to_env(cookie_file)
149
+ #save_to_env_file(env_content)
150
+
151
+ # Convert back to cookie file using .env
152
+ cookiefile = "firefox-cookies.txt"
153
+ env_to_cookies_from_env("firefox-cookies.txt")
154
+
155
+ # Add cookies
156
+ logger.info(f"Using Firefox cookies: {USE_FIREFOX_COOKIES}")
157
  opts["cookiefile"] = "firefox-cookies.txt" #create_temp_cookie_file()
158
  else:
159
  opts["no_cookies"] = True # Forces yt-dlp to access YouTube without any authentication
 
173
  return None, f"File not found after download: {download_file.name}"
174
 
175
  # Return file while it exists in temp directory
176
+ logger.info(f"Downloaded file: {download_file.name}")
177
  return str(download_file), f"Successfully converted: {download_file.name}"
178
 
179
  except Exception as e: