2021-02-26 00:22:16 +00:00
|
|
|
import urllib.request
|
|
|
|
from urllib.request import urlopen
|
|
|
|
from urllib.request import urlretrieve
|
|
|
|
import cgi
|
|
|
|
from consoleoutput import consoleTitle, clearConsole, printMainMenu
|
|
|
|
import time
|
|
|
|
|
|
|
|
|
|
|
|
def calculateFileSize(downloadFileSize):
|
|
|
|
fileSizeDownload = int(downloadFileSize)
|
|
|
|
fileSizeMb = fileSizeDownload / 1024 / 1024
|
|
|
|
roundedFileSize = round(fileSizeMb, 2)
|
|
|
|
return roundedFileSize
|
|
|
|
|
|
|
|
consoleTitle()
|
|
|
|
|
2021-02-27 00:36:16 +00:00
|
|
|
|
2021-02-26 00:22:16 +00:00
|
|
|
print("if you see this clearConsole dont work")
|
|
|
|
clearConsole()
|
|
|
|
printMainMenu()
|
2021-02-27 00:36:16 +00:00
|
|
|
choice = input(" pluGET >> ")
|
2021-02-26 00:22:16 +00:00
|
|
|
if choice == "1":
|
|
|
|
ressourceId = input("SpigotMC Ressource ID: ")
|
|
|
|
|
|
|
|
# 28140 for Luckperms (Testing only)
|
|
|
|
url = "https://api.spiget.org/v2/resources/" + ressourceId + "/download"
|
|
|
|
print(url)
|
|
|
|
|
|
|
|
# getting original filename
|
|
|
|
remotefile = urlopen(url)
|
|
|
|
filecontent = remotefile.info()['Content-Disposition']
|
|
|
|
filesize = remotefile.info()['Content-Length']
|
|
|
|
value, params = cgi.parse_header(filecontent)
|
|
|
|
filename = params["filename"]
|
|
|
|
|
|
|
|
# creating file path
|
2021-02-27 00:36:16 +00:00
|
|
|
path = r"C:\\Users\USER\Desktop\\"
|
2021-02-26 00:22:16 +00:00
|
|
|
ppath = path + filename
|
|
|
|
|
|
|
|
# download file
|
|
|
|
urllib.request.urlretrieve(url, ppath)
|
|
|
|
|
|
|
|
filesizeData = calculateFileSize(filesize)
|
|
|
|
print(filesizeData)
|
|
|
|
|
|
|
|
#print(format(filesizeinmb, '.2f'))
|
|
|
|
|
|
|
|
print("Hello world")
|
|
|
|
print("Waiting still seconds: 5", end='\r')
|
|
|
|
time.sleep(1)
|
|
|
|
print("Waiting still seconds: 4", end='\r')
|
|
|
|
time.sleep(1)
|
|
|
|
print("Waiting still seconds: 3", end='\r')
|
|
|
|
time.sleep(1)
|
|
|
|
print("Waiting still seconds: 2", end='\r')
|
|
|
|
time.sleep(1)
|
|
|
|
print("Waiting still seconds: 1", end='\r')
|
|
|
|
time.sleep(1)
|
2021-02-27 00:36:16 +00:00
|
|
|
print("Done ✅☑✔ ")
|
|
|
|
input("Press key to end program...")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# get latest update > https://api.spiget.org/v2/resources/28140/updates/latest
|
|
|
|
# this also > https://api.spiget.org/v2/resources/28140/versions/latest
|
|
|
|
# get latest download with correct name > https://api.spiget.org/v2/resources/28140/versions/latest/download
|
|
|
|
# query for a plugin https://api.spiget.org/v2/search/resources/luckperms?field=name
|