Commit b490d9eb authored by Seblu's avatar Seblu
Browse files

Support AUR API v5

parent bb34abc5
Pipeline #484 passed with stages
in 5 minutes and 16 seconds
......@@ -77,18 +77,19 @@ class AURPackage(dict):
def __init__(self, name, timeout=None):
super().__init__() = name
url = "%s/rpc.php?type=info&arg=%s" % (self.AUR_URL, name)
url = "%s/rpc.php?v=5&type=info&arg[]=%s" % (self.AUR_URL, name)
url_req = Request(url, headers={"User-Agent": self.USER_AGENT})
debug(f"{name} Requesting url: {url} (timeout: {timeout}s)")
url_fd = urlopen(url_req, timeout=timeout)
d = jloads("utf-8"))
if d["version"] != 1:
if d["version"] != 5:
raise Exception(f"Unknown AUR Backend version: {d['version']}")
if len(d["results"]) == 0:
raise Exception(f"No such package: {name}")
if d["results"]["PackageBase"] != name:
raise Exception(f"No such base package: {name}")
self._info = d["results"]
if d["results"][0]["PackageBase"] != name:
raise Exception(f"Not a base package")
self._info = d["results"][0]
except Exception as err:
raise Exception(f"No such package: {name}") from err
def __getattr__(self, name):
for k, v in self._info.items():
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment