File size: 1,104 Bytes
ff47e01
e2d0f6c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

# 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()