Spaces:
Sleeping
Sleeping
Download app.py from MACSWAI/vdown-final: direct link, hf CLI and curl.
- Browser
- Download file 2.21 kB
-
https://huggingface.co/spaces/MACSWAI/vdown-final/resolve/main/app.py
- Command line
-
hf download hf://spaces/MACSWAI/vdown-final/app.py
-
curl -L -o app.py https://huggingface.co/spaces/MACSWAI/vdown-final/resolve/main/app.py
2.21 kB
| import streamlit as st | |
| import yt_dlp | |
| import os | |
| import time | |
| import socket | |
| # --- KONFIGURASI HALAMAN --- | |
| st.set_page_config(page_title="VDown", page_icon="⚡", layout="centered") | |
| # --- CSS --- | |
| st.markdown(""" | |
| <style> | |
| .stApp { background: linear-gradient(to right, #ece9e6, #ffffff); color: black; } | |
| .main-card { background: white; padding: 20px; border-radius: 15px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); } | |
| </style> | |
| """, unsafe_allow_html=True) | |
| st.title("⚡ VDown Simple") | |
| # --- DEBUGGING JARINGAN (Untuk Cek Status) --- | |
| try: | |
| # Cek apakah server punya internet | |
| socket.gethostbyname("google.com") | |
| st.success("✅ Status Server: Online (Terhubung ke Internet)") | |
| except: | |
| st.error("❌ Status Server: OFFLINE (Internet Diblokir Hugging Face)") | |
| url = st.text_input("Link Video:", placeholder="https://...") | |
| if st.button("Proses Video"): | |
| if not url: | |
| st.warning("Isi link dulu.") | |
| else: | |
| status = st.empty() | |
| status.info("Sedang memproses...") | |
| try: | |
| # Opsi Anti-Blokir | |
| ydl_opts = { | |
| 'format': 'best', | |
| 'quiet': True, | |
| 'no_warnings': True, | |
| 'force_ipv4': True, # Paksa IPv4 | |
| 'nocheckcertificate': True,# Abaikan SSL Error | |
| 'socket_timeout': 10, # Timeout pendek | |
| # Header samaran | |
| 'http_headers': { | |
| 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36', | |
| } | |
| } | |
| with yt_dlp.YoutubeDL(ydl_opts) as ydl: | |
| info = ydl.extract_info(url, download=False) | |
| # Tampilkan Hasil | |
| status.empty() | |
| st.image(info.get('thumbnail')) | |
| st.subheader(info.get('title')) | |
| st.link_button("⬇️ Download Sekarang", info.get('url')) | |
| except Exception as e: | |
| status.empty() | |
| st.error(f"Gagal: {e}") | |
| st.write("Tips: Jika Status Server OFFLINE, berarti akun ini sudah diblokir jaringannya. Silakan coba platform lain.") |