Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from flask import Flask, render_template, request, send_file
|
| 2 |
import yt_dlp
|
| 3 |
import os
|
|
@@ -37,9 +53,9 @@ def download():
|
|
| 37 |
"format": f"bestvideo[height<={quality}]+bestaudio/best" if format_type == "mp4" else "bestaudio/best",
|
| 38 |
"merge_output_format": "mp4",
|
| 39 |
"nocheckcertificate": True,
|
| 40 |
-
"force_ipv4": True, # Kita pakai fitur bawaan ini saja, LEBIH AMAN
|
| 41 |
"quiet": True,
|
| 42 |
"no_warnings": True,
|
|
|
|
| 43 |
}
|
| 44 |
|
| 45 |
if format_type == "mp3":
|
|
|
|
| 1 |
+
# --- SYSTEM PATCH: FORCE IPv4 ONLY (SAFE MODE) ---
|
| 2 |
+
import socket
|
| 3 |
+
|
| 4 |
+
# Simpan fungsi asli
|
| 5 |
+
_original_getaddrinfo = socket.getaddrinfo
|
| 6 |
+
|
| 7 |
+
# Buat fungsi pengganti yang membuang hasil IPv6
|
| 8 |
+
def new_getaddrinfo(*args, **kwargs):
|
| 9 |
+
responses = _original_getaddrinfo(*args, **kwargs)
|
| 10 |
+
# Hanya ambil yang jenisnya AF_INET (IPv4)
|
| 11 |
+
return [res for res in responses if res[0] == socket.AF_INET]
|
| 12 |
+
|
| 13 |
+
# Pasang fungsi pengganti ke sistem
|
| 14 |
+
socket.getaddrinfo = new_getaddrinfo
|
| 15 |
+
# -------------------------------------------------
|
| 16 |
+
|
| 17 |
from flask import Flask, render_template, request, send_file
|
| 18 |
import yt_dlp
|
| 19 |
import os
|
|
|
|
| 53 |
"format": f"bestvideo[height<={quality}]+bestaudio/best" if format_type == "mp4" else "bestaudio/best",
|
| 54 |
"merge_output_format": "mp4",
|
| 55 |
"nocheckcertificate": True,
|
|
|
|
| 56 |
"quiet": True,
|
| 57 |
"no_warnings": True,
|
| 58 |
+
# Kita tidak perlu lagi "force_ipv4" disini karena sudah di-patch di sistem atas
|
| 59 |
}
|
| 60 |
|
| 61 |
if format_type == "mp3":
|