-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclone.py
62 lines (52 loc) · 1.69 KB
/
clone.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
from RegisterMegaAcc import ExtractURL, register
import os, sys
from rich import print
from rich.spinner import Spinner
from rich.live import Live
# print(f'Credentials:\n{email}, {password}')
def login(email, password):
stream = os.popen(f'mega-login "{email}" "{password}"')
output = stream.read()
return(output)
def logout():
stream = os.popen(f'mega-logout')
output = stream.read()
return(output)
def import_file(link):
stream = os.popen(f'mega-import {link}')
output = stream.read()
return(output)
def export_file(filename):
stream = os.popen(f'mega-export -a -f "{filename}"')
output = stream.read()
# print(output)
return(output)
def mega_ls():
stream = os.popen('mega-ls')
output = stream.read()
return(output)
def clone(_link, _email, _password):
# os.popen('$env:PATH += ";$env:LOCALAPPDATA\MEGAcmd"')
# print('Logging in...')
login(_email, _password)
# print('Importing file...')
import_file(_link)
filename = str(mega_ls()).strip("'")
# print(filename)
mirror_link = ExtractURL(export_file(filename))
# print('Logging out...')
logout()
return(mirror_link)
if __name__ == "__main__":
link = sys.argv[1]
link_stripped = link.strip("'\"")
with Live(Spinner('dots', text='Registering account...', style='blue'), refresh_per_second=20, transient=True):
while True:
email, password = register()
break
with Live(Spinner('dots', text='Cloning...', style='blue'), refresh_per_second=20, transient=True):
while True:
exported = clone(link, email, password)
break
print()
print(f'[cyan]Cloned link: {exported}[/cyan]')