diff --git a/plexorcist.py b/plexorcist.py index e8545db..53c1344 100755 --- a/plexorcist.py +++ b/plexorcist.py @@ -1,6 +1,7 @@ #!/usr/bin/env python """Main Plexorcist execution file!""" +import os import configparser import functools from datetime import datetime, timedelta @@ -10,6 +11,12 @@ import requests import xmltodict +# Get the absolute path of the directory containing the script +script_dir = os.path.dirname(os.path.abspath(__file__)) + +# Construct the absolute path of the INI file +config_file_path = os.path.join(script_dir, "plexorcist.ini") + # Read the config file config = configparser.ConfigParser() config.read("plexorcist.ini") @@ -31,7 +38,8 @@ I18N[option] = config.get("i18n", option) # Set the log file name -LOG_FILE = "plexorcist.log" +log_file_path = os.path.join(script_dir, "plexorcist.log") +LOG_FILE = log_file_path # Create a rotating file handler with a maximum size of 1 MB handler = RotatingFileHandler(LOG_FILE, maxBytes=1024 * 1024, backupCount=2)