Offex commited on
Commit
13e44e1
·
verified ·
1 Parent(s): d21a344

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -171,11 +171,13 @@ def index():
171
  def fetch():
172
  url = request.form.get("url")
173
  try:
174
- # FIX: force_ipv4=True add kiya hai taaki 'Failed to resolve' error na aaye
 
175
  opts = {
176
  'quiet': True,
177
  'nocheckcertificate': True,
178
- 'force_ipv4': True,
 
179
  'user_agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36',
180
  }
181
 
@@ -225,13 +227,14 @@ def dl():
225
  name = f"Video_{uuid.uuid4().hex[:5]}.mp4"
226
 
227
  try:
228
- # FIX: force_ipv4=True yahan bhi add kiya
229
  opts = {
230
  'format': f'{fid}+bestaudio/best',
231
  'outtmpl': name,
232
  'merge_output_format': 'mp4',
233
  'nocheckcertificate': True,
234
- 'force_ipv4': True,
 
235
  }
236
 
237
  with yt_dlp.YoutubeDL(opts) as ydl:
@@ -247,3 +250,4 @@ def dl():
247
 
248
  if __name__ == "__main__":
249
  app.run(host='0.0.0.0', port=7860)
 
 
171
  def fetch():
172
  url = request.form.get("url")
173
  try:
174
+ # --- FIX: FORCE IPV4 & DISABLE CACHE ---
175
+ # Ye settings server ko force karengi ki wo YouTube ko sahi se connect kare
176
  opts = {
177
  'quiet': True,
178
  'nocheckcertificate': True,
179
+ 'force_ipv4': True, # YEH HAI MAIN JADOO
180
+ 'cachedir': False, # Cache disable taaki purana error na aaye
181
  'user_agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36',
182
  }
183
 
 
227
  name = f"Video_{uuid.uuid4().hex[:5]}.mp4"
228
 
229
  try:
230
+ # Yahan bhi FIX lagaya hai
231
  opts = {
232
  'format': f'{fid}+bestaudio/best',
233
  'outtmpl': name,
234
  'merge_output_format': 'mp4',
235
  'nocheckcertificate': True,
236
+ 'force_ipv4': True, # IMPORTANT
237
+ 'cachedir': False,
238
  }
239
 
240
  with yt_dlp.YoutubeDL(opts) as ydl:
 
250
 
251
  if __name__ == "__main__":
252
  app.run(host='0.0.0.0', port=7860)
253
+