parent
27797cb361
commit
762e5f10da
|
|
@ -4,8 +4,8 @@ from dotenv import load_dotenv
|
||||||
|
|
||||||
load_dotenv(override=True)
|
load_dotenv(override=True)
|
||||||
|
|
||||||
logfile = os.getenv("LOGFILE", "log.log")
|
log_file = os.getenv("LOG_FILE", os.getenv("LOGFILE", "log.log"))
|
||||||
markfile = os.getenv("MARKFILE", "mark.log")
|
mark_file = os.getenv("MARK_FILE", os.getenv("MARKFILE", "mark.log"))
|
||||||
|
|
||||||
|
|
||||||
def logger(message: str, log_type=0):
|
def logger(message: str, log_type=0):
|
||||||
|
|
@ -32,14 +32,14 @@ def logger(message: str, log_type=0):
|
||||||
|
|
||||||
if output is not None:
|
if output is not None:
|
||||||
print(output)
|
print(output)
|
||||||
file = open(logfile, "a", encoding="utf-8")
|
with open(f"{log_file}", "a", encoding="utf-8") as file:
|
||||||
file.write(output + "\n")
|
file.write(output + "\n")
|
||||||
|
|
||||||
|
|
||||||
def log_marked(
|
def log_marked(
|
||||||
username: str, library: str, movie_show: str, episode: str = None, duration=None
|
username: str, library: str, movie_show: str, episode: str = None, duration=None
|
||||||
):
|
):
|
||||||
if markfile is None:
|
if mark_file is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
output = f"{username}/{library}/{movie_show}"
|
output = f"{username}/{library}/{movie_show}"
|
||||||
|
|
@ -50,8 +50,8 @@ def log_marked(
|
||||||
if duration:
|
if duration:
|
||||||
output += f"/{duration}"
|
output += f"/{duration}"
|
||||||
|
|
||||||
file = open(f"{markfile}", "a", encoding="utf-8")
|
with open(f"{mark_file}", "a", encoding="utf-8") as file:
|
||||||
file.write(output + "\n")
|
file.write(output + "\n")
|
||||||
|
|
||||||
|
|
||||||
# Reimplementation of distutils.util.strtobool due to it being deprecated
|
# Reimplementation of distutils.util.strtobool due to it being deprecated
|
||||||
|
|
|
||||||
|
|
@ -262,10 +262,10 @@ def should_sync_server(server_1_type, server_2_type):
|
||||||
|
|
||||||
|
|
||||||
def main_loop():
|
def main_loop():
|
||||||
logfile = os.getenv("LOGFILE", "log.log")
|
log_file = os.getenv("LOG_FILE", os.getenv("LOGFILE", "log.log"))
|
||||||
# Delete logfile if it exists
|
# Delete log_file if it exists
|
||||||
if os.path.exists(logfile):
|
if os.path.exists(log_file):
|
||||||
os.remove(logfile)
|
os.remove(log_file)
|
||||||
|
|
||||||
dryrun = str_to_bool(os.getenv("DRYRUN", "False"))
|
dryrun = str_to_bool(os.getenv("DRYRUN", "False"))
|
||||||
logger(f"Dryrun: {dryrun}", 1)
|
logger(f"Dryrun: {dryrun}", 1)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue