the smell of an idea
This commit is contained in:
parent
33fdeeb5f9
commit
eca3d077fe
57
main.py
Normal file
57
main.py
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
import requests
|
||||||
|
import tqdm
|
||||||
|
import tarfile
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
discordUrl = "https://discord.com/api/download?platform=linux&format=tar.gz"
|
||||||
|
tmpDir = "/tmp/dup/"
|
||||||
|
confDir = "~/.config/"
|
||||||
|
installDir = os.path.expanduser("~") + "/.local/lib/Discord"
|
||||||
|
|
||||||
|
def download(url: str, dest: str):
|
||||||
|
with open(tmpDir + dest, 'wb') as f:
|
||||||
|
with requests.get(url, stream=True) as r:
|
||||||
|
r.raise_for_status()
|
||||||
|
totalLength = int(r.headers.get('content-length', 0))
|
||||||
|
|
||||||
|
tqdm_params = {
|
||||||
|
'desc': dest,
|
||||||
|
'total': totalLength,
|
||||||
|
'miniters': 1,
|
||||||
|
'bar_format' : "{desc}: |{bar:40}| {percentage:3.1f}% ",
|
||||||
|
}
|
||||||
|
with tqdm.tqdm(**tqdm_params) as pb:
|
||||||
|
for chunk in r.iter_content(chunk_size=8192):
|
||||||
|
pb.update(len(chunk))
|
||||||
|
f.write(chunk)
|
||||||
|
|
||||||
|
def rm(file):
|
||||||
|
print("TBA")
|
||||||
|
def rmdir():
|
||||||
|
print("TBA")
|
||||||
|
def mkdir():
|
||||||
|
print("TBA")
|
||||||
|
|
||||||
|
def installDiscord():
|
||||||
|
#os.mkdir(tmpDir)
|
||||||
|
|
||||||
|
print("Downloading Discord...")
|
||||||
|
download(discordUrl, "discord.tar.gz")
|
||||||
|
|
||||||
|
print("Extracting..." )
|
||||||
|
file = tarfile.open(tmpDir+"/discord.tar.gz")
|
||||||
|
os.mkdir("/tmp/dup/discord")
|
||||||
|
file.extractall(tmpDir+"/discord")
|
||||||
|
file.close()
|
||||||
|
|
||||||
|
print("Installing...")
|
||||||
|
shutil.rmtree(installDir)
|
||||||
|
shutil.move(tmpDir+"/discord/Discord", installDir)
|
||||||
|
|
||||||
|
print("Cleaning up...")
|
||||||
|
# os.remove(tmpDir+"discord.tar.gz")
|
||||||
|
shutil.rmtree(tmpDir)
|
||||||
|
|
||||||
|
|
||||||
|
installDiscord()
|
Loading…
Reference in New Issue
Block a user