Geek7 commited on
Commit
0438968
·
1 Parent(s): 15ba164

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -86
app.py CHANGED
@@ -1,23 +1,6 @@
1
  import streamlit as st
2
- from pytube import YouTube
3
  import streamlit.components.v1 as components
4
 
5
- hide_streamlit_style = """
6
- <style>
7
- #MainMenu {visibility: hidden;}
8
- footer {visibility: hidden;}
9
- .stApp{
10
- background-image: linear-gradient(115deg,#FFAF00,#FFC500,#FFD600,#FCED00,#F9F380,#F6F7CD);
11
- animation: rotate 7s linear infinite;
12
- }
13
- @keyframes rotate {
14
- 100%{
15
- filter: hue-rotate(-360deg)
16
- }
17
- }
18
- </style>
19
- """
20
-
21
  # JavaScript code for confetti animation
22
  confetti_animation_script = """
23
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/confetti.browser.min.js"></script>
@@ -34,76 +17,11 @@ confetti_animation_script = """
34
  function randomInRange(min, max) {
35
  return Math.random() * (max - min) + min;
36
  }
37
-
38
- function startButtonClicked() {
39
- triggerConfetti();
40
- }
41
  </script>
42
  """
43
 
44
- components.html(confetti_animation_script)
45
-
46
- st.markdown(hide_streamlit_style, unsafe_allow_html=True)
47
-
48
- class YouTubeDownloader:
49
- @staticmethod
50
- def run():
51
- st.header("")
52
- url = st.text_input("Enter Here")
53
- start_button = st.button("Start", on_click=YouTubeDownloader.start_button_clicked)
54
-
55
- if start_button:
56
- if url:
57
- YouTubeDownloader.validate_url(url)
58
- with st.expander("preview video"):
59
- st.video(url)
60
- YouTubeDownloader.cleanup()
61
- file_ = YouTubeDownloader.download_video(url)
62
- st.video(file_)
63
- YouTubeDownloader.helper_message()
64
-
65
- st.markdown("")
66
-
67
- @staticmethod
68
- def download_video(url):
69
- with st.spinner("Downloading..."):
70
- local_file = (
71
- YouTube(url)
72
- .streams.filter(progressive=True, file_extension="mp4")
73
- .first()
74
- .download()
75
- )
76
- st.success("Downloaded")
77
- return local_file
78
-
79
- @staticmethod
80
- def validate_url(url):
81
- import validators
82
-
83
- if not validators.url(url):
84
- st.error("Hi there 👋 URL seems invalid 👽")
85
- st.stop()
86
-
87
- @classmethod
88
- def cleanup(cls):
89
- import pathlib
90
- import glob
91
-
92
- junks = glob.glob("*.mp4")
93
- for junk in junks:
94
- pathlib.Path(junk).unlink()
95
-
96
- @classmethod
97
- def helper_message(cls):
98
- st.write(
99
- "> To save to the local computer, "
100
- "click the vertical ... icon (aka hamburger button) in the bottom-right corner (in the video above) and click download."
101
- )
102
-
103
- @classmethod
104
- def start_button_clicked(cls):
105
- YouTubeDownloader.trigger_confetti()
106
-
107
 
108
- if __name__ == "__main__":
109
- YouTubeDownloader.run()
 
 
1
  import streamlit as st
 
2
  import streamlit.components.v1 as components
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  # JavaScript code for confetti animation
5
  confetti_animation_script = """
6
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/confetti.browser.min.js"></script>
 
17
  function randomInRange(min, max) {
18
  return Math.random() * (max - min) + min;
19
  }
 
 
 
 
20
  </script>
21
  """
22
 
23
+ components.html(confetti_animation_script, height=600)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
+ if st.button("Click for Confetti"):
26
+ st.write("Confetti time!")
27
+ st.write("You can customize this behavior further as needed.")