Add quotation support for Ignore Tags field
- Update field description and placeholder to show quotation usage - Add _parse_tags() static method to parse comma-separated tags with quote support - Support both single and double quotes to preserve spaces and special characters - Update all ignore_tags parsing locations to use new helper function - Examples: "4K, \" East\", \"[Dead]\"" -> ["4K", " East", "[Dead]"]
This commit is contained in:
@@ -92,8 +92,8 @@ class Plugin:
|
|||||||
"label": "🏷️ Ignore Tags (comma-separated)",
|
"label": "🏷️ Ignore Tags (comma-separated)",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "",
|
"default": "",
|
||||||
"placeholder": "4K, [4K], [Dead]",
|
"placeholder": "4K, [4K], \" East\", \"[Dead]\"",
|
||||||
"help_text": "Tags to ignore when matching streams. Space-separated in channel names unless they contain brackets/parentheses.",
|
"help_text": "Tags to ignore when matching streams. Use quotes to preserve spaces/special chars (e.g., \" East\" for tags with leading space).",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "ignore_quality_tags",
|
"id": "ignore_quality_tags",
|
||||||
@@ -381,6 +381,69 @@ class Plugin:
|
|||||||
logger.warning(f"[Stream-Mapparr] Could not trigger frontend refresh: {e}")
|
logger.warning(f"[Stream-Mapparr] Could not trigger frontend refresh: {e}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _parse_tags(tags_str):
|
||||||
|
"""
|
||||||
|
Parse comma-separated tags with support for quoted strings.
|
||||||
|
|
||||||
|
Supports both single and double quotes to preserve spaces and special characters.
|
||||||
|
Examples:
|
||||||
|
"4K, HD, FHD" -> ["4K", "HD", "FHD"]
|
||||||
|
"4K, \" East\", \"[Dead]\"" -> ["4K", " East", "[Dead]"]
|
||||||
|
"4K, ' West', \"(Backup)\"" -> ["4K", " West", "(Backup)"]
|
||||||
|
|
||||||
|
Args:
|
||||||
|
tags_str: String containing comma-separated tags (with optional quotes)
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
List of parsed tags
|
||||||
|
"""
|
||||||
|
if not tags_str or not tags_str.strip():
|
||||||
|
return []
|
||||||
|
|
||||||
|
tags = []
|
||||||
|
current_tag = []
|
||||||
|
in_quote = None # None, '"', or "'"
|
||||||
|
i = 0
|
||||||
|
|
||||||
|
while i < len(tags_str):
|
||||||
|
char = tags_str[i]
|
||||||
|
|
||||||
|
# Handle quote start/end
|
||||||
|
if char in ('"', "'") and (in_quote is None or in_quote == char):
|
||||||
|
if in_quote is None:
|
||||||
|
in_quote = char # Start quote
|
||||||
|
else:
|
||||||
|
in_quote = None # End quote
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Handle comma (separator) outside of quotes
|
||||||
|
if char == ',' and in_quote is None:
|
||||||
|
tag = ''.join(current_tag)
|
||||||
|
# Only strip if tag wasn't quoted
|
||||||
|
tag = tag.strip()
|
||||||
|
if tag:
|
||||||
|
tags.append(tag)
|
||||||
|
current_tag = []
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Regular character
|
||||||
|
current_tag.append(char)
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
# Add final tag
|
||||||
|
if current_tag or in_quote is not None:
|
||||||
|
tag = ''.join(current_tag)
|
||||||
|
# Only strip if tag wasn't quoted
|
||||||
|
if in_quote is None:
|
||||||
|
tag = tag.strip()
|
||||||
|
if tag:
|
||||||
|
tags.append(tag)
|
||||||
|
|
||||||
|
return tags
|
||||||
|
|
||||||
def _clean_channel_name(self, name, ignore_tags=None, ignore_quality=True, ignore_regional=True,
|
def _clean_channel_name(self, name, ignore_tags=None, ignore_quality=True, ignore_regional=True,
|
||||||
ignore_geographic=True, ignore_misc=True, remove_cinemax=False):
|
ignore_geographic=True, ignore_misc=True, remove_cinemax=False):
|
||||||
"""
|
"""
|
||||||
@@ -904,8 +967,8 @@ class Plugin:
|
|||||||
|
|
||||||
ignore_tags_str = settings.get("ignore_tags", "").strip()
|
ignore_tags_str = settings.get("ignore_tags", "").strip()
|
||||||
if ignore_tags_str:
|
if ignore_tags_str:
|
||||||
ignore_tags = [tag.strip() for tag in ignore_tags_str.split(',') if tag.strip()]
|
ignore_tags = self._parse_tags(ignore_tags_str)
|
||||||
validation_results.append(f"ℹ️ Ignore Tags: {len(ignore_tags)} tag(s) configured: {', '.join(ignore_tags)}")
|
validation_results.append(f"ℹ️ Ignore Tags: {len(ignore_tags)} tag(s) configured: {', '.join(repr(tag) for tag in ignore_tags)}")
|
||||||
else:
|
else:
|
||||||
validation_results.append("ℹ️ Ignore Tags: None configured")
|
validation_results.append("ℹ️ Ignore Tags: None configured")
|
||||||
|
|
||||||
@@ -981,7 +1044,7 @@ class Plugin:
|
|||||||
# Parse ignore tags
|
# Parse ignore tags
|
||||||
ignore_tags = []
|
ignore_tags = []
|
||||||
if ignore_tags_str:
|
if ignore_tags_str:
|
||||||
ignore_tags = [tag.strip() for tag in ignore_tags_str.split(',') if tag.strip()]
|
ignore_tags = self._parse_tags(ignore_tags_str)
|
||||||
logger.info(f"[Stream-Mapparr] Ignore tags configured: {ignore_tags}")
|
logger.info(f"[Stream-Mapparr] Ignore tags configured: {ignore_tags}")
|
||||||
|
|
||||||
# Log category settings
|
# Log category settings
|
||||||
|
|||||||
Reference in New Issue
Block a user