Karel Malý commited on
Commit
ee4df57
1 Parent(s): 5e7fb02

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from pytube import YouTube
3
+ import os
4
+
5
+ # Create a text input box
6
+ url = st.text_input('Enter your youtube video url:')
7
+
8
+ if button := st.button('Submit'):
9
+ yt = YouTube(url)
10
+ video = yt.streams.get_audio_only()
11
+ video_title = yt.title
12
+ downloaded_file = video.download(filename=video_title)
13
+ new_file = f"{video_title}.mp3"
14
+ os.rename(downloaded_file, new_file)
15
+ with open(new_file, 'rb') as f:
16
+ data = f.read()
17
+ st.download_button(label='Download', data=data, file_name=new_file)
18
+ os.remove(new_file)