Next commited on
Commit
e7e2b0a
·
verified ·
1 Parent(s): 75f8d63

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import webui
2
+ import yt_dlp
3
+
4
+ class YoutubeDownloader(webui.Block):
5
+ def __init__(self):
6
+ super().__init__()
7
+ self.url_input = webui.Textbox(label="YouTube URL")
8
+ self.download_button = webui.Button(label="Download")
9
+ self.result_text = webui.Textarea(rows=10)
10
+
11
+ def on_button_click(self, event):
12
+ url = self.url_input.get()
13
+ ydl = yt_dlp.YoutubeDLP()
14
+ try:
15
+ results = ydl.extract_info(url, download=True)
16
+ self.result_text.set("Download information:\n" + str(results))
17
+ except Exception as e:
18
+ self.result_text.set("Error: " + str(e))
19
+
20
+
21
+ if __name__ == "__main__":
22
+ webui.launch(YoutubeDownloader(), port=8000)