[40] add log-requests env variable

pull/1294/head
meisnate12 2 years ago
parent da3c93c5cd
commit adf5f84ffd

@ -1 +1 @@
1.18.3-develop39 1.18.3-develop40

@ -430,8 +430,8 @@ translations:
audio_language_other_summary: <<library_translationU>>s filmed in other uncommon Languages. audio_language_other_summary: <<library_translationU>>s filmed in other uncommon Languages.
# possible key_names: Book, Comic, True Story, Video Game # possible key_names: Book, Comic, True Story, Video Game
basedon_name: Based on a <<translated_key_name>> based_name: Based on a <<translated_key_name>>
basedon_summary: <<library_translationU>>s based on or inspired by <<translated_key_name>>s. based_summary: <<library_translationU>>s based on or inspired by <<translated_key_name>>s.
collectionless_name: Collectionless collectionless_name: Collectionless
collectionless_summary: Collection of <<library_translationU>>s used to make Plex display items correctly. collectionless_summary: Collection of <<library_translationU>>s used to make Plex display items correctly.

@ -14,6 +14,7 @@ These docs are assuming you have a basic understanding of Docker concepts. One
| [Run Tests](#run-tests) | `-rt`, `--tests`, or `--run-tests` | `PMM_TEST` | | [Run Tests](#run-tests) | `-rt`, `--tests`, or `--run-tests` | `PMM_TEST` |
| [Debug](#debug) | `-db` or `--debug` | `PMM_DEBUG` | | [Debug](#debug) | `-db` or `--debug` | `PMM_DEBUG` |
| [Trace](#trace) | `-tr` or `--trace` | `PMM_TRACE` | | [Trace](#trace) | `-tr` or `--trace` | `PMM_TRACE` |
| [Log Requests](#log-requests) | `-lr` or `--log-requests` | `PMM_LOG_REQUESTS` |
| [Timeout](#timeout) | `-ti` or `--timeout` | `PMM_TIMEOUT` | | [Timeout](#timeout) | `-ti` or `--timeout` | `PMM_TIMEOUT` |
| [Collections Only](#collections-only) | `-co` or `--collections-only` | `PMM_COLLECTIONS_ONLY` | | [Collections Only](#collections-only) | `-co` or `--collections-only` | `PMM_COLLECTIONS_ONLY` |
| [Playlists Only](#playlists-only) | `-po` or `--playlists-only` | `PMM_PLAYLISTS_ONLY` | | [Playlists Only](#playlists-only) | `-po` or `--playlists-only` | `PMM_PLAYLISTS_ONLY` |
@ -257,7 +258,40 @@ python plex_meta_manager.py --trace
```` ````
````{tab} Docker Environment ````{tab} Docker Environment
``` ```
docker run -it -v "X:\Media\Plex Meta Manager\config:/config:rw" meisnate12/plex-meta-manager --trace0 docker run -it -v "X:\Media\Plex Meta Manager\config:/config:rw" meisnate12/plex-meta-manager --trace
```
````
### Log Requests
Run with every network request printed to the Logs. **This can potentially have personal information in it.**
<table class="dualTable colwidths-auto align-default table">
<tr>
<th style="background-color: #1d1d1d;"></th>
<th>Shell</th>
<th>Environment</th>
</tr>
<tr>
<th>Flags</th>
<td><code>-lr</code> or <code>--log-request</code> or <code>--log-requests</code></td>
<td><code>PMM_LOG_REQUESTS</code></td>
</tr>
<tr>
<th>Example</th>
<td><code>--log-requests</code></td>
<td><code>PMM_NETWORK=true</code></td>
</tr>
</table>
````{tab} Local Environment
```
python plex_meta_manager.py --log-requests
```
````
````{tab} Docker Environment
```
docker run -it -v "X:\Media\Plex Meta Manager\config:/config:rw" meisnate12/plex-meta-manager --log-requests
``` ```
```` ````

@ -2100,6 +2100,28 @@ class CollectionBuilder:
return util.validate_regex(data, self.Type, validate=validate) return util.validate_regex(data, self.Type, validate=validate)
elif attribute in string_attributes and modifier in ["", ".not", ".is", ".isnot", ".begins", ".ends"]: elif attribute in string_attributes and modifier in ["", ".not", ".is", ".isnot", ".begins", ".ends"]:
return smart_pair(util.get_list(data, split=False)) return smart_pair(util.get_list(data, split=False))
elif attribute in year_attributes and modifier in ["", ".not", ".gt", ".gte", ".lt", ".lte"]:
if modifier in ["", ".not"]:
final_years = []
values = util.get_list(data)
for value in values:
if str(value).startswith("current_year"):
year_values = str(value).split("-")
try:
final_years.append(datetime.now().year - (0 if len(year_values) == 1 else int(year_values[1].strip())))
except ValueError:
raise Failed(f"{self.Type} Error: {final} attribute modifier invalid '{year_values[1]}'")
else:
final_years.append(util.parse(self.Type, final, value, datatype="int"))
return smart_pair(final_years)
else:
if str(data).startswith("current_year"):
year_values = str(data).split("-")
try:
return datetime.now().year - (0 if len(year_values) == 1 else int(year_values[1].strip()))
except ValueError:
raise Failed(f"{self.Type} Error: {final} attribute modifier invalid '{year_values[1]}'")
return util.parse(self.Type, final, data, datatype="int", minimum=0)
elif (attribute in number_attributes and modifier in ["", ".not", ".gt", ".gte", ".lt", ".lte"]) \ elif (attribute in number_attributes and modifier in ["", ".not", ".gt", ".gte", ".lt", ".lte"]) \
or (attribute in tag_attributes and modifier in [".count_gt", ".count_gte", ".count_lt", ".count_lte"]): or (attribute in tag_attributes and modifier in [".count_gt", ".count_gte", ".count_lt", ".count_lte"]):
return util.parse(self.Type, final, data, datatype="int", minimum=0) return util.parse(self.Type, final, data, datatype="int", minimum=0)
@ -2174,28 +2196,6 @@ class CollectionBuilder:
return datetime.strftime(datetime.now(), "%Y-%m-%d") return datetime.strftime(datetime.now(), "%Y-%m-%d")
else: else:
return util.validate_date(data, final, return_as="%Y-%m-%d") return util.validate_date(data, final, return_as="%Y-%m-%d")
elif attribute in year_attributes and modifier in ["", ".not", ".gt", ".gte", ".lt", ".lte"]:
if modifier in ["", ".not"]:
final_years = []
values = util.get_list(data)
for value in values:
if str(value).startswith("current_year"):
year_values = str(value).split("-")
try:
final_years.append(datetime.now().year - (0 if len(year_values) == 1 else int(year_values[1].strip())))
except ValueError:
raise Failed(f"{self.Type} Error: {final} attribute modifier invalid '{year_values[1]}'")
else:
final_years.append(util.parse(self.Type, final, value, datatype="int"))
return smart_pair(final_years)
else:
if str(data).startswith("current_year"):
year_values = str(data).split("-")
try:
return datetime.now().year - (0 if len(year_values) == 1 else int(year_values[1].strip()))
except ValueError:
raise Failed(f"{self.Type} Error: {final} attribute modifier invalid '{year_values[1]}'")
return util.parse(self.Type, final, data, datatype="int", minimum=0)
elif attribute in date_attributes and modifier in ["", ".not"]: elif attribute in date_attributes and modifier in ["", ".not"]:
search_mod = "d" search_mod = "d"
if plex_search and data and str(data)[-1] in ["s", "m", "h", "d", "w", "o", "y"]: if plex_search and data and str(data)[-1] in ["s", "m", "h", "d", "w", "o", "y"]:

@ -29,13 +29,14 @@ _srcfile = os.path.normcase(fmt_filter.__code__.co_filename)
class MyLogger: class MyLogger:
def __init__(self, logger_name, default_dir, screen_width, separating_character, ignore_ghost, is_debug, is_trace): def __init__(self, logger_name, default_dir, screen_width, separating_character, ignore_ghost, is_debug, is_trace, log_requests):
self.logger_name = logger_name self.logger_name = logger_name
self.default_dir = default_dir self.default_dir = default_dir
self.screen_width = screen_width self.screen_width = screen_width
self.separating_character = separating_character self.separating_character = separating_character
self.is_debug = is_debug self.is_debug = is_debug
self.is_trace = is_trace self.is_trace = is_trace
self.log_requests = log_requests
self.ignore_ghost = ignore_ghost self.ignore_ghost = ignore_ghost
self.log_dir = os.path.join(default_dir, LOG_DIR) self.log_dir = os.path.join(default_dir, LOG_DIR)
self.playlists_dir = os.path.join(self.log_dir, PLAYLIST_DIR) self.playlists_dir = os.path.join(self.log_dir, PLAYLIST_DIR)
@ -51,7 +52,7 @@ class MyLogger:
self.spacing = 0 self.spacing = 0
self.playlists_log = os.path.join(self.playlists_dir, PLAYLISTS_LOG) self.playlists_log = os.path.join(self.playlists_dir, PLAYLISTS_LOG)
os.makedirs(self.log_dir, exist_ok=True) os.makedirs(self.log_dir, exist_ok=True)
self._logger = logging.getLogger(self.logger_name) self._logger = logging.getLogger(None if self.log_requests else self.logger_name)
self._logger.setLevel(logging.DEBUG) self._logger.setLevel(logging.DEBUG)
cmd_handler = logging.StreamHandler() cmd_handler = logging.StreamHandler()

@ -21,6 +21,7 @@ if sys.version_info[0] != 3 or sys.version_info[1] < 7:
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("-db", "--debug", dest="debug", help="Run with Debug Logs Reporting to the Command Window", action="store_true", default=False) parser.add_argument("-db", "--debug", dest="debug", help="Run with Debug Logs Reporting to the Command Window", action="store_true", default=False)
parser.add_argument("-tr", "--trace", dest="trace", help="Run with extra Trace Debug Logs", action="store_true", default=False) parser.add_argument("-tr", "--trace", dest="trace", help="Run with extra Trace Debug Logs", action="store_true", default=False)
parser.add_argument("-lr", "--log-request", "log-requests", dest="log_requests", help="Run with all Requests printed", action="store_true", default=False)
parser.add_argument("-c", "--config", dest="config", help="Run with desired *.yml file", type=str) parser.add_argument("-c", "--config", dest="config", help="Run with desired *.yml file", type=str)
parser.add_argument("-t", "--time", "--times", dest="times", help="Times to update each day use format HH:MM (Default: 05:00) (comma-separated list)", default="05:00", type=str) parser.add_argument("-t", "--time", "--times", dest="times", help="Times to update each day use format HH:MM (Default: 05:00) (comma-separated list)", default="05:00", type=str)
parser.add_argument("-ti", "--timeout", dest="timeout", help="PMM Global Timeout (Default: 180)", default=180, type=int) parser.add_argument("-ti", "--timeout", dest="timeout", help="PMM Global Timeout (Default: 180)", default=180, type=int)
@ -118,6 +119,7 @@ screen_width = get_arg("PMM_WIDTH", args.width, arg_int=True)
timeout = get_arg("PMM_TIMEOUT", args.timeout, arg_int=True) timeout = get_arg("PMM_TIMEOUT", args.timeout, arg_int=True)
debug = get_arg("PMM_DEBUG", args.debug, arg_bool=True) debug = get_arg("PMM_DEBUG", args.debug, arg_bool=True)
trace = get_arg("PMM_TRACE", args.trace, arg_bool=True) trace = get_arg("PMM_TRACE", args.trace, arg_bool=True)
log_requests = get_arg("PMM_LOG_REQUESTS", args.log_requests, arg_bool=True)
plex_url = get_arg("PMM_PLEX_URL", args.plex_url) plex_url = get_arg("PMM_PLEX_URL", args.plex_url)
plex_token = get_arg("PMM_PLEX_TOKEN", args.plex_token) plex_token = get_arg("PMM_PLEX_TOKEN", args.plex_token)
@ -138,7 +140,7 @@ elif not os.path.exists(os.path.join(default_dir, "config.yml")):
print(f"Config Error: config not found at {os.path.abspath(default_dir)}") print(f"Config Error: config not found at {os.path.abspath(default_dir)}")
sys.exit(0) sys.exit(0)
logger = MyLogger("Plex Meta Manager", default_dir, screen_width, divider[0], ignore_ghost, test or debug, trace) logger = MyLogger("Plex Meta Manager", default_dir, screen_width, divider[0], ignore_ghost, test or debug, trace, log_requests)
from modules import util from modules import util
util.logger = logger util.logger = logger

Loading…
Cancel
Save