Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -142,164 +142,12 @@
|
|
142 |
|
143 |
|
144 |
|
145 |
-
# import streamlit as st
|
146 |
-
# import yt_dlp
|
147 |
-
# import os
|
148 |
-
# from pathlib import Path
|
149 |
-
# import random
|
150 |
-
# import time
|
151 |
-
|
152 |
-
# # νμ΄μ§ μ€μ
|
153 |
-
# st.set_page_config(page_title="Simple YouTube Downloader", page_icon="πΊ")
|
154 |
-
# st.title("Simple YouTube Downloader πΊ")
|
155 |
-
|
156 |
-
# # μ€νμΌ μ€μ
|
157 |
-
# st.markdown("""
|
158 |
-
# <style>
|
159 |
-
# .stButton > button {
|
160 |
-
# width: 100%;
|
161 |
-
# height: 60px;
|
162 |
-
# }
|
163 |
-
# </style>
|
164 |
-
# """, unsafe_allow_html=True)
|
165 |
-
|
166 |
-
# # λ€μ΄λ‘λ ν΄λ μμ±
|
167 |
-
# output_dir = Path("downloads")
|
168 |
-
# output_dir.mkdir(exist_ok=True)
|
169 |
-
|
170 |
-
# def download_video(url, progress_bar, status_text):
|
171 |
-
# try:
|
172 |
-
# user_agents = [
|
173 |
-
# 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
174 |
-
# 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2.1 Safari/605.1.15',
|
175 |
-
# 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0'
|
176 |
-
# ]
|
177 |
-
|
178 |
-
# ydl_opts = {
|
179 |
-
# 'format': 'best',
|
180 |
-
# 'outtmpl': str(output_dir / '%(title)s.%(ext)s'),
|
181 |
-
# 'quiet': True,
|
182 |
-
# 'no_warnings': True,
|
183 |
-
# 'cookiefile': 'youtube.com_cookies.txt',
|
184 |
-
# 'user_agent': random.choice(user_agents),
|
185 |
-
# 'referer': 'https://www.youtube.com/',
|
186 |
-
# 'http_chunk_size': random.randint(10000000, 15000000),
|
187 |
-
# 'retries': 5, # μ¬μλ νμλ₯Ό 5λ‘ λλ¦Ό
|
188 |
-
# 'sleep_interval': 3,
|
189 |
-
# 'max_sleep_interval': 8,
|
190 |
-
# 'headers': {
|
191 |
-
# 'Accept-Language': 'en-US,en;q=0.9',
|
192 |
-
# 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
193 |
-
# },
|
194 |
-
# }
|
195 |
-
|
196 |
-
# def progress_hook(d):
|
197 |
-
# if d['status'] == 'downloading':
|
198 |
-
# try:
|
199 |
-
# progress = d['downloaded_bytes'] / d['total_bytes']
|
200 |
-
# progress_bar.progress(progress)
|
201 |
-
# status_text.text(f"λ€μ΄λ‘λ μ€: {progress:.1%}")
|
202 |
-
# except:
|
203 |
-
# status_text.text("λ€μ΄λ‘λ μ€...")
|
204 |
-
# elif d['status'] == 'finished':
|
205 |
-
# progress_bar.progress(1.0)
|
206 |
-
# status_text.text("μ²λ¦¬ μλ£!")
|
207 |
-
|
208 |
-
# ydl_opts['progress_hooks'] = [progress_hook]
|
209 |
-
|
210 |
-
# for attempt in range(5): # μ¬μλ νμλ₯Ό 5λ‘ μ€μ
|
211 |
-
# try:
|
212 |
-
# with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
213 |
-
# info = ydl.extract_info(url, download=True)
|
214 |
-
# filename = ydl.prepare_filename(info)
|
215 |
-
# return filename
|
216 |
-
# except yt_dlp.utils.ExtractorError as e:
|
217 |
-
# if "Sign in to confirm you're not a bot" in str(e):
|
218 |
-
# status_text.text(f"μ¬μλ μ€... ({attempt + 1}/5)")
|
219 |
-
# time.sleep(random.uniform(3, 5))
|
220 |
-
# continue
|
221 |
-
# status_text.text(f"μ€λ₯ λ°μ: {str(e)}")
|
222 |
-
# st.error(f"λ€μ΄λ‘λ μ€ν¨: {str(e)}") # μ€ν¨ λ©μμ§ νμ
|
223 |
-
# st.info("λ¬Έμ κ° μ§μλ κ²½μ° URLμ΄ μ¬λ°λ₯Έμ§ νμΈνκ³ λ€μ μλνμΈμ.") # μΆκ° λ©λͺ¨
|
224 |
-
# return None
|
225 |
-
# except Exception as e:
|
226 |
-
# if attempt < 4:
|
227 |
-
# status_text.text(f"μ¬μλ μ€... ({attempt + 1}/5)")
|
228 |
-
# time.sleep(2)
|
229 |
-
# continue
|
230 |
-
# status_text.text(f"μ€λ₯ λ°μ: {str(e)}")
|
231 |
-
# st.error(f"λ€μ΄λ‘λ μ€ν¨: {str(e)}") # μ€ν¨ λ©μμ§ νμ
|
232 |
-
# st.info("λ¬Έμ κ° μ§μλ κ²½μ° URLμ΄ μ¬λ°λ₯Έμ§ νμΈνκ³ λ€μ μλνμΈμ.") # μΆκ° λ©λͺ¨
|
233 |
-
# return None
|
234 |
-
|
235 |
-
# except Exception as e:
|
236 |
-
# st.error(f"μ€λ₯ λ°μ: {str(e)}")
|
237 |
-
# return None
|
238 |
-
|
239 |
-
# # μΏ ν€ νμΌ μ²΄ν¬
|
240 |
-
# if not os.path.exists('youtube.com_cookies.txt'):
|
241 |
-
# st.warning("β οΈ 'youtube.com_cookies.txt' νμΌμ΄ νμν©λλ€. YouTubeμ λ‘κ·ΈμΈλ μΏ ν€ νμΌμ μ
λ‘λν΄μ£ΌμΈμ.")
|
242 |
-
# uploaded_file = st.file_uploader("μΏ ν€ νμΌ μ
λ‘λ", type=['txt'])
|
243 |
-
# if uploaded_file is not None:
|
244 |
-
# with open('youtube.com_cookies.txt', 'wb') as f:
|
245 |
-
# f.write(uploaded_file.getvalue())
|
246 |
-
# st.success("β
μΏ ν€ νμΌμ΄ μ
λ‘λλμμ΅λλ€!")
|
247 |
-
# st.rerun()
|
248 |
-
|
249 |
-
# # λ©μΈ UI
|
250 |
-
# if 'video_url' not in st.session_state:
|
251 |
-
# st.session_state.video_url = ""
|
252 |
-
|
253 |
-
# video_url = st.text_input("YouTube URL μ
λ ₯:",
|
254 |
-
# value=st.session_state.video_url,
|
255 |
-
# placeholder="https://www.youtube.com/watch?v=...")
|
256 |
-
|
257 |
-
# # λ²νΌμ κ°μ μ€μ λ°°μΉ
|
258 |
-
# col1, col2 = st.columns(2)
|
259 |
-
|
260 |
-
# with col1:
|
261 |
-
# download_button = st.button("λ€μ΄λ‘λ", type="primary", key="download_btn", use_container_width=True)
|
262 |
-
|
263 |
-
# with col2:
|
264 |
-
# reset_button = st.button("μ΄κΈ°ν", key="reset_btn", use_container_width=True)
|
265 |
-
|
266 |
-
# # λ€μ΄λ‘λ λ‘μ§
|
267 |
-
# if download_button:
|
268 |
-
# if video_url:
|
269 |
-
# progress_bar = st.progress(0)
|
270 |
-
# status_text = st.empty()
|
271 |
-
|
272 |
-
# downloaded_file = download_video(video_url, progress_bar, status_text)
|
273 |
-
|
274 |
-
# if downloaded_file and os.path.exists(downloaded_file):
|
275 |
-
# with open(downloaded_file, 'rb') as file:
|
276 |
-
# st.download_button(
|
277 |
-
# label="β¬οΈ νμΌ λ€μ΄λ‘λ",
|
278 |
-
# data=file,
|
279 |
-
# file_name=os.path.basename(downloaded_file),
|
280 |
-
# mime="video/mp4",
|
281 |
-
# use_container_width=True
|
282 |
-
# )
|
283 |
-
# else:
|
284 |
-
# st.warning("β οΈ YouTube URLμ μ
λ ₯ν΄μ£ΌμΈμ.")
|
285 |
-
|
286 |
-
# # μ΄κΈ°ν λ‘μ§
|
287 |
-
# if reset_button:
|
288 |
-
# st.session_state.video_url = ""
|
289 |
-
# st.rerun()
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
import streamlit as st
|
294 |
import yt_dlp
|
295 |
import os
|
296 |
from pathlib import Path
|
297 |
import random
|
298 |
import time
|
299 |
-
import logging
|
300 |
-
|
301 |
-
# λ‘κΉ
μ€μ
|
302 |
-
logging.basicConfig(level=logging.ERROR, filename='error.log')
|
303 |
|
304 |
# νμ΄μ§ μ€μ
|
305 |
st.set_page_config(page_title="Simple YouTube Downloader", page_icon="πΊ")
|
@@ -335,10 +183,10 @@ def download_video(url, progress_bar, status_text):
|
|
335 |
'cookiefile': 'youtube.com_cookies.txt',
|
336 |
'user_agent': random.choice(user_agents),
|
337 |
'referer': 'https://www.youtube.com/',
|
338 |
-
'http_chunk_size': random.randint(
|
339 |
-
'retries': 5, # μ¬μλ
|
340 |
'sleep_interval': 3,
|
341 |
-
'max_sleep_interval':
|
342 |
'headers': {
|
343 |
'Accept-Language': 'en-US,en;q=0.9',
|
344 |
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
@@ -351,8 +199,7 @@ def download_video(url, progress_bar, status_text):
|
|
351 |
progress = d['downloaded_bytes'] / d['total_bytes']
|
352 |
progress_bar.progress(progress)
|
353 |
status_text.text(f"λ€μ΄λ‘λ μ€: {progress:.1%}")
|
354 |
-
except
|
355 |
-
logging.error(f"Progress Hook Error: {e}")
|
356 |
status_text.text("λ€μ΄λ‘λ μ€...")
|
357 |
elif d['status'] == 'finished':
|
358 |
progress_bar.progress(1.0)
|
@@ -371,21 +218,22 @@ def download_video(url, progress_bar, status_text):
|
|
371 |
status_text.text(f"μ¬μλ μ€... ({attempt + 1}/5)")
|
372 |
time.sleep(random.uniform(3, 5))
|
373 |
continue
|
374 |
-
|
375 |
-
st.
|
|
|
376 |
return None
|
377 |
except Exception as e:
|
378 |
-
logging.error(f"Download Error: {str(e)}")
|
379 |
if attempt < 4:
|
380 |
status_text.text(f"μ¬μλ μ€... ({attempt + 1}/5)")
|
381 |
time.sleep(2)
|
382 |
continue
|
383 |
-
|
|
|
|
|
384 |
return None
|
385 |
|
386 |
except Exception as e:
|
387 |
-
|
388 |
-
st.info("λ¬Έμ κ° μ§μλ κ²½μ° λ€λ₯Έ URLμ μλν΄μ£ΌμΈμ.")
|
389 |
return None
|
390 |
|
391 |
# μΏ ν€ νμΌ μ²΄ν¬
|
@@ -438,5 +286,157 @@ if download_button:
|
|
438 |
# μ΄κΈ°ν λ‘μ§
|
439 |
if reset_button:
|
440 |
st.session_state.video_url = ""
|
441 |
-
st.rerun()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
442 |
|
|
|
142 |
|
143 |
|
144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
import streamlit as st
|
146 |
import yt_dlp
|
147 |
import os
|
148 |
from pathlib import Path
|
149 |
import random
|
150 |
import time
|
|
|
|
|
|
|
|
|
151 |
|
152 |
# νμ΄μ§ μ€μ
|
153 |
st.set_page_config(page_title="Simple YouTube Downloader", page_icon="πΊ")
|
|
|
183 |
'cookiefile': 'youtube.com_cookies.txt',
|
184 |
'user_agent': random.choice(user_agents),
|
185 |
'referer': 'https://www.youtube.com/',
|
186 |
+
'http_chunk_size': random.randint(10000000, 15000000),
|
187 |
+
'retries': 5, # μ¬μλ νμλ₯Ό 5λ‘ λλ¦Ό
|
188 |
'sleep_interval': 3,
|
189 |
+
'max_sleep_interval': 8,
|
190 |
'headers': {
|
191 |
'Accept-Language': 'en-US,en;q=0.9',
|
192 |
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
|
|
199 |
progress = d['downloaded_bytes'] / d['total_bytes']
|
200 |
progress_bar.progress(progress)
|
201 |
status_text.text(f"λ€μ΄λ‘λ μ€: {progress:.1%}")
|
202 |
+
except:
|
|
|
203 |
status_text.text("λ€μ΄λ‘λ μ€...")
|
204 |
elif d['status'] == 'finished':
|
205 |
progress_bar.progress(1.0)
|
|
|
218 |
status_text.text(f"μ¬μλ μ€... ({attempt + 1}/5)")
|
219 |
time.sleep(random.uniform(3, 5))
|
220 |
continue
|
221 |
+
status_text.text(f"μ€λ₯ λ°μ: {str(e)}")
|
222 |
+
st.error(f"λ€μ΄λ‘λ μ€ν¨: {str(e)}") # μ€ν¨ λ©μμ§ νμ
|
223 |
+
st.info("λ¬Έμ κ° μ§μλ κ²½μ° URLμ΄ μ¬λ°λ₯Έμ§ νμΈνκ³ λ€μ μλνμΈμ.") # μΆκ° λ©λͺ¨
|
224 |
return None
|
225 |
except Exception as e:
|
|
|
226 |
if attempt < 4:
|
227 |
status_text.text(f"μ¬μλ μ€... ({attempt + 1}/5)")
|
228 |
time.sleep(2)
|
229 |
continue
|
230 |
+
status_text.text(f"μ€λ₯ λ°μ: {str(e)}")
|
231 |
+
st.error(f"λ€μ΄λ‘λ μ€ν¨: {str(e)}") # μ€ν¨ λ©μμ§ νμ
|
232 |
+
st.info("λ¬Έμ κ° μ§μλ κ²½μ° URLμ΄ μ¬λ°λ₯Έμ§ νμΈνκ³ λ€μ μλνμΈμ.") # μΆκ° λ©λͺ¨
|
233 |
return None
|
234 |
|
235 |
except Exception as e:
|
236 |
+
st.error(f"μ€λ₯ λ°μ: {str(e)}")
|
|
|
237 |
return None
|
238 |
|
239 |
# μΏ ν€ νμΌ μ²΄ν¬
|
|
|
286 |
# μ΄κΈ°ν λ‘μ§
|
287 |
if reset_button:
|
288 |
st.session_state.video_url = ""
|
289 |
+
st.rerun()
|
290 |
+
|
291 |
+
|
292 |
+
|
293 |
+
# import streamlit as st
|
294 |
+
# import yt_dlp
|
295 |
+
# import os
|
296 |
+
# from pathlib import Path
|
297 |
+
# import random
|
298 |
+
# import time
|
299 |
+
# import logging
|
300 |
+
|
301 |
+
# # λ‘κΉ
μ€μ
|
302 |
+
# logging.basicConfig(level=logging.ERROR, filename='error.log')
|
303 |
+
|
304 |
+
# # νμ΄μ§ μ€μ
|
305 |
+
# st.set_page_config(page_title="Simple YouTube Downloader", page_icon="πΊ")
|
306 |
+
# st.title("Simple YouTube Downloader πΊ")
|
307 |
+
|
308 |
+
# # μ€νμΌ μ€μ
|
309 |
+
# st.markdown("""
|
310 |
+
# <style>
|
311 |
+
# .stButton > button {
|
312 |
+
# width: 100%;
|
313 |
+
# height: 60px;
|
314 |
+
# }
|
315 |
+
# </style>
|
316 |
+
# """, unsafe_allow_html=True)
|
317 |
+
|
318 |
+
# # λ€μ΄λ‘λ ν΄λ μμ±
|
319 |
+
# output_dir = Path("downloads")
|
320 |
+
# output_dir.mkdir(exist_ok=True)
|
321 |
+
|
322 |
+
# def download_video(url, progress_bar, status_text):
|
323 |
+
# try:
|
324 |
+
# user_agents = [
|
325 |
+
# 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
326 |
+
# 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2.1 Safari/605.1.15',
|
327 |
+
# 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0'
|
328 |
+
# ]
|
329 |
+
|
330 |
+
# ydl_opts = {
|
331 |
+
# 'format': 'best',
|
332 |
+
# 'outtmpl': str(output_dir / '%(title)s.%(ext)s'),
|
333 |
+
# 'quiet': True,
|
334 |
+
# 'no_warnings': True,
|
335 |
+
# 'cookiefile': 'youtube.com_cookies.txt',
|
336 |
+
# 'user_agent': random.choice(user_agents),
|
337 |
+
# 'referer': 'https://www.youtube.com/',
|
338 |
+
# 'http_chunk_size': random.randint(100000000, 150000000),
|
339 |
+
# 'retries': 5, # μ¬μλ νμ
|
340 |
+
# 'sleep_interval': 3,
|
341 |
+
# 'max_sleep_interval': 10,
|
342 |
+
# 'headers': {
|
343 |
+
# 'Accept-Language': 'en-US,en;q=0.9',
|
344 |
+
# 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
345 |
+
# },
|
346 |
+
# }
|
347 |
+
|
348 |
+
# def progress_hook(d):
|
349 |
+
# if d['status'] == 'downloading':
|
350 |
+
# try:
|
351 |
+
# progress = d['downloaded_bytes'] / d['total_bytes']
|
352 |
+
# progress_bar.progress(progress)
|
353 |
+
# status_text.text(f"λ€μ΄λ‘λ μ€: {progress:.1%}")
|
354 |
+
# except Exception as e:
|
355 |
+
# logging.error(f"Progress Hook Error: {e}")
|
356 |
+
# status_text.text("λ€μ΄λ‘λ μ€...")
|
357 |
+
# elif d['status'] == 'finished':
|
358 |
+
# progress_bar.progress(1.0)
|
359 |
+
# status_text.text("μ²λ¦¬ μλ£!")
|
360 |
+
|
361 |
+
# ydl_opts['progress_hooks'] = [progress_hook]
|
362 |
+
|
363 |
+
# for attempt in range(5): # μ¬μλ νμλ₯Ό 5λ‘ μ€μ
|
364 |
+
# try:
|
365 |
+
# with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
366 |
+
# info = ydl.extract_info(url, download=True)
|
367 |
+
# filename = ydl.prepare_filename(info)
|
368 |
+
# return filename
|
369 |
+
# except yt_dlp.utils.ExtractorError as e:
|
370 |
+
# if "Sign in to confirm you're not a bot" in str(e):
|
371 |
+
# status_text.text(f"μ¬μλ μ€... ({attempt + 1}/5)")
|
372 |
+
# time.sleep(random.uniform(3, 5))
|
373 |
+
# continue
|
374 |
+
# logging.error(f"Extractor Error: {str(e)}")
|
375 |
+
# st.info("λ¬Έμ κ° μ§μλ κ²½μ° URLμ΄ μ¬λ°λ₯Έμ§ νμΈνκ³ λ€μ μλνμΈμ.")
|
376 |
+
# return None
|
377 |
+
# except Exception as e:
|
378 |
+
# logging.error(f"Download Error: {str(e)}")
|
379 |
+
# if attempt < 4:
|
380 |
+
# status_text.text(f"μ¬μλ μ€... ({attempt + 1}/5)")
|
381 |
+
# time.sleep(2)
|
382 |
+
# continue
|
383 |
+
# st.info("λ¬Έμ κ° μ§μλ κ²½μ° λ€λ₯Έ URLμ μλν΄μ£ΌμΈμ.")
|
384 |
+
# return None
|
385 |
+
|
386 |
+
# except Exception as e:
|
387 |
+
# logging.error(f"General Error: {str(e)}")
|
388 |
+
# st.info("λ¬Έμ κ° μ§μλ κ²½μ° λ€λ₯Έ URLμ μλν΄μ£ΌμΈμ.")
|
389 |
+
# return None
|
390 |
+
|
391 |
+
# # μΏ ν€ νμΌ μ²΄ν¬
|
392 |
+
# if not os.path.exists('youtube.com_cookies.txt'):
|
393 |
+
# st.warning("β οΈ 'youtube.com_cookies.txt' νμΌμ΄ νμν©λλ€. YouTubeμ λ‘κ·ΈμΈλ μΏ ν€ νμΌμ μ
λ‘λν΄μ£ΌμΈμ.")
|
394 |
+
# uploaded_file = st.file_uploader("μΏ ν€ νμΌ μ
λ‘λ", type=['txt'])
|
395 |
+
# if uploaded_file is not None:
|
396 |
+
# with open('youtube.com_cookies.txt', 'wb') as f:
|
397 |
+
# f.write(uploaded_file.getvalue())
|
398 |
+
# st.success("β
μΏ ν€ νμΌμ΄ μ
λ‘λλμμ΅λλ€!")
|
399 |
+
# st.rerun()
|
400 |
+
|
401 |
+
# # λ©μΈ UI
|
402 |
+
# if 'video_url' not in st.session_state:
|
403 |
+
# st.session_state.video_url = ""
|
404 |
+
|
405 |
+
# video_url = st.text_input("YouTube URL μ
λ ₯:",
|
406 |
+
# value=st.session_state.video_url,
|
407 |
+
# placeholder="https://www.youtube.com/watch?v=...")
|
408 |
+
|
409 |
+
# # λ²νΌμ κ°μ μ€μ λ°°μΉ
|
410 |
+
# col1, col2 = st.columns(2)
|
411 |
+
|
412 |
+
# with col1:
|
413 |
+
# download_button = st.button("λ€μ΄λ‘λ", type="primary", key="download_btn", use_container_width=True)
|
414 |
+
|
415 |
+
# with col2:
|
416 |
+
# reset_button = st.button("μ΄κΈ°ν", key="reset_btn", use_container_width=True)
|
417 |
+
|
418 |
+
# # λ€μ΄λ‘λ λ‘μ§
|
419 |
+
# if download_button:
|
420 |
+
# if video_url:
|
421 |
+
# progress_bar = st.progress(0)
|
422 |
+
# status_text = st.empty()
|
423 |
+
|
424 |
+
# downloaded_file = download_video(video_url, progress_bar, status_text)
|
425 |
+
|
426 |
+
# if downloaded_file and os.path.exists(downloaded_file):
|
427 |
+
# with open(downloaded_file, 'rb') as file:
|
428 |
+
# st.download_button(
|
429 |
+
# label="β¬οΈ νμΌ λ€μ΄λ‘λ",
|
430 |
+
# data=file,
|
431 |
+
# file_name=os.path.basename(downloaded_file),
|
432 |
+
# mime="video/mp4",
|
433 |
+
# use_container_width=True
|
434 |
+
# )
|
435 |
+
# else:
|
436 |
+
# st.warning("β οΈ YouTube URLμ μ
λ ₯ν΄μ£ΌμΈμ.")
|
437 |
+
|
438 |
+
# # μ΄κΈ°ν λ‘μ§
|
439 |
+
# if reset_button:
|
440 |
+
# st.session_state.video_url = ""
|
441 |
+
# st.rerun() # st.experimental_rerun()μ st.rerun()μΌλ‘ λ³κ²½νμ΅λλ€.
|
442 |
|