Matias Macias Gomez commited on
Commit
d9ecb6b
·
1 Parent(s): ba99ed5

Added cookies

Browse files
Files changed (1) hide show
  1. streamlit_app.py +16 -0
streamlit_app.py CHANGED
@@ -24,9 +24,17 @@ def _remove_video():
24
 
25
  def download_video(url:str, save_path:str , **kwargs):
26
  video_id =url.split("/")[-1]
 
 
 
 
27
  ydl_opts = {
28
  'outtmpl': f'{save_path}/{video_id}.%(ext)s',
29
  }
 
 
 
 
30
  with yt_dlp.YoutubeDL(ydl_opts) as ydl:
31
  ydl.download(url)
32
 
@@ -44,6 +52,14 @@ def download_video(url:str, save_path:str , **kwargs):
44
 
45
  st.title("Download Any* Video")
46
 
 
 
 
 
 
 
 
 
47
  st.text_input("Video URL", key="url", placeholder="Enter Video URL and Hit Enter", on_change=_remove_video)
48
 
49
 
 
24
 
25
  def download_video(url:str, save_path:str , **kwargs):
26
  video_id =url.split("/")[-1]
27
+
28
+ if len(video_id) < 1:
29
+ video_id = url.split("/")[-2]
30
+
31
  ydl_opts = {
32
  'outtmpl': f'{save_path}/{video_id}.%(ext)s',
33
  }
34
+
35
+ if st.session_state["ig_cookie"]:
36
+ ydl_opts['cookies'] = st.session_state["ig_cookie"]
37
+
38
  with yt_dlp.YoutubeDL(ydl_opts) as ydl:
39
  ydl.download(url)
40
 
 
52
 
53
  st.title("Download Any* Video")
54
 
55
+ with st.sidebar:
56
+ st.subheader("Cookies! :cookie:")
57
+ st.write("For some websites that have a more strict bot control it's necessary to upload a cookie file to download content from them")
58
+ st.file_uploader(label="**Upload Instagram Cookie** :cookie:", type=["txt", "json"],
59
+ accept_multiple_files=False, key="ig_cookie")
60
+ st.file_uploader(label="**Upload TikTok Cookie** :cookie:", type=["txt", "json"],
61
+ accept_multiple_files=False, key="tt_cookie")
62
+
63
  st.text_input("Video URL", key="url", placeholder="Enter Video URL and Hit Enter", on_change=_remove_video)
64
 
65