Last active
December 31, 2021 01:17
-
-
Save TIBTHINK/7c18dfc8086ce2e5ca3bba51d53f96c7 to your computer and use it in GitHub Desktop.
a small script that downloads the latest version of a plugin from github (script generated from http://pioxy.ddns.net:3000/tibthink/minecraft-server)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Yes i know, i could find a way to get the name of the jar file, | |
# but i am not motivated to give a fuck about it so you guys just | |
# have to deal with the lazyness | |
import os | |
import json | |
import requests | |
pwd = str(os.getcwd()) | |
class plugins(): | |
# This is for repos with more than one release version | |
def github_downloader(url, name, sub=1): | |
folder_check = os.path.exists(pwd + "/plugins") | |
if not folder_check: | |
path = os.path.join(pwd, "plugins") | |
os.mkdir(path) | |
response = requests.get(url) | |
data = response.json() | |
spigot_number = len(data[1]['assets']) | |
download_link = data[1]['assets'][spigot_number - sub]['browser_download_url'] | |
open(pwd + "/plugins/" + name, 'wb').write(requests.get(download_link).content) | |
# This is for repo's that have a single release | |
def github_downloader_sr(url, name,): | |
folder_check = os.path.exists(pwd + "/plugins") | |
if not folder_check: | |
path = os.path.join(pwd, "plugins") | |
os.mkdir(path) | |
response = requests.get(url) | |
data = response.json() | |
download_link = data[0]['assets'][0]['browser_download_url'] | |
open(pwd + "/plugins/" + name, 'wb').write(requests.get(download_link).content) | |
if __name__ == '__main__': | |
plugins.github_downloader("https://api.github.com/repos/webbukkit/dynmap/releases", "Dynmap.jar") | |
plugins.github_downloader("https://api.github.com/repos/PryPurity/WorldBorder/releases", "WorldBorder.jar") | |
plugins.github_downloader("https://api.github.com/repos/EssentialsX/Essentials/releases", "EssentialsX.jar", 8 ) | |
plugins.github_downloader_sr("https://api.github.com/repos/TIBTHINK/payRespect/releases", "PayRespect.jar") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment