mirror of
https://github.com/meisnate12/Plex-Meta-Manager
synced 2024-11-10 06:54:21 +00:00
[69] Merge remote-tracking branch 'chazlarson/task/github-credentials' into nightly
This commit is contained in:
commit
74f22a49ba
8 changed files with 38 additions and 7 deletions
|
@ -171,3 +171,4 @@ If you are unable to use the [Plex Meta Manager Discord Server](https://discord.
|
|||
* Pull Requests are greatly encouraged, please submit all Pull Requests to the nightly branch.
|
||||
|
||||
<br>
|
||||
|
||||
|
|
|
@ -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) | ✅ <br/>Either here or per library |
|
||||
| [`tmdb`](tmdb) | ✅ |
|
||||
| [`github`](github) | ❌ |
|
||||
| [`tautulli`](tautulli) | ❌ |
|
||||
| [`omdb`](omdb) | ❌ |
|
||||
| [`notifiarr`](notifiarr) | ❌ |
|
||||
|
|
19
docs/config/github.md
Normal file
19
docs/config/github.md
Normal file
|
@ -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 | ✅ |
|
||||
|
||||
* The GitHub Personal Access Token can be generated [here](https://github.com/settings/tokens).
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
## Plex Meta Manager Team
|
||||
|
||||
| Github | Discord | Role |
|
||||
| GitHub | Discord | Role |
|
||||
|:----------------------------------------------|:------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| [meisnate12](https://github.com/meisnate12/) | Sohjiro | Main PMM Developer |
|
||||
| [YozoraXCII](https://github.com/YozoraXCII) | Yozora | PMM Discord Moderator, Default Configs Creator & Maintainer, Wiki Contributor, [Configs Repo](https://github.com/meisnate12/Plex-Meta-Manager-Configs) Maintainer |
|
||||
|
|
|
@ -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…
Reference in a new issue