Add setting; github PAT

pull/1527/head
Chaz Larson 1 year ago
parent 1bf2243dfb
commit 583b6c8b94

@ -89,6 +89,8 @@ tmdb: # REQUIRED for the script to run
tautulli: # Can be individually specified per library as well
url: http://192.168.1.12:8181
apikey: ################################
github:
token: ################################
omdb:
apikey: ########
cache_expiration: 60

@ -209,6 +209,7 @@ html_theme_options = {
("Trakt", "config/trakt"),
("MdbList", "config/mdblist"),
("OMDb", "config/omdb"),
("Github", "config/github"),
("AniDB", "config/anidb"),
("MyAnimeList", "config/myanimelist"),
]),

@ -16,6 +16,7 @@ This table outlines the third-party services that Plex Meta Manager can make use
| [`webhooks`](webhooks) | ❌ |
| [`plex`](plex) | &#9989; <br/>Either here or per library |
| [`tmdb`](tmdb) | &#9989; |
| [`github`](github) | &#10060; |
| [`tautulli`](tautulli) | &#10060; |
| [`omdb`](omdb) | &#10060; |
| [`notifiarr`](notifiarr) | &#10060; |

@ -0,0 +1,19 @@
# Github Attributes
Configuring [Github](https://github.com/) is optional but can allow you to avoid rate limits when requesting data from github.
Requests made with a github token have a higher rate limit than anonymous requests.
A `github` mapping is in the root of the config file.
Below is a `github` mapping example and the full set of attributes:
```yaml
github:
token: ################################
```
| Attribute | Allowed Values | Default | Required |
|:-------------------|:---------------------------------------------------------------------------|:--------|:--------:|
| `token` | Github Personal Access Token | N/A | &#9989; |
* The Github Personal Access Token can be generated [here](https://github.com/settings/tokens).

@ -262,6 +262,7 @@ class ConfigFile:
hooks("collection_changes")
temp["changes"] = None if not changes else changes if len(changes) > 1 else changes[0]
self.data["webhooks"] = temp
if "github" in self.data: self.data["github"] = self.data.pop("github")
if "plex" in self.data: self.data["plex"] = self.data.pop("plex")
if "tmdb" in self.data: self.data["tmdb"] = self.data.pop("tmdb")
if "tautulli" in self.data: self.data["tautulli"] = self.data.pop("tautulli")

@ -12,6 +12,12 @@ configs_raw_url = f"{raw_url}/meisnate12/Plex-Meta-Manager-Configs"
class GitHub:
def __init__(self, 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.translation_url = f"{raw_url}/meisnate12/PMM-Translations/master/defaults/"
self._configs_url = None
@ -24,7 +30,7 @@ class GitHub:
repo = f"/{repo}"
if not str(repo).endswith("/"):
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:
raise Failed(f"Git Error: No repo found at https://github.com{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"]}
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"]
def get_commits(self, dev_version, nightly=False):
master_sha = self.config.get_json(f"{pmm_base}/commits/master")["sha"]
response = self.config.get_json(f"{pmm_base}/commits", params={"sha": "nightly" if nightly else "develop"})
master_sha = self.config.get_json(f"{pmm_base}/commits/master", headers=self.headers)["sha"]
response = self.config.get_json(f"{pmm_base}/commits", headers=self.headers, params={"sha": "nightly" if nightly else "develop"})
commits = []
for commit in response:
if commit["sha"] == master_sha:
@ -57,7 +63,7 @@ class GitHub:
def config_tags(self):
if not self._config_tags:
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:
pass
return self._config_tags
@ -83,7 +89,7 @@ class GitHub:
def translation_yaml(self, translation_key):
if translation_key not in self._translations:
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": {}}
for k in output:
if k in yaml:

Loading…
Cancel
Save