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 os import path, remove
|
||||||
from requests import request
|
from requests import request
|
||||||
from ast import literal_eval as litEval
|
from ast import literal_eval as litEval
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
# Try to load cache
|
# Try to load cache
|
||||||
print("[[ Info ]] Trying to load installed versions from 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:
|
if not knownVersions.get(plugin, "") or knownVersions[plugin] != version:
|
||||||
with open(f"plugins/{pluginName}-spigot-{version}.jar", "wb") as f:
|
with open(f"plugins/{pluginName}-spigot-{version}.jar", "wb") as f:
|
||||||
f.write(
|
r = request(
|
||||||
request(
|
"GET",
|
||||||
|
f"https://api.spiget.org/v2/resources/{plugin}/versions/{version}/download/proxy",
|
||||||
|
allow_redirects=True,
|
||||||
|
)
|
||||||
|
while r.status_code == 429:
|
||||||
|
print("|| Warn || Spiget has ratelimited me, waiting 1s")
|
||||||
|
sleep(1)
|
||||||
|
r = request(
|
||||||
"GET",
|
"GET",
|
||||||
f"https://api.spiget.org/v2/resources/{plugin}/versions/{version}/download/proxy",
|
f"https://api.spiget.org/v2/resources/{plugin}/versions/{version}/download/proxy",
|
||||||
allow_redirects=True,
|
allow_redirects=True,
|
||||||
).content
|
)
|
||||||
)
|
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(
|
if knownVersions.get(plugin, "") and path.exists(
|
||||||
f"plugins/{pluginName}-spigot-{knownVersions.get(plugin, '')}.jar"
|
f"plugins/{pluginName}-spigot-{knownVersions.get(plugin, '')}.jar"
|
||||||
):
|
):
|
||||||
|
|
Loading…
Reference in a new issue