From 19c44cce5c50278ec719ace0da251fdcbd627185 Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Wed, 7 Sep 2022 10:59:24 -0700 Subject: [PATCH] fix dupes --- src/ytdl_sub/validators/nfo_validators.py | 36 +++++++++---------- .../plugins/nfo_tags/test_nfo_kodi_safe.txt | 24 ------------- 2 files changed, 17 insertions(+), 43 deletions(-) diff --git a/src/ytdl_sub/validators/nfo_validators.py b/src/ytdl_sub/validators/nfo_validators.py index ef254a03..3b013553 100644 --- a/src/ytdl_sub/validators/nfo_validators.py +++ b/src/ytdl_sub/validators/nfo_validators.py @@ -112,25 +112,23 @@ class SharedNfoTagsValidator( if not isinstance(tag_value, list): tag_value = [tag_value] - # iterate each list, validate accordingly if it is a string tag or attribute tag - for tag_value_i in tag_value: - if isinstance(tag_value_i, str): - self._string_tags[key].extend( - self._validate_key( - key=key, - validator=self._tags_validator, - ).list - ) - elif isinstance(tag_value_i, dict): - self._attribute_tags[key].extend( - self._validate_key( - key=key, validator=self._tags_with_attributes_validator - ).list - ) - else: - raise self._validation_exception( - "must either be a single or list of string/attribute object" - ) + if isinstance(tag_value[0], str): + self._string_tags[key].extend( + self._validate_key( + key=key, + validator=self._tags_validator, + ).list + ) + elif isinstance(tag_value[0], dict): + self._attribute_tags[key].extend( + self._validate_key( + key=key, validator=self._tags_with_attributes_validator + ).list + ) + else: + raise self._validation_exception( + "must either be a single or list of string/attribute object" + ) @property def string_tags(self) -> Dict[str, List[TStringFormatterValidator]]: diff --git a/tests/e2e/resources/transaction_log_summaries/plugins/nfo_tags/test_nfo_kodi_safe.txt b/tests/e2e/resources/transaction_log_summaries/plugins/nfo_tags/test_nfo_kodi_safe.txt index 3b83abf2..62455ad7 100644 --- a/tests/e2e/resources/transaction_log_summaries/plugins/nfo_tags/test_nfo_kodi_safe.txt +++ b/tests/e2e/resources/transaction_log_summaries/plugins/nfo_tags/test_nfo_kodi_safe.txt @@ -11,8 +11,6 @@ Rick Beato - Can you hear the difference? 🎸🔥 #shorts.nfo kodi_safe_multi_title □: - value 1 □ - value 2 □ - - value 1 □ - - value 2 □ kodi_safe_multi_title_with_attrs: - attributes: □?: 'value @@ -24,16 +22,6 @@ Rick Beato - Can you hear the difference? 🎸🔥 #shorts.nfo newlines □' tag: "the \n tag 2 □□" - - attributes: - □?: 'value - - newlines □' - tag: "the \n tag 1 □□" - - attributes: - □?: 'value - - newlines □' - tag: "the \n tag 2 □□" kodi_safe_title □: kodi_safe_value □ kodi_safe_title_with_attrs: attributes: @@ -49,8 +37,6 @@ test.nfo kodi_safe_multi_title □: - value 1 □ - value 2 □ - - value 1 □ - - value 2 □ kodi_safe_multi_title_with_attrs: - attributes: □?: 'value @@ -62,16 +48,6 @@ test.nfo newlines □' tag: "the \n tag 2 □□" - - attributes: - □?: 'value - - newlines □' - tag: "the \n tag 1 □□" - - attributes: - □?: 'value - - newlines □' - tag: "the \n tag 2 □□" kodi_safe_title □: kodi_safe_value □ kodi_safe_title_with_attrs: attributes: