[167] add default to template_variables

pull/1146/head
meisnate12 2 years ago
parent 42a67e6a08
commit b1d30d7913

@ -1 +1 @@
1.17.3-develop166
1.17.3-develop167

@ -15,6 +15,7 @@ external_templates:
conditions:
- style: standard
value: <<standard_value>>
default:
standard_value: 105
style: compact
group: audio_codec

@ -19,6 +19,7 @@ external_templates:
conditions:
- overlay_name: NR
value: <<post_nr_text>>
default:
key: <<overlay_name>>
pre_text: ""
post_text: "+"

@ -8,11 +8,12 @@
external_templates:
pmm: templates
template_variables:
queue: position
limit: 10
limit_<<key>>: <<limit>>
default:
pre_text: TOP
style: round
limit: 10
limit_<<key>>: <<limit>>
queue: position
back_color: "#00000099"
back_width: 160
back_height: 160

@ -30,13 +30,14 @@ external_templates:
value: 26
- style: square
value:
default:
style: round
country: <<key>>
country_<<key>>: <<country>>
offset: 10
queue: position
pmm: flag/<<final_style>>/<<country_<<key>>>>
addon_position: <<final_align>>
offset: 10
addon_offset: <<offset>>
back_color: "#00000099"
back_width: 190
@ -55,15 +56,15 @@ queues:
left:
- horizontal_align: left
- vertical_offset: 75
- vertical_offset: 136
- vertical_offset: 197
- vertical_offset: 258
- vertical_offset: 137
- vertical_offset: 199
- vertical_offset: 261
right:
- horizontal_align: right
- vertical_offset: 75
- vertical_offset: 136
- vertical_offset: 197
- vertical_offset: 258
- vertical_offset: 137
- vertical_offset: 199
- vertical_offset: 261
templates:
flags:

@ -99,7 +99,6 @@ external_templates:
value: edition
- type: [resolution, resolution_dovetail]
value: resolution
horizontal_align: left
vertical_align: top

@ -9,6 +9,7 @@
external_templates:
pmm: templates
template_variables:
default:
text_<<key>>: <<overlay_name>>
group: quality
horizontal_offset: 15

@ -134,7 +134,7 @@ All [Shared Overlay Variables](variables) are available with the default values
| `style` | **Description:** Controls the visual theme of the overlays created.<table class="clearTable"><tr><th>Values:</th></tr><tr><td><code>round</code></td><td>Round Theme</td></tr><tr><td><code>square</code></td><td>Square Theme</td></tr><tr><td><code>half</code></td><td>Square Flag with Round Background</td></tr></table> |
| `offset` | **Description:** Controls the offset between the flag and the text.<br>**Default:** `10`<br>**Values:** Any Integer 0 or greater |
| `align` | **Description:** Controls the flag alignment in the backdrop.<br>**Default:** `left`<br>**Values:** `left` or `right` |
| `country_<<key>>`<sup>1</sup> | **Description:** Controls the country image for the Overlay.<br>**Default:** Listed in the [Table](#supported-audio-subtitle-language-flags) above<br>**Values:** [ISO 3166-1 Country Code](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes) for the flag desired |
| `country_<<key>>`<sup>1</sup> | **Description:** Controls the country image for the Overlay.<br>**Default:** Listed in the [Table](#supported-audiosubtitle-language-flags) above<br>**Values:** [ISO 3166-1 Country Code](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes) for the flag desired |
| `use_lowercase` | **Description:** Controls if the overlay display is in lowercase.<br>**Values:** `true` to use lowercase text |
| `use_subtitles` | **Description:** Controls if the overlay is based on subtitle language instead of audio language.<br>**Values:** `true` to look at subtitle language instead of audio language |
| `overlay_level` | **Description:** Choose the Overlay Level.<br>**Values:** `season` or `episode` |

@ -17,6 +17,7 @@ WARNING = 30
WARN = WARNING
INFO = 20
DEBUG = 10
TRACE = 0
def fmt_filter(record):
@ -182,7 +183,7 @@ class MyLogger:
def trace(self, msg, *args, **kwargs):
if self.is_trace:
self._log(DEBUG, str(msg), args, **kwargs)
self._log(TRACE, str(msg), args, **kwargs)
def error(self, msg, *args, **kwargs):
if self.save_errors:
@ -229,6 +230,16 @@ class MyLogger:
self.secrets.append(str(text))
def _log(self, level, msg, args, exc_info=None, extra=None, stack_info=False, stacklevel=1):
trace = False
original_format_str = "[%(asctime)s] %(filename)-27s %(levelname)-10s | %(message)s"
format_str = original_format_str
if level == TRACE:
trace = True
level = DEBUG
format_str = "[%(asctime)s] %(filename)-27s [TRACE] | %(message)s"
for handler in self._logger.handlers:
if isinstance(handler, RotatingFileHandler):
handler.setFormatter(logging.Formatter(format_str))
if self.spacing > 0:
self.exorcise()
if "\n" in msg:
@ -240,7 +251,7 @@ class MyLogger:
handler.setFormatter(logging.Formatter(" " * 65 + "| %(message)s"))
for handler in self._logger.handlers:
if isinstance(handler, RotatingFileHandler):
handler.setFormatter(logging.Formatter("[%(asctime)s] %(filename)-27s %(levelname)-10s | %(message)s"))
handler.setFormatter(logging.Formatter(format_str))
else:
for secret in self.secrets:
if secret in msg:
@ -262,6 +273,10 @@ class MyLogger:
exc_info = sys.exc_info()
record = self._logger.makeRecord(self._logger.name, level, fn, lno, msg, args, exc_info, func, extra, sinfo)
self._logger.handle(record)
if trace:
for handler in self._logger.handlers:
if isinstance(handler, RotatingFileHandler):
handler.setFormatter(logging.Formatter(original_format_str))
def findCaller(self, stack_info=False, stacklevel=1):
f = logging.currentframe()

@ -245,6 +245,13 @@ class DataFile:
conditionals[ck] = cv
added_vars = {}
init_defaults = {}
if "default" in template:
if not template["default"]:
raise Failed(f"{self.data_type} Error: template sub-attribute default is blank")
if not isinstance(template["default"], dict):
raise Failed(f"{self.data_type} Error: template sub-attribute default is not a dictionary")
init_defaults = template["default"]
for input_dict, input_type, overwrite_call in [
(temp_vars, "External", False),
(extra_variables, "Definition", False),
@ -260,6 +267,13 @@ class DataFile:
raise Failed(f"{self.data_type} Error: {input_type} template sub-attribute conditionals is not a dictionary")
for ck, cv in input_value.items():
conditionals[ck] = cv
elif input_key == "default":
if not input_value:
raise Failed(f"{self.data_type} Error: {input_type} template sub-attribute default is blank")
if not isinstance(input_value, dict):
raise Failed(f"{self.data_type} Error: {input_type} template sub-attribute default is not a dictionary")
for dk, dv in input_value.items():
init_defaults[dk] = dv
elif input_value is None:
optional.append(str(input_key))
elif overwrite_call:
@ -295,17 +309,12 @@ class DataFile:
return_item = str(return_item).replace(f"<<{rk}>>", str(rv))
return return_item
ini_default = {}
default = {}
if "default" in template:
if not template["default"]:
raise Failed(f"{self.data_type} Error: template sub-attribute default is blank")
if not isinstance(template["default"], dict):
raise Failed(f"{self.data_type} Error: template sub-attribute default is not a dictionary")
ini_default = {replace_var(dv, variables): replace_var(template["default"][dv], variables) for dv in template["default"] if dv not in variables}
for dkey, dvalue in ini_default.items():
final_key = replace_var(dkey, ini_default)
final_value = replace_var(dvalue, ini_default)
if init_defaults:
var_default = {replace_var(dk, variables): replace_var(dv, variables) for dk, dv in init_defaults.items() if dk not in variables}
for dkey, dvalue in var_default.items():
final_key = replace_var(dkey, var_default)
final_value = replace_var(dvalue, var_default)
if final_key not in optional and final_key not in variables and final_key not in conditionals:
default[final_key] = final_value
default[f"{final_key}_encoded"] = requests.utils.quote(str(final_value))
@ -491,7 +500,9 @@ class DataFile:
except Failed:
continue
logger.debug("")
logger.debug(f"Final Template Attributes: {new_attributes}")
logger.separator(f"Final Template Attributes", space=False, border=False, debug=True)
logger.debug("")
logger.debug(new_attributes)
logger.debug("")
return new_attributes

Loading…
Cancel
Save