Spaces:
Sleeping
Sleeping
Download app.py from FarelDeveloper/aiodownloader: direct link, hf CLI and curl.
- Browser
- Download file 4.9 kB
-
https://huggingface.co/spaces/FarelDeveloper/aiodownloader/resolve/main/app.py
- Command line
-
hf download hf://spaces/FarelDeveloper/aiodownloader/app.py
-
curl -L -o app.py https://huggingface.co/spaces/FarelDeveloper/aiodownloader/resolve/main/app.py
4.9 kB
| 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" | |
| ] | |
| 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")) |