diff --git a/README.md b/README.md index 08d8801..abf761f 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,8 @@ --- - [![made-with-python](https://img.shields.io/badge/Made%20with-Python-blue.svg)](https://www.python.org/) [![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://github.com/l3uddz/traktarr/blob/master/LICENSE) +[![made-with-python](https://img.shields.io/badge/Made%20with-Python-blue.svg)](https://www.python.org/) +[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://github.com/l3uddz/traktarr/blob/master/LICENSE) [![Feature Requests](https://img.shields.io/badge/Requests-Feathub-blue.svg)](http://feathub.com/l3uddz/traktarr) [![Discord](https://img.shields.io/discord/381077432285003776.svg)](https://discord.gg/xmNYmSJ) @@ -606,49 +607,46 @@ Sonarr configuration. ### Tags -To show how tags work, we will create a sample tag `AMZN` and assign it to certain networks. +The `tags` option allows Sonarr to assign tags to shows from specific television networks, so that Sonarr can filter in/out certain keywords from releases. -_Note: These are optional._ +**Example:** -### Sonarr +To show how tags work, we will create a tag `AMZN` and assign it to certain television networks that usually have AMZN releases. -First, we will create a tag in Sonarr (Settings > Indexers > Restrictions). +1. First, we will create a tag in Sonarr (Settings > Indexers > Restrictions). -``` -Must contain: BluRay, Amazon, AMZN, -Must not contain: -Tags: AMZN -``` - -### traktarr - -Finally, we will edit the traktarr config and assign the `AMZN` tag to certain networks. - -```json -"tags": { - "amzn": [ - "hbo", - "amc", - "usa network", - "tnt", - "starz", - "the cw", - "fx", - "fox", - "abc", - "nbc", - "cbs", - "tbs", - "amazon", - "syfy", - "cinemax", - "bravo", - "showtime", - "paramount network" - ] -} + ``` + Must contain: BluRay, Amazon, AMZN + Must not contain: + Tags: AMZN + ``` -``` +2. And, finally, we will edit the traktarr config and assign the `AMZN` tag to some networks. + + ```json + "tags": { + "amzn": [ + "hbo", + "amc", + "usa network", + "tnt", + "starz", + "the cw", + "fx", + "fox", + "abc", + "nbc", + "cbs", + "tbs", + "amazon", + "syfy", + "cinemax", + "bravo", + "showtime", + "paramount network" + ] + } + ``` ## Trakt diff --git a/traktarr.py b/traktarr.py index b846e66..250f618 100755 --- a/traktarr.py +++ b/traktarr.py @@ -2,6 +2,7 @@ import os.path import sys import time +import signal import click import schedule @@ -703,13 +704,19 @@ def init_notifications(): return +# Handles exit signals, cancels jobs and exits cleanly +def exit_handler(signum, frame): + log.info(f"Received {signal.Signals(signum).name}, canceling jobs and exiting.") + schedule.clear() + exit() + + ############################################################ # MAIN ############################################################ if __name__ == "__main__": print(""" - ,--. ,--. ,--. ,-' '-.,--.--. ,--,--.| |,-.,-' '-. ,--,--.,--.--.,--.--. '-. .-'| .--'' ,-. || /'-. .-'' ,-. || .--'| .--' @@ -724,5 +731,11 @@ if __name__ == "__main__": ######################################################################### # GNU General Public License v3.0 # ######################################################################### - """) +""") + + # Register the signal handlers + signal.signal(signal.SIGTERM, exit_handler) + signal.signal(signal.SIGINT, exit_handler) + + # Start application app()