-
Notifications
You must be signed in to change notification settings - Fork 0
/
ytdl1video.py
77 lines (60 loc) · 2.76 KB
/
ytdl1video.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import subprocess
import os
import pyfiglet
from colorama import Fore, init
import time
# Initialize Colorama
init(autoreset=True)
def print_colored_logo():
# Generate ASCII art for the logo with a modern font
logo = pyfiglet.figlet_format("SRIEVi", font="slant")
# Center the logo in the terminal
terminal_width = os.get_terminal_size().columns
centered_logo = "\n".join(line.center(terminal_width) for line in logo.splitlines())
# Colors for the gradient effect (cyber-like appearance)
colors = [Fore.LIGHTCYAN_EX, Fore.CYAN, Fore.MAGENTA, Fore.LIGHTMAGENTA_EX, Fore.LIGHTGREEN_EX, Fore.LIGHTBLUE_EX]
# Apply a glowing effect to each character in the logo
print("\n") # Add spacing before the logo
for i, char in enumerate(centered_logo):
if char.strip(): # Apply color only to non-space characters
print(colors[i % len(colors)] + char, end='', flush=True)
time.sleep(0.03) # Slight delay to create a glowing effect
else:
print(char, end='', flush=True)
print("\n") # New line after the logo
def print_welcome():
# Call the function to print the colored logo
print_colored_logo()
# Welcome message
welcome_message = f"{Fore.LIGHTBLUE_EX}Welcome to the YouTube Video Downloader! \n"
terminal_width = os.get_terminal_size().columns
centered_message = welcome_message.center(terminal_width)
print(centered_message)
# Updated GitHub and social links
developer_info = f"Support us {Fore.LIGHTGREEN_EX}@eirsvi "
centered_developer = developer_info.center(terminal_width)
print(centered_developer)
social_links = f"{Fore.LIGHTRED_EX}GitHub | X | YouTube \n"
centered_social_links = social_links.center(terminal_width)
print(centered_social_links)
# Example URL without centering
example_url = f"EXAMPLE URL:{Fore.LIGHTYELLOW_EX} https://youtu.be/lXnpiXJirlA?si=YWXPbH5M8mFhSBVD \n"
print(example_url)
print() # Add an extra newline for spacing
def download_youtube_video():
# Call the welcome message function
print_welcome()
# Prompt user for the video URL
url = input(f"{Fore.LIGHTCYAN_EX}Enter the YouTube video URL: ")
# Define a default output directory (e.g., ~/Downloads)
output_dir = os.path.expanduser('~/Downloads')
# Generate the output file name
output_file = os.path.join(output_dir, '%(title)s.%(ext)s')
try:
# Command to download video using yt-dlp
subprocess.run(['yt-dlp', '-o', output_file, url], check=True)
print(f"{Fore.LIGHTGREEN_EX}Video downloaded successfully: {output_file}")
except subprocess.CalledProcessError as e:
print(f"{Fore.LIGHTRED_EX}Error downloading video: {e}")
if __name__ == "__main__":
download_youtube_video()