From 709c5ebaa81d816d3788d265089e3c252b49a8bc Mon Sep 17 00:00:00 2001 From: Kur01234 Date: Tue, 7 May 2024 12:34:24 +0200 Subject: [PATCH 1/2] Correct duplicate values --- music_kraken/objects/metadata.py | 10 +++++++--- pyproject.toml | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/music_kraken/objects/metadata.py b/music_kraken/objects/metadata.py index 69fff8d..dfda274 100644 --- a/music_kraken/objects/metadata.py +++ b/music_kraken/objects/metadata.py @@ -355,7 +355,12 @@ class Metadata: return None list_data = self.id3_dict[field] - + #correct duplications + correct_list_data = list() + for data in list_data: + if data not in correct_list_data: + correct_list_data.append(data) + list_data = correct_list_data # convert for example the time objects to timestamps for i, element in enumerate(list_data): # for performance’s sake I don't do other checks if it is already the right type @@ -368,7 +373,7 @@ class Metadata: if type(element) == ID3Timestamp: list_data[i] = element.timestamp continue - + """ Version 2.4 of the specification prescribes that all text fields (the fields that start with a T, except for TXXX) can contain multiple values separated by a null character. Thus if above conditions are met, I concatenate the list, @@ -395,6 +400,5 @@ class Metadata: """ # set the tagging timestamp to the current time self.__setitem__(Mapping.TAGGING_TIME, [ID3Timestamp.now()]) - for field in self.id3_dict: yield self.get_mutagen_object(field) diff --git a/pyproject.toml b/pyproject.toml index 9c8232b..62598b1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,7 +69,7 @@ dependencies = [ "toml~=0.10.2", "typing_extensions~=4.7.1", - "python-sponsorblock~=0.0.0", + "python-sponsorblock~=0.1.dev1", "youtube_dl", ] dynamic = [ -- 2.45.2 From e3e7aea959111049753714d59414fb3a7d85b39e Mon Sep 17 00:00:00 2001 From: Kur01234 Date: Wed, 8 May 2024 12:27:56 +0200 Subject: [PATCH 2/2] fix for lyrics --- music_kraken/audio/metadata.py | 8 +++++++- music_kraken/objects/formatted_text.py | 2 +- music_kraken/objects/metadata.py | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/music_kraken/audio/metadata.py b/music_kraken/audio/metadata.py index 1d37419..b59bc98 100644 --- a/music_kraken/audio/metadata.py +++ b/music_kraken/audio/metadata.py @@ -1,5 +1,5 @@ import mutagen -from mutagen.id3 import ID3, Frame, APIC +from mutagen.id3 import ID3, Frame, APIC, USLT from pathlib import Path from typing import List import logging @@ -7,6 +7,7 @@ from PIL import Image from ..utils.config import logging_settings, main_settings from ..objects import Song, Target, Metadata +from ..objects.metadata import Mapping from ..connection import Connection LOGGER = logging_settings["tagging_logger"] @@ -105,6 +106,11 @@ def write_metadata_to_target(metadata: Metadata, target: Target, song: Song): data=converted_target.read_bytes(), ) ) + id3_object.frames.delall("USLT") + uslt_val = metadata.get_id3_value(Mapping.UNSYNCED_LYRICS) + id3_object.frames.add( + USLT(encoding=3, lang=u'eng', desc=u'desc', text=uslt_val) + ) mutagen_file = mutagen.File(target.file_path) diff --git a/music_kraken/objects/formatted_text.py b/music_kraken/objects/formatted_text.py index b1891b6..8f9fc52 100644 --- a/music_kraken/objects/formatted_text.py +++ b/music_kraken/objects/formatted_text.py @@ -32,7 +32,7 @@ class FormattedText: if self.is_empty and other.is_empty: return True - return self.doc == other.doc + return self.html == other.html @property def markdown(self) -> str: diff --git a/music_kraken/objects/metadata.py b/music_kraken/objects/metadata.py index dfda274..14ffb69 100644 --- a/music_kraken/objects/metadata.py +++ b/music_kraken/objects/metadata.py @@ -92,7 +92,7 @@ class Mapping(Enum): key = attribute.value if key[0] == 'T': - # a text fiel + # a text field return cls.get_text_instance(key, value) if key[0] == "W": # an url field @@ -381,7 +381,7 @@ class Metadata: """ if field.value[0].upper() == "T" and field.value.upper() != "TXXX": return self.NULL_BYTE.join(list_data) - + return list_data[0] def get_mutagen_object(self, field): -- 2.45.2