Skip to content

Commit 64e8457

Browse files
Add files via upload
1 parent aab92a1 commit 64e8457

File tree

4 files changed

+175
-0
lines changed

4 files changed

+175
-0
lines changed

mp4-donwload-main/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Radoslav Petkov
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

mp4-donwload-main/README.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# YouTube Downloader (yt-dlp)
2+
3+
A simple Python script for downloading videos or audio from YouTube using the `yt-dlp` tool.
4+
5+
## Features
6+
7+
- Download multiple YouTube videos or audio tracks at once.
8+
- Automatically saves downloads in a `downloads` folder located in the same directory as the script.
9+
- Supports downloading in either `mp4` (video) or `mp3` (audio) formats.
10+
11+
## Prerequisites
12+
13+
1. **Python 3.x**:
14+
- Ensure you have Python 3 installed on your system. You can download it from [python.org](https://www.python.org/).
15+
16+
2. **yt-dlp**:
17+
- Install the `yt-dlp` tool using pip:
18+
```bash
19+
pip install yt-dlp
20+
```
21+
22+
3. **FFmpeg** (required for audio extraction):
23+
- Install FFmpeg for your platform:
24+
- **Linux**: Install via your package manager (e.g., `sudo apt install ffmpeg`).
25+
- **MacOS**: Install via Homebrew (`brew install ffmpeg`).
26+
- **Windows**: Download from [ffmpeg.org](https://ffmpeg.org/).
27+
28+
## Installation
29+
30+
1. Clone the repository or download the script:
31+
```bash
32+
git clone https://github.com/yourusername/youtube-downloader.git
33+
cd youtube-downloader
34+
35+
2. Ensure the script is executable:
36+
37+
chmod +x youtube_downloader.py
38+
39+
40+
41+
Usage
42+
1. Run the script:
43+
44+
./youtube_downloader.py
45+
46+
47+
2. Input YouTube URLs (one per line):
48+
49+
https://www.youtube.com/watch?v=example1
50+
https://www.youtube.com/watch?v=example2
51+
52+
Press Enter on an empty line to finish input.
53+
54+
3. Choose the format:
55+
• Type mp4 for video.
56+
• Type mp3 for audio.
57+
4. The script will download all files into the downloads folder.
58+
59+
Example Output
60+
61+
When the script runs, it will display the following:
62+
63+
==== YouTube Downloader (yt-dlp) ====
64+
65+
Enter YouTube URLs, one per line. Then press Enter on an empty line to finish:
66+
https://www.youtube.com/watch?v=example1
67+
https://www.youtube.com/watch?v=example2
68+
69+
Choose format: 'mp4' for video or 'mp3' for audio: mp3
70+
71+
Starting downloads in: /path/to/script/downloads
72+
73+
Downloading: https://www.youtube.com/watch?v=example1
74+
Downloading: https://www.youtube.com/watch?v=example2
75+
76+
All downloads completed!
77+
78+
Notes
79+
• The script automatically creates a downloads folder if it doesn’t already exist.
80+
• Invalid URLs will not be downloaded.
81+
• For issues with audio or video, ensure FFmpeg is correctly installed.
82+
83+
License
84+
85+
This project is licensed under the MIT License. See the LICENSE file for details.
86+
87+
Happy downloading! 🎥🎶
88+
89+
You can customize the `git clone` URL or any other project-specific details as needed!

mp4-donwload-main/download/d

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

mp4-donwload-main/mp4_player.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env python3
2+
3+
import os
4+
import subprocess
5+
import sys
6+
7+
8+
def main():
9+
print("==== YouTube Downloader (yt-dlp) ====\n")
10+
11+
script_dir = os.path.dirname(os.path.abspath(__file__))
12+
default_output_folder = os.path.join(script_dir, "downloads")
13+
14+
if not os.path.isdir(default_output_folder):
15+
print(f"Creating default folder: '{default_output_folder}'...")
16+
os.makedirs(default_output_folder, exist_ok=True)
17+
18+
print("Enter YouTube URLs, one per line. Then press Enter on an empty line to finish:")
19+
urls = []
20+
while True:
21+
line = sys.stdin.readline().strip()
22+
if not line:
23+
break
24+
urls.append(line)
25+
26+
if not urls:
27+
print("No URLs provided. Exiting.")
28+
sys.exit(1)
29+
30+
while True:
31+
download_format = input("Choose format: 'mp4' for video or 'mp3' for audio: ").strip().lower()
32+
if download_format in ["mp4", "mp3"]:
33+
break
34+
print("Invalid choice. Please type 'mp4' or 'mp3'.")
35+
36+
print(f"\nAll downloads will be saved to: {default_output_folder}")
37+
38+
print(f"\nStarting downloads in: {default_output_folder}")
39+
for url in urls:
40+
print(f"\nDownloading: {url}")
41+
42+
if download_format == 'mp4':
43+
cmd = [
44+
"yt-dlp",
45+
"-f", "mp4",
46+
"--merge-output-format", "mp4",
47+
"-o", os.path.join(default_output_folder, "%(title)s.%(ext)s"),
48+
url
49+
]
50+
else:
51+
cmd = [
52+
"yt-dlp",
53+
"-x", "--audio-format", "mp3",
54+
"-o", os.path.join(default_output_folder, "%(title)s.%(ext)s"),
55+
url
56+
]
57+
58+
subprocess.run(cmd, check=False)
59+
60+
print("\nAll downloads completed!")
61+
62+
63+
if __name__ == "__main__":
64+
main()

0 commit comments

Comments
 (0)