mirror of
https://github.com/linuxserver/docker-lsio-api.git
synced 2026-02-20 08:40:34 +08:00
Cleanup
This commit is contained in:
parent
6c3f9f737c
commit
5f816beec9
@ -5,16 +5,12 @@ import os
|
||||
import yaml
|
||||
|
||||
PAT = os.environ.get("PAT", None)
|
||||
|
||||
GH_AUTH = Auth.Token(PAT) if PAT else None
|
||||
GH = Github(auth=GH_AUTH)
|
||||
|
||||
def get_repos():
|
||||
auth = Auth.Token(PAT) if PAT else None
|
||||
gh = Github(auth=auth)
|
||||
org = gh.get_organization("linuxserver")
|
||||
repos = org.get_repos()
|
||||
return [repo for repo in sorted(repos, key=lambda repo: repo.name) if repo.name.startswith("docker-")
|
||||
and not repo.name.startswith("docker-baseimage-")
|
||||
and (repo.description is None or "DEPRECATED" not in repo.description)]
|
||||
org = GH.get_organization("linuxserver")
|
||||
return org.get_repos()
|
||||
|
||||
def get_file(repo, branch, path, is_yaml=False):
|
||||
try:
|
||||
@ -31,8 +27,11 @@ def get_last_stable_release(repo):
|
||||
return "latest", str(repo.pushed_at)
|
||||
|
||||
def get_readme_vars(repo):
|
||||
master = get_file(repo, "master", "readme-vars.yml", is_yaml=True)
|
||||
main = get_file(repo, "master", "readme-vars.yml", is_yaml=True)
|
||||
develop = get_file(repo, "master", "readme-vars.yml", is_yaml=True)
|
||||
nightly = get_file(repo, "master", "readme-vars.yml", is_yaml=True)
|
||||
return master or main or develop or nightly
|
||||
return (
|
||||
get_file(repo, "master", "readme-vars.yml", is_yaml=True) or
|
||||
get_file(repo, "main", "readme-vars.yml", is_yaml=True) or
|
||||
get_file(repo, "develop", "readme-vars.yml", is_yaml=True) or
|
||||
get_file(repo, "nightly", "readme-vars.yml", is_yaml=True))
|
||||
|
||||
def print_rate_limit():
|
||||
print(f"Github ratelimit - {GH.get_rate_limit()}")
|
||||
|
||||
@ -48,6 +48,8 @@ def get_description(readme_vars):
|
||||
return description
|
||||
|
||||
def get_image(repo):
|
||||
if not repo.name.startswith("docker-") or repo.name.startswith("docker-baseimage-"):
|
||||
return None
|
||||
readme_vars = gh.get_readme_vars(repo)
|
||||
if not readme_vars:
|
||||
return None
|
||||
@ -82,7 +84,7 @@ def update_images():
|
||||
print(f"{datetime.datetime.now()} - updating images")
|
||||
images = []
|
||||
repos = gh.get_repos()
|
||||
for repo in repos:
|
||||
for repo in sorted(repos, key=lambda repo: repo.name):
|
||||
image = get_image(repo)
|
||||
if not image:
|
||||
continue
|
||||
@ -94,7 +96,9 @@ def update_images():
|
||||
def main():
|
||||
set_db_schema()
|
||||
while True:
|
||||
gh.print_rate_limit()
|
||||
update_images()
|
||||
gh.print_rate_limit()
|
||||
time.sleep(INVALIDATE_HOURS*60*60)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user