This repository was archived by the owner on Feb 2, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathtools.py
78 lines (65 loc) · 2.27 KB
/
tools.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
78
from os import system
from requests import get, head
from rich.progress import Progress
from rich import print
from re import match as rematch
from subprocess import run, PIPE
# replace the ` ` with an `-` in url encoding, shit just fucking works
def caseConverter(inp):
return(inp.replace(' ', '-').lower())
# `cls` shortcut
def cls():
system('cls')
# Y/n quick question shortcut
def ny():
inp = input('(N/y) ')
if inp.lower() == 'y':
return(True)
else:
return(False)
def yn():
inp = input('(Y/n) ')
if inp.lower() == 'n':
return(False)
else:
return(True)
# Downloads the file from any source
# Uses rich's progress bar tracking
def download(url, fnam, name):
headers = {'Accept-Encoding': 'gzip, deflate',
'User-Agent': 'Mozilla/5.0',
'cache_control': 'max-age=600',
'connection': 'keep-alive'}
response = head(url, headers=headers)
total_size = int(response.headers.get("content-length", 0))
with Progress() as progress:
task = progress.add_task(f"[cyan]:: Downloading [bold]{name}[/bold][/cyan]", total=total_size)
with open(fnam, "wb") as file:
response = get(url, stream=True)
chunk_size = 1024 # You can adjust this value as needed
# the shits that writes the data and updates the progress bar every 1kib
for data in response.iter_content(chunk_size=chunk_size):
file.write(data)
progress.update(task, completed=file.tell())
# Shortens the file names so they are shorter ¯\_(ツ)_/¯
def convertFilename(inp):
if 'revanced-cli' in inp:
return('cli.jar')
elif 'revanced-integrations' in inp:
return('integrations.apk')
elif 'revanced-patches' in inp:
return('patches.jar')
# this fucking shit converts ex. patches.jar to ReVanced Patches
# Used in the downloader
def fuckingConverter(inp):
return(f"ReVanced {inp.split('.')[0].capitalize()}")
def javaCheck():
try:
result = run(['java', '-version'], stdout=PIPE, stderr=PIPE, text=True)
if result.returncode == 0:
if '17.' in result.stderr:
return True
else:
return False
except:
return False