45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
from github_api import find_package_version_with_tag as find_package_version_with_tag_github
|
|
from dockerhub_api import find_package_version_with_tag as find_package_version_with_tag_dockerhub
|
|
import os
|
|
import json
|
|
|
|
def retrieve_state ():
|
|
default_state = {
|
|
"suwayomi_id": "",
|
|
"pihole_id":""
|
|
}
|
|
if os.path.exists("state.json"):
|
|
with open("state.json", "r") as f:
|
|
return json.load(f)
|
|
else:
|
|
state = default_state.copy()
|
|
return state
|
|
|
|
def save_state(state):
|
|
with open("state.json", "w") as f:
|
|
json.dump(state, f, indent=2)
|
|
|
|
def check_for_new_suwayomi_version():
|
|
latest_online_version = find_package_version_with_tag_github("Suwayomi", "tachidesk", "stable")
|
|
local_state = retrieve_state()
|
|
if latest_online_version != local_state["suwayomi_id"]:
|
|
local_state["suwayomi_id"] = latest_online_version
|
|
save_state(local_state)
|
|
print("New Suwayomi version has been found")
|
|
return True
|
|
print("No new Suwayomi version found")
|
|
return False
|
|
|
|
def check_for_new_pihole_version():
|
|
latest_online_version = find_package_version_with_tag_dockerhub("pihole/pihole", "latest")
|
|
local_state = retrieve_state()
|
|
if latest_online_version != local_state["pihole_id"]:
|
|
local_state["pihole_id"] = latest_online_version
|
|
save_state(local_state)
|
|
print("New Pi-hole version has been found")
|
|
return True
|
|
print("No new Pi-hole version found")
|
|
return False
|
|
|
|
if __name__ == '__main__':
|
|
check_for_new_pihole_version() |