|
|
@ -70,7 +70,7 @@ class Webhooks:
|
|
|
|
|
|
|
|
|
|
|
|
def start_time_hooks(self, start_time):
|
|
|
|
def start_time_hooks(self, start_time):
|
|
|
|
if self.run_start_webhooks:
|
|
|
|
if self.run_start_webhooks:
|
|
|
|
self._request(self.run_start_webhooks, {"start_time": start_time.strftime("%Y-%m-%d %H:%M:%S")})
|
|
|
|
self._request(self.run_start_webhooks, {"event": "run_start", "start_time": start_time.strftime("%Y-%m-%d %H:%M:%S")})
|
|
|
|
|
|
|
|
|
|
|
|
def version_hooks(self, version, latest_version):
|
|
|
|
def version_hooks(self, version, latest_version):
|
|
|
|
if self.version_webhooks:
|
|
|
|
if self.version_webhooks:
|
|
|
@ -79,11 +79,12 @@ class Webhooks:
|
|
|
|
notes = self.config.GitHub.latest_release_notes()
|
|
|
|
notes = self.config.GitHub.latest_release_notes()
|
|
|
|
elif version[2] and version[2] < latest_version[2]:
|
|
|
|
elif version[2] and version[2] < latest_version[2]:
|
|
|
|
notes = self.config.GitHub.get_commits(version[2], nightly=self.config.check_nightly)
|
|
|
|
notes = self.config.GitHub.get_commits(version[2], nightly=self.config.check_nightly)
|
|
|
|
self._request(self.version_webhooks, {"current": version[0], "latest": latest_version[0], "notes": notes})
|
|
|
|
self._request(self.version_webhooks, {"event": "version", "current": version[0], "latest": latest_version[0], "notes": notes})
|
|
|
|
|
|
|
|
|
|
|
|
def end_time_hooks(self, start_time, end_time, run_time, stats):
|
|
|
|
def end_time_hooks(self, start_time, end_time, run_time, stats):
|
|
|
|
if self.run_end_webhooks:
|
|
|
|
if self.run_end_webhooks:
|
|
|
|
self._request(self.run_end_webhooks, {
|
|
|
|
self._request(self.run_end_webhooks, {
|
|
|
|
|
|
|
|
"event": "run_end",
|
|
|
|
"start_time": start_time.strftime("%Y-%m-%d %H:%M:%S"),
|
|
|
|
"start_time": start_time.strftime("%Y-%m-%d %H:%M:%S"),
|
|
|
|
"end_time": end_time.strftime("%Y-%m-%d %H:%M:%S"),
|
|
|
|
"end_time": end_time.strftime("%Y-%m-%d %H:%M:%S"),
|
|
|
|
"run_time": run_time,
|
|
|
|
"run_time": run_time,
|
|
|
@ -99,7 +100,7 @@ class Webhooks:
|
|
|
|
|
|
|
|
|
|
|
|
def error_hooks(self, text, server=None, library=None, collection=None, playlist=None, critical=True):
|
|
|
|
def error_hooks(self, text, server=None, library=None, collection=None, playlist=None, critical=True):
|
|
|
|
if self.error_webhooks:
|
|
|
|
if self.error_webhooks:
|
|
|
|
json = {"error": str(text), "critical": critical}
|
|
|
|
json = {"event": "error", "error": str(text), "critical": critical}
|
|
|
|
if server: json["server_name"] = str(server)
|
|
|
|
if server: json["server_name"] = str(server)
|
|
|
|
if library: json["library_name"] = str(library)
|
|
|
|
if library: json["library_name"] = str(library)
|
|
|
|
if collection: json["collection"] = str(collection)
|
|
|
|
if collection: json["collection"] = str(collection)
|
|
|
@ -108,7 +109,7 @@ class Webhooks:
|
|
|
|
|
|
|
|
|
|
|
|
def delete_hooks(self, message, server=None, library=None):
|
|
|
|
def delete_hooks(self, message, server=None, library=None):
|
|
|
|
if self.delete_webhooks:
|
|
|
|
if self.delete_webhooks:
|
|
|
|
json = {"message": message}
|
|
|
|
json = {"event": "delete", "message": message}
|
|
|
|
if server: json["server_name"] = str(server)
|
|
|
|
if server: json["server_name"] = str(server)
|
|
|
|
if library: json["library_name"] = str(library)
|
|
|
|
if library: json["library_name"] = str(library)
|
|
|
|
self._request(self.delete_webhooks, json)
|
|
|
|
self._request(self.delete_webhooks, json)
|
|
|
@ -123,6 +124,7 @@ class Webhooks:
|
|
|
|
if not playlist and not background_url and collection.art and next((f for f in collection.fields if f.name == "art"), None):
|
|
|
|
if not playlist and not background_url and collection.art and next((f for f in collection.fields if f.name == "art"), None):
|
|
|
|
art = self.config.get_image_encoded(f"{self.library.url}{collection.art}?X-Plex-Token={self.library.token}")
|
|
|
|
art = self.config.get_image_encoded(f"{self.library.url}{collection.art}?X-Plex-Token={self.library.token}")
|
|
|
|
self._request(webhooks, {
|
|
|
|
self._request(webhooks, {
|
|
|
|
|
|
|
|
"event": "changes",
|
|
|
|
"server_name": self.library.PlexServer.friendlyName,
|
|
|
|
"server_name": self.library.PlexServer.friendlyName,
|
|
|
|
"library_name": self.library.name,
|
|
|
|
"library_name": self.library.name,
|
|
|
|
"playlist" if playlist else "collection": collection.title,
|
|
|
|
"playlist" if playlist else "collection": collection.title,
|
|
|
|