-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathx.com.py
More file actions
261 lines (215 loc) · 8.96 KB
/
x.com.py
File metadata and controls
261 lines (215 loc) · 8.96 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
import subprocess
import os
import time
import sys
# Try to import optional dependencies
try:
import pyfiglet
from colorama import Fore, init
# Initialize Colorama
init(autoreset=True)
FANCY_AVAILABLE = True
except ImportError:
FANCY_AVAILABLE = False
def clear_screen():
"""Clear the terminal screen."""
os.system('cls' if os.name == 'nt' else 'clear')
def print_fancy_logo():
"""Generate a fancy animated logo with colors using pyfiglet and colorama."""
if not FANCY_AVAILABLE:
print("Fancy mode requires pyfiglet and colorama. Install with: pip install pyfiglet colorama")
return False
# 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.01) # Slight delay to create a glowing effect
else:
print(char, end='', flush=True)
print("\n") # New line after the logo
# Welcome message
welcome_message = f"{Fore.LIGHTBLUE_EX}Welcome to the X 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 with both names
developer_info = f"Created by {Fore.LIGHTGREEN_EX}@eirsvi {Fore.RESET}and {Fore.LIGHTGREEN_EX}@kmjBuCa"
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://x.com/elonmusk/status/1790978078233252341 \n"
print(example_url)
print() # Add an extra newline for spacing
return True
def print_simple_logo():
"""Generate a simple text logo without dependencies."""
# Simple text logo
logo = """
SRIEVi
"""
# 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())
# Print each character without delay
print("\n") # Add spacing before the logo
for char in centered_logo:
print(char, end='', flush=True)
print("\n") # New line after the logo
# Welcome message
welcome_message = "Welcome to the X Video Downloader! \n"
terminal_width = os.get_terminal_size().columns
centered_message = welcome_message.center(terminal_width)
print(centered_message)
# Developer info with both names
developer_info = "Created by @eirsvi and @kmjBuCa"
centered_developer = developer_info.center(terminal_width)
print(centered_developer)
# Social links
social_links = "GitHub | X | YouTube \n"
centered_social_links = social_links.center(terminal_width)
print(centered_social_links)
# Example URL
example_url = "EXAMPLE URL: https://x.com/elonmusk/status/1790978078233252341 \n"
print(example_url)
print() # Add an extra newline for spacing
return True
def print_minimal_logo():
"""Generate a minimal logo with ANSI colors."""
# Centered intro and credits
intro = "|||||||||[ X.COM ]|||||||||"
credits = "@EIRSVi | @kmjBuCa"
# Center the text
terminal_width = os.get_terminal_size().columns
centered_intro = intro.center(terminal_width)
centered_credits = credits.center(terminal_width)
# Print the intro and credits
print("\033[38;5;39m" + centered_intro) # Aqua color
print("\033[38;5;50m" + centered_credits) # Green color
print("\033[0m") # Reset color
# Short prompt guide
print("\nThis script can download X videos and save them to your computer.\n")
return True
def download_video(style, output_dir=None):
"""Download a video from X.com with the specified style."""
clear_screen()
# Display the selected style logo
if style == 1:
success = print_fancy_logo()
if not success:
print("Falling back to simple mode...")
print_simple_logo()
elif style == 2:
print_simple_logo()
elif style == 3:
print_minimal_logo()
# Determine the prompt style based on the selected display style
if style == 1 and FANCY_AVAILABLE:
url = input(f"{Fore.LIGHTCYAN_EX}Enter the X video URL: {Fore.RESET}")
elif style == 3:
url = input("\033[38;5;39mEnter the X video URL: \033[0m")
else:
url = input("Enter the X video URL: ")
# Determine output directory
if output_dir is None:
if style == 1:
output_dir = os.path.expanduser('~/Downloads')
else:
output_dir = os.path.expanduser('~/Videos')
# Create the directory if it doesn't exist
if not os.path.exists(output_dir):
os.makedirs(output_dir)
# 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)
# Success message based on style
if style == 1 and FANCY_AVAILABLE:
print(f"{Fore.LIGHTGREEN_EX}Video downloaded successfully!")
print(f"{Fore.LIGHTGREEN_EX}Video saved in: {output_dir}")
elif style == 3:
print("\033[38;5;50mVideo downloaded successfully!\033[0m")
print(f"\033[38;5;50mVideo saved in: {output_dir}\033[0m")
else:
print(f"Video downloaded successfully!")
print(f"Video saved in: {output_dir}")
except subprocess.CalledProcessError as e:
# Error message based on style
if style == 1 and FANCY_AVAILABLE:
print(f"{Fore.LIGHTRED_EX}Error downloading video: {e}")
elif style == 3:
print(f"\033[38;5;196mError downloading video: {e}\033[0m")
else:
print(f"Error downloading video: {e}")
# Ask if the user wants to download another video
if style == 1 and FANCY_AVAILABLE:
again = input(f"\n{Fore.CYAN}Do you want to download another video? (y/n): {Fore.RESET}")
elif style == 3:
again = input("\n\033[38;5;39mDo you want to download another video? (y/n): \033[0m")
else:
again = input("\nDo you want to download another video? (y/n): ")
if again.lower() == 'y':
return True
return False
def select_output_directory():
"""Let the user select an output directory."""
print("\nSelect output directory:")
print("1. Downloads folder")
print("2. Videos folder")
print("3. Custom location")
choice = input("Enter your choice (1-3): ")
if choice == '1':
return os.path.expanduser('~/Downloads')
elif choice == '2':
return os.path.expanduser('~/Videos')
elif choice == '3':
custom_dir = input("Enter custom directory path: ")
# Expand user directory if needed
if custom_dir.startswith('~'):
custom_dir = os.path.expanduser(custom_dir)
return custom_dir
else:
print("Invalid choice. Using default (Downloads folder).")
return os.path.expanduser('~/Downloads')
def main():
"""Main function to run the X video downloader."""
clear_screen()
print("X Video Downloader")
print("=================\n")
# Automatically use fancy mode if available, otherwise use simple mode
style = 1 if FANCY_AVAILABLE else 2
if FANCY_AVAILABLE:
print("Using Fancy display style")
else:
print("Fancy mode not available. Using Simple display style.")
print("To enable Fancy mode, install: pip install pyfiglet colorama")
print()
# Ask for output directory
print("Would you like to select an output directory?")
dir_choice = input("Enter 'y' for yes, any other key for default: ")
output_dir = None
if dir_choice.lower() == 'y':
output_dir = select_output_directory()
# Download loop
while True:
continue_downloading = download_video(style, output_dir)
if not continue_downloading:
break
print("\nThank you for using X Video Downloader!")
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print("\n\nProgram interrupted. Exiting...")
sys.exit(0)