File size: 4,902 Bytes
1163788
 
b6e17fe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1163788
2da4f4f
1163788
 
 
 
b6e17fe
 
 
1163788
 
 
b6e17fe
 
1163788
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b6e17fe
 
 
1163788
 
 
b6e17fe
 
1163788
 
 
 
 
 
 
 
 
 
 
2da4f4f
1163788
b6e17fe
1163788
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2da4f4f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import gradio as gr
import yt_dlp
import spaces
import random

# DAFTAR PROXY PREMIUM (Diambil dari file premium_http_proxy.txt Anda)
# Kita masukkan beberapa sampel dari list Anda. Anda bisa tambah sendiri ke dalam list ini.
PROXY_LIST = [
    "http://xjxjlhbdkk9n:65fv2nee2xca9wu@65.111.9.194:3129",
    "http://xjxjlhbdkk9n:65fv2nee2xca9wu@216.26.224.50:3129",
    "http://xjxjlhbdkk9n:65fv2nee2xca9wu@209.50.188.241:3129",
    "http://xjxjlhbdkk9n:65fv2nee2xca9wu@209.50.169.134:3129",
    "http://xjxjlhbdkk9n:65fv2nee2xca9wu@216.26.225.30:3129",
    "http://5ukighv82z3p:5m8vi0mep8h79x0@104.207.39.60:3129",
    "http://5ukighv82z3p:5m8vi0mep8h79x0@45.3.40.181:3129",
    "http://5ukighv82z3p:5m8vi0mep8h79x0@104.207.37.134:3129"
]

@spaces.GPU
def get_video_info(url):
    if not url:
        return "Silakan masukkan URL terlebih dahulu.", None, gr.Dropdown(choices=[])

    # Pilih 1 proxy secara acak dari list premium Anda
    selected_proxy = random.choice(PROXY_LIST)

    ydl_opts = {
        'quiet': True,
        'no_warnings': True,
        'proxy': selected_proxy, # πŸ‘ˆ SUNTIKAN PROXY PREMIUM DI SINI
        'socket_timeout': 15,    # Biar ga bengong kelamaan kalau proxynya lagi down
    }

    try:
        with yt_dlp.YoutubeDL(ydl_opts) as ydl:
            info = ydl.extract_info(url, download=False)
            
            title = info.get('title', 'Unknown Title')
            thumbnail = info.get('thumbnail', '')
            uploader = info.get('uploader', 'Unknown')
            duration = info.get('duration_string', 'Unknown')
            
            meta_text = f"### πŸŽ₯ {title}\n**Uploader:** {uploader} | **Durasi:** {duration}"
            
            formats = info.get('formats', [])
            options = []
            for f in formats:
                if f.get('vcodec') != 'none' and (f.get('height') or f.get('format_note')):
                    res = f.get('format_note') or f"{f.get('height')}p"
                    ext = f.get('ext', 'mp4')
                    fid = f.get('format_id')
                    
                    filesize = f.get('filesize')
                    size_str = f"{filesize / (1024*1024):.2f} MB" if filesize else "Unknown Size"
                    
                    label = f"{res} ({ext}) - {size_str}"
                    options.append((label, fid))
            
            options.reverse()
            
            if not options:
                options = [("Default Best Quality", "best")]

            return meta_text, thumbnail, gr.Dropdown(choices=options, interactive=True, value=options[0][1])
            
    except Exception as e:
        return f"❌ Terjadi kesalahan: {str(e)}", None, gr.Dropdown(choices=[])

def generate_download_link(url, format_id):
    if not url or not format_id:
        return "Pilih resolusi dan masukkan URL valid terlebih dahulu."
    
    # Pakai proxy juga saat generate link download akhir
    selected_proxy = random.choice(PROXY_LIST)
        
    ydl_opts = {
        'format': f"{format_id}+bestaudio/best" if format_id != "best" else "best",
        'quiet': True,
        'proxy': selected_proxy # πŸ‘ˆ SUNTIKAN PROXY PREMIUM DI SINI
    }
    
    try:
        with yt_dlp.YoutubeDL(ydl_opts) as ydl:
            info = ydl.extract_info(url, download=False)
            download_url = info.get('url') or info.get('formats')[0].get('url')
            
            return f"### βœ… Link Download Berhasil Dibuat!\n[πŸ‘‰ Klik di Sini Untuk Download / Stream Video]({download_url})"
    except Exception as e:
        return f"❌ Gagal membuat link: {str(e)}"

with gr.Blocks() as demo:
    gr.Markdown("# πŸš€ Farel AIO Downloader")
    gr.Markdown("Download video dari YouTube, TikTok, Facebook, Twitter, secara instan di ZeroGPU (Bypassed).")
    
    with gr.Row():
        url_input = gr.Textbox(label="URL Video", placeholder="Tempel tautan video Anda di sini...", scale=4)
        check_btn = gr.Button("Periksa Video", variant="primary", scale=1)
        
    with gr.Row():
        with gr.Column(scale=2):
            thumb_output = gr.Image(label="Preview Thumbnail", interactive=False)
        with gr.Column(scale=3):
            meta_output = gr.Markdown("Informasi video akan muncul di sini setelah Anda memeriksa URL.")
            format_dropdown = gr.Dropdown(label="Pilih Kualitas / Resolusi", choices=[], interactive=False)
            download_btn = gr.Button("Dapatkan Link Unduhan", variant="stop")
            
    link_output = gr.Markdown()

    check_btn.click(
        fn=get_video_info, 
        inputs=[url_input], 
        outputs=[meta_output, thumb_output, format_dropdown]
    )
    
    download_btn.click(
        fn=generate_download_link,
        inputs=[url_input, format_dropdown],
        outputs=[link_output]
    )

if __name__ == "__main__":
    demo.launch(theme=gr.themes.Soft(primary_hue="blue", neutral_hue="slate"))