spiget is annoying, wtf can files be empty
This commit is contained in:
parent
694179cdb0
commit
3680b79bad
1 changed files with 24 additions and 4 deletions
|
@ -1,6 +1,7 @@
|
|||
from os import path, remove
|
||||
from requests import request
|
||||
from ast import literal_eval as litEval
|
||||
from time import sleep
|
||||
|
||||
# Try to load cache
|
||||
print("[[ Info ]] Trying to load installed versions from cache...")
|
||||
|
@ -81,13 +82,32 @@ if spigotPlugins:
|
|||
)
|
||||
if not knownVersions.get(plugin, "") or knownVersions[plugin] != version:
|
||||
with open(f"plugins/{pluginName}-spigot-{version}.jar", "wb") as f:
|
||||
f.write(
|
||||
request(
|
||||
r = request(
|
||||
"GET",
|
||||
f"https://api.spiget.org/v2/resources/{plugin}/versions/{version}/download/proxy",
|
||||
allow_redirects=True,
|
||||
).content
|
||||
)
|
||||
while r.status_code == 429:
|
||||
print("|| Warn || Spiget has ratelimited me, waiting 1s")
|
||||
sleep(1)
|
||||
r = request(
|
||||
"GET",
|
||||
f"https://api.spiget.org/v2/resources/{plugin}/versions/{version}/download/proxy",
|
||||
allow_redirects=True,
|
||||
)
|
||||
if r.content == b"":
|
||||
print(
|
||||
f"""
|
||||
!! Notice !! For whatever reason, {pluginName} is not available through the download proxy API.
|
||||
!! Notice !! The plugin download should be at https://api.spiget.org/v2/resources/{plugin}/versions/{version}/download
|
||||
!! Notice !! I apologize for not being able to get this plugin on my own, but there's nothing I can do here.
|
||||
!! Notice !! I will mark this plugin's version as 'NULL-{version}'
|
||||
!! Notice !! Which will allow you to see if this plugin needs updates on later script runs by comparing the two NULL versions.
|
||||
"""
|
||||
)
|
||||
version = f"NULL-{version}"
|
||||
else:
|
||||
f.write(r.content)
|
||||
if knownVersions.get(plugin, "") and path.exists(
|
||||
f"plugins/{pluginName}-spigot-{knownVersions.get(plugin, '')}.jar"
|
||||
):
|
||||
|
|
Loading…
Reference in a new issue