elfgk commited on
Commit
c90dd55
·
verified ·
1 Parent(s): ba83e79

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -29
app.py CHANGED
@@ -1,29 +1,31 @@
1
- import gradio as gr
2
- from pytubefix import YouTube
3
-
4
- def download_video(link):
5
- try:
6
- yt = YouTube(link)
7
- # İndirilmek istenen video akışını seçme
8
- stream = yt.streams.filter(progressive=True, file_extension='mp4').first()
9
-
10
- if stream:
11
- stream.download() # İndirme işlemi
12
- return f"{yt.title} başarıyla indirildi!"
13
- else:
14
- return "Video akışı bulunamadı. Lütfen farklı bir link deneyin."
15
- except Exception as e:
16
- return f"Hata oluştu: {str(e)}"
17
-
18
- # Gradio arayüzü oluştur
19
- interface = gr.Interface(
20
- fn=download_video,
21
- inputs=gr.Textbox(label="YouTube Video Linki"),
22
- outputs="text",
23
- title="YouTube Video İndirici",
24
- description="YouTube linkini girin ve MP4 formatında indirin.",
25
-
26
- )
27
-
28
- # Arayüzü başlat
29
- interface.launch(share=True)
 
 
 
1
+ import gradio as gr
2
+ import yt_dlp
3
+
4
+ def download_video(link):
5
+ try:
6
+ ydl_opts = {
7
+ 'format': 'best',
8
+ 'outtmpl': '%(title)s.%(ext)s',
9
+ }
10
+
11
+ with yt_dlp.YoutubeDL(ydl_opts) as ydl:
12
+ info_dict = ydl.extract_info(link, download=True)
13
+ title = info_dict.get('title', 'Video')
14
+ return f"{title} başarıyla indirildi!"
15
+ except Exception as e:
16
+ return f"Hata oluştu: {str(e)}"
17
+
18
+ # Gradio arayüzü oluştur
19
+ interface = gr.Interface(
20
+ fn=download_video,
21
+ inputs=gr.Textbox(label="YouTube Video Linki"),
22
+ outputs="text",
23
+ title="YouTube Video İndirici",
24
+ description="YouTube linkini girin ve videoyu MP4 formatında indirin.",
25
+ examples=[
26
+ ["https://www.youtube.com/watch?v=dQw4w9WgXcQ"]
27
+ ]
28
+ )
29
+
30
+ # Arayüzü başlat
31
+ interface.launch(share=True)