-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMediaFire.py
More file actions
executable file
·72 lines (57 loc) · 2.26 KB
/
Copy pathMediaFire.py
File metadata and controls
executable file
·72 lines (57 loc) · 2.26 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
#!/usr/bin/env python3
import signal
import sys
# Global variable for Link 1 - Set This To a DL Link You own in your mediafire folder
# Example:
# Link1 = "https://www.mediafire.com/view/i0w4rh8twcwfirv/Test.png/file"
Link1 = "https://www.mediafire.com/file/b1wt1l2hrb0ey3e/Test.zip/file"
# Immediately check if Link1 is set
if not Link1:
print("Please set the 'Link1' variable in the script first.")
sys.exit(1)
# Function to handle SIGINT (CTRL+C)
def signal_handler(sig, frame):
print('\nYou pressed CTRL+C! Exiting gracefully.')
sys.exit(0)
# Register the signal handler for SIGINT
signal.signal(signal.SIGINT, signal_handler)
# Function to extract the unique ID from a Mediafire link
def extract_id(link):
# Attempt to extract the ID from the URL path
parts = link.split('/')
mediafire_index = next((i for i, part in enumerate(parts) if "mediafire.com" in part), None)
if mediafire_index is not None and len(parts) > mediafire_index + 2:
return parts[mediafire_index + 2]
# If the path method fails, attempt to extract the ID using the 'quickkey' parameter
if 'quickkey=' in link:
start = link.find('quickkey=') + len('quickkey=')
end = link.find('&', start)
return link[start:end if end != -1 else None]
return None
# Function to build the final link with the two IDs
def build_link(id1, id2):
return f"mediafire.com/?{id1},{id2}"
# Extract the ID from the preconfigured Link1
id1 = extract_id(Link1)
try:
# Prompt the user to enter Link 2 during runtime
Link2 = input("Enter Your Blocked Mediafire Link: ").strip()
# Check if Link2 contains "mediafire.com/"
if not Link2 or "mediafire.com/" not in Link2:
raise ValueError("Invalid or no link provided.")
except (EOFError, ValueError) as e:
# Handle case where user inputs an EOF character or an invalid link
print(f'\nError: {str(e)} Exiting.')
sys.exit(1)
# Extract the ID from Link 2
id2 = extract_id(Link2)
if not id2:
print('\nError: Could not extract ID from Link 2. Exiting.')
sys.exit(1)
# Adding line break before constructing the final link
print("\n")
print("Your Link:")
# Build the final link using the IDs from Link 1 and Link 2
final_link = build_link(id1, id2)
# Print the final link
print(final_link)