|
|
@ -12,6 +12,12 @@ configs_raw_url = f"{raw_url}/meisnate12/Plex-Meta-Manager-Configs"
|
|
|
|
class GitHub:
|
|
|
|
class GitHub:
|
|
|
|
def __init__(self, config):
|
|
|
|
def __init__(self, config):
|
|
|
|
self.config = config
|
|
|
|
self.config = config
|
|
|
|
|
|
|
|
self.headers = None
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
self.token = config.data["github"]["token"]
|
|
|
|
|
|
|
|
self.headers = {'Authorization': 'token ' + self.token}
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
self.token = None
|
|
|
|
self.images_raw_url = f"{raw_url}/meisnate12/PMM-Image-Sets/master/sets/"
|
|
|
|
self.images_raw_url = f"{raw_url}/meisnate12/PMM-Image-Sets/master/sets/"
|
|
|
|
self.translation_url = f"{raw_url}/meisnate12/PMM-Translations/master/defaults/"
|
|
|
|
self.translation_url = f"{raw_url}/meisnate12/PMM-Translations/master/defaults/"
|
|
|
|
self._configs_url = None
|
|
|
|
self._configs_url = None
|
|
|
@ -24,7 +30,7 @@ class GitHub:
|
|
|
|
repo = f"/{repo}"
|
|
|
|
repo = f"/{repo}"
|
|
|
|
if not str(repo).endswith("/"):
|
|
|
|
if not str(repo).endswith("/"):
|
|
|
|
repo = f"{repo}/"
|
|
|
|
repo = f"{repo}/"
|
|
|
|
response = self.config.get(f"{base_url}/repos{repo}commits")
|
|
|
|
response = self.config.get(f"{base_url}/repos{repo}commits", headers=self.headers)
|
|
|
|
if response.status_code >= 400:
|
|
|
|
if response.status_code >= 400:
|
|
|
|
raise Failed(f"Git Error: No repo found at https://github.com{repo}")
|
|
|
|
raise Failed(f"Git Error: No repo found at https://github.com{repo}")
|
|
|
|
return self.get_tree(response.json()[0]["commit"]["tree"]["url"]), repo
|
|
|
|
return self.get_tree(response.json()[0]["commit"]["tree"]["url"]), repo
|
|
|
@ -36,12 +42,12 @@ class GitHub:
|
|
|
|
return {i["path"]: i for i in response.json()["tree"]}
|
|
|
|
return {i["path"]: i for i in response.json()["tree"]}
|
|
|
|
|
|
|
|
|
|
|
|
def latest_release_notes(self):
|
|
|
|
def latest_release_notes(self):
|
|
|
|
response = self.config.get_json(f"{pmm_base}/releases/latest")
|
|
|
|
response = self.config.get_json(f"{pmm_base}/releases/latest", headers=self.headers)
|
|
|
|
return response["body"]
|
|
|
|
return response["body"]
|
|
|
|
|
|
|
|
|
|
|
|
def get_commits(self, dev_version, nightly=False):
|
|
|
|
def get_commits(self, dev_version, nightly=False):
|
|
|
|
master_sha = self.config.get_json(f"{pmm_base}/commits/master")["sha"]
|
|
|
|
master_sha = self.config.get_json(f"{pmm_base}/commits/master", headers=self.headers)["sha"]
|
|
|
|
response = self.config.get_json(f"{pmm_base}/commits", params={"sha": "nightly" if nightly else "develop"})
|
|
|
|
response = self.config.get_json(f"{pmm_base}/commits", headers=self.headers, params={"sha": "nightly" if nightly else "develop"})
|
|
|
|
commits = []
|
|
|
|
commits = []
|
|
|
|
for commit in response:
|
|
|
|
for commit in response:
|
|
|
|
if commit["sha"] == master_sha:
|
|
|
|
if commit["sha"] == master_sha:
|
|
|
@ -57,7 +63,7 @@ class GitHub:
|
|
|
|
def config_tags(self):
|
|
|
|
def config_tags(self):
|
|
|
|
if not self._config_tags:
|
|
|
|
if not self._config_tags:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
self._config_tags = [r["ref"][11:] for r in self.config.get_json(f"{pmm_base}-Configs/git/refs/tags")]
|
|
|
|
self._config_tags = [r["ref"][11:] for r in self.config.get_json(f"{pmm_base}-Configs/git/refs/tags", headers=self.headers)]
|
|
|
|
except TypeError:
|
|
|
|
except TypeError:
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
return self._config_tags
|
|
|
|
return self._config_tags
|
|
|
@ -83,7 +89,7 @@ class GitHub:
|
|
|
|
def translation_yaml(self, translation_key):
|
|
|
|
def translation_yaml(self, translation_key):
|
|
|
|
if translation_key not in self._translations:
|
|
|
|
if translation_key not in self._translations:
|
|
|
|
url = f"{self.translation_url}{translation_key}.yml"
|
|
|
|
url = f"{self.translation_url}{translation_key}.yml"
|
|
|
|
yaml = util.YAML(input_data=self.config.get(url).content).data
|
|
|
|
yaml = util.YAML(input_data=self.config.get(url, headers=self.headers).content).data
|
|
|
|
output = {"collections": {}, "key_names": {}, "variables": {}}
|
|
|
|
output = {"collections": {}, "key_names": {}, "variables": {}}
|
|
|
|
for k in output:
|
|
|
|
for k in output:
|
|
|
|
if k in yaml:
|
|
|
|
if k in yaml:
|
|
|
|