Add mark list support

This commit is contained in:
Luigi311
2023-11-13 01:12:08 -07:00
parent 76ac264b25
commit df13cef760
4 changed files with 165 additions and 81 deletions

View File

@@ -5,6 +5,7 @@ from dotenv import load_dotenv
load_dotenv(override=True)
logfile = os.getenv("LOGFILE", "log.log")
markfile = os.getenv("MARK_FILE", "mark.log")
def logger(message: str, log_type=0):
@@ -31,6 +32,24 @@ def logger(message: str, log_type=0):
file.write(output + "\n")
def log_marked(
username: str, library: str, movie_show: str, episode: str = None, duration=None
):
if markfile is None:
return
output = f"{username}/{library}/{movie_show}"
if episode:
output += f"/{episode}"
if duration:
output += f"/{duration}"
file = open(f"{markfile}", "a", encoding="utf-8")
file.write(output + "\n")
# Reimplementation of distutils.util.strtobool due to it being deprecated
# Source: https://github.com/PostHog/posthog/blob/01e184c29d2c10c43166f1d40a334abbc3f99d8a/posthog/utils.py#L668
def str_to_bool(value: any) -> bool: