jitendra.kasaudhan
commited on
Commit
·
4aa1f8b
1
Parent(s):
d03c727
Add progress bar
Browse files
app.py
CHANGED
@@ -10,10 +10,20 @@ def get_binary_file_downloader_html(bin_file, file_label='File'):
|
|
10 |
href = f'<a href="data:application/octet-stream;base64,{bin_str}" download="{os.path.basename(bin_file)}">Download {file_label}</a>'
|
11 |
return href
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
def main():
|
14 |
# Set the title and background color
|
15 |
st.title("YouTube To MP3 Converter 🎥")
|
16 |
st.markdown('<style>h1{color: orange; text-align: center;}</style>', unsafe_allow_html=True)
|
|
|
17 |
# st.subheader('Built with the Llama 2 🦙, Haystack, Streamlit and ❤️')
|
18 |
# st.markdown('<style>h3{color: pink; text-align: center;}</style>', unsafe_allow_html=True)
|
19 |
|
@@ -27,7 +37,10 @@ def main():
|
|
27 |
|
28 |
# Submit button
|
29 |
if st.button("Submit") and youtube_url:
|
30 |
-
|
|
|
|
|
|
|
31 |
# extract only audio
|
32 |
video = yt.streams.filter(only_audio=True).first()
|
33 |
|
@@ -47,6 +60,7 @@ def main():
|
|
47 |
# st.markdown(get_binary_file_downloader_html('photo.jpg', 'Picture'), unsafe_allow_html=True)
|
48 |
# st.markdown(get_binary_file_downloader_html('data.csv', 'My Data'), unsafe_allow_html=True)
|
49 |
st.markdown(get_binary_file_downloader_html(new_file, 'Audio'), unsafe_allow_html=True)
|
|
|
50 |
st.success('Successfull!!')
|
51 |
|
52 |
if __name__ == "__main__":
|
|
|
10 |
href = f'<a href="data:application/octet-stream;base64,{bin_str}" download="{os.path.basename(bin_file)}">Download {file_label}</a>'
|
11 |
return href
|
12 |
|
13 |
+
def on_progress(stream, chunk, bytes_remaining):
|
14 |
+
print(' progress:', bytes_remaining, " ", end='\r', flush=True)
|
15 |
+
|
16 |
+
def on_complete(stream, filename):
|
17 |
+
print('--- Completed ---')
|
18 |
+
print('stream:', stream)
|
19 |
+
print('filename:', filename)
|
20 |
+
|
21 |
+
|
22 |
def main():
|
23 |
# Set the title and background color
|
24 |
st.title("YouTube To MP3 Converter 🎥")
|
25 |
st.markdown('<style>h1{color: orange; text-align: center;}</style>', unsafe_allow_html=True)
|
26 |
+
|
27 |
# st.subheader('Built with the Llama 2 🦙, Haystack, Streamlit and ❤️')
|
28 |
# st.markdown('<style>h3{color: pink; text-align: center;}</style>', unsafe_allow_html=True)
|
29 |
|
|
|
37 |
|
38 |
# Submit button
|
39 |
if st.button("Submit") and youtube_url:
|
40 |
+
progress_bar = st.progress(0, text='Processing...')
|
41 |
+
yt = YouTube(youtube_url)
|
42 |
+
yt.register_on_progress_callback(on_progress)
|
43 |
+
yt.register_on_complete_callback(on_complete)
|
44 |
# extract only audio
|
45 |
video = yt.streams.filter(only_audio=True).first()
|
46 |
|
|
|
60 |
# st.markdown(get_binary_file_downloader_html('photo.jpg', 'Picture'), unsafe_allow_html=True)
|
61 |
# st.markdown(get_binary_file_downloader_html('data.csv', 'My Data'), unsafe_allow_html=True)
|
62 |
st.markdown(get_binary_file_downloader_html(new_file, 'Audio'), unsafe_allow_html=True)
|
63 |
+
progress_bar.progress(100, text='DONE')
|
64 |
st.success('Successfull!!')
|
65 |
|
66 |
if __name__ == "__main__":
|