Spaces:
Build error
Build error
Matias Macias Gomez commited on
Commit Β·
9d331e0
1
Parent(s): b020547
Added project files
Browse files- .idea/.gitignore +3 -0
- README.md +27 -1
- requirements.txt +2 -0
- streamlit_app.py +45 -0
.idea/.gitignore
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Default ignored files
|
| 2 |
+
/shelf/
|
| 3 |
+
/workspace.xml
|
README.md
CHANGED
|
@@ -1 +1,27 @@
|
|
| 1 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# π Awesome Video Downloader Tool π₯
|
| 2 |
+
|
| 3 |
+
## Introduction
|
| 4 |
+
Welcome to our amazing video downloader tool! π This Streamlit app empowers you to effortlessly download your favorite videos from various platforms. No more hassle β just grab your popcorn and enjoy the show! πΏ
|
| 5 |
+
|
| 6 |
+
## Features π οΈ
|
| 7 |
+
- **Fast and Easy**: Download videos with lightning speed through our user-friendly interface.
|
| 8 |
+
- **Multi-Platform Support**: Works seamlessly on YouTube, Vimeo, and many more!
|
| 9 |
+
- **High Quality**: Enjoy your videos in the best quality available.
|
| 10 |
+
- **No Ads**: Say goodbye to annoying ads β a clean and uninterrupted experience.
|
| 11 |
+
- **Cross-Platform**: Accessible through any device with a browser.
|
| 12 |
+
|
| 13 |
+
## How to Use π
|
| 14 |
+
1. Clone this repository to your local machine.
|
| 15 |
+
2. Install the required packages:
|
| 16 |
+
```bash
|
| 17 |
+
pip install -r requirements.txt
|
| 18 |
+
```
|
| 19 |
+
|
| 20 |
+
3. Run the Streamlit app:
|
| 21 |
+
```bash
|
| 22 |
+
streamlit run streamlit_app.py
|
| 23 |
+
```
|
| 24 |
+
|
| 25 |
+
4. Open the provided link in your browser.
|
| 26 |
+
5. Paste the video URL.
|
| 27 |
+
6. Hit the download button! π
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit==1.27.2
|
| 2 |
+
yt-dlp==2023.10.13
|
streamlit_app.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import yt_dlp
|
| 3 |
+
import string
|
| 4 |
+
import streamlit as st
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
# Callbacks
|
| 8 |
+
if "videos" not in st.session_state:
|
| 9 |
+
st.session_state["videos"] = ""
|
| 10 |
+
|
| 11 |
+
if "downloaded" not in st.session_state:
|
| 12 |
+
st.session_state["downloaded"] = []
|
| 13 |
+
|
| 14 |
+
def download_video(url:str, save_path:str , download:bool, **kwargs):
|
| 15 |
+
ydl_opts = {
|
| 16 |
+
'outtmpl': f'{save_path}/video.%(ext)s',
|
| 17 |
+
}
|
| 18 |
+
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
| 19 |
+
info_dict = ydl.extract_info(url, download=download)
|
| 20 |
+
video_title = info_dict.get('title', None)
|
| 21 |
+
video_title = f"{video_title}"
|
| 22 |
+
return video_title
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
st.title("Download Any Video")
|
| 26 |
+
|
| 27 |
+
st.text_input("Video URL", key="url", placeholder="Enter Video URL and Hit Enter")
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
if st.session_state["url"]:
|
| 31 |
+
download = False if st.session_state["url"] in st.session_state["downloaded"] else True
|
| 32 |
+
video_path = download_video(st.session_state["url"], save_path=os.path.join(".", "data"), download=download)
|
| 33 |
+
st.session_state["videos"] = video_path
|
| 34 |
+
if not download:
|
| 35 |
+
st.session_state["downloaded"].append(st.session_state["url"])
|
| 36 |
+
|
| 37 |
+
if st.session_state["videos"]:
|
| 38 |
+
st.write("**Title**:", st.session_state["videos"])
|
| 39 |
+
st.video(os.path.join(".", "data", "video.mp4"))
|
| 40 |
+
video_file = open("data/video.mp4", "rb")
|
| 41 |
+
st.download_button("**Download Video π**",
|
| 42 |
+
data=video_file,
|
| 43 |
+
file_name=f"{st.session_state['videos'].lower().translate(str.maketrans('','', string.punctuation)).replace(' ', '_')}.mp4",
|
| 44 |
+
mime="video/mp4",
|
| 45 |
+
type="primary")
|