Spaces:
Paused
Paused
| # app.py | |
| import gradio as gr | |
| import yt_dlp | |
| import os | |
| def download_anime(url, ep_start=1, ep_end=None): | |
| ydl_opts = { | |
| 'format': 'best', | |
| 'outtmpl': '%(title)s - Episode %(episode_num)02d.%(ext)s', | |
| 'quiet': False, | |
| 'no_warnings': False, | |
| } | |
| if ep_end: | |
| ydl_opts['playliststart'] = ep_start | |
| ydl_opts['playlistend'] = ep_end | |
| with yt_dlp.YoutubeDL(ydl_opts) as ydl: | |
| try: | |
| info = ydl.extract_info(url, download=True) | |
| title = info.get('title', 'Unknown') | |
| return f"Downloaded: {title}" | |
| except Exception as e: | |
| return f"Error: {str(e)}" | |
| with gr.Blocks() as demo: | |
| gr.Markdown("# Anime Downloader (yt-dlp)") | |
| url = gr.Textbox(label="Anime Page URL (e.g., animewave episode or series)") | |
| start = gr.Number(label="Start Episode", value=1, precision=0) | |
| end = gr.Number(label="End Episode (optional)", value=None) | |
| btn = gr.Button("Download") | |
| output = gr.Textbox(label="Status") | |
| btn.click(download_anime, inputs=[url, start, end], outputs=output) | |
| demo.launch() |