diff --git a/zotify/file.py b/zotify/file.py index 4cf1bfc8..2722fb14 100644 --- a/zotify/file.py +++ b/zotify/file.py @@ -56,7 +56,9 @@ def transcode( "-i", str(self.__path), ] - path = self.__path.parent.joinpath(self.__path.name.rsplit(".", 1)[0] + ext) + path = self.__path.parent.joinpath( + f'{self.__path.name.rsplit(".", 1)[0]}.{ext}' + ) if self.__path == path: raise TranscodingError( f"Cannot overwrite source, target file {path} already exists." @@ -98,7 +100,26 @@ def write_metadata(self, metadata: list[MetadataEntry]) -> None: try: f[m.name] = m.value except KeyError: - pass + if m.name == "album_artist": + f["albumartist"] = m.value + if m.name == "artists": + f["artist"] = m.value + if m.name == "date": + f["year"] = m.value + if m.name == "disc": + f["discnumber"] = m.value + if m.name == "track_number": + f["tracknumber"] = m.value + try: + if m.name == "duration": + f["#length"] = m.value + except KeyError: + continue + except NotImplementedError: + continue + if m.name == "replaygain_track_gain": + f["replaygaintrackgain"] = m.value + continue try: f.save() except OggVorbisHeaderError: diff --git a/zotify/playable.py b/zotify/playable.py index dd312db4..0d47a77a 100644 --- a/zotify/playable.py +++ b/zotify/playable.py @@ -82,6 +82,7 @@ def write_audio_stream( self, output: Path, chunk_size: int = 128 * 1024, + disable_progress_bar: bool = False, ) -> LocalFile: """ Writes audio stream to file @@ -100,6 +101,7 @@ def write_audio_stream( unit_divisor=1024, position=0, leave=False, + disable=disable_progress_bar, ) as p_bar: chunk = None while chunk != b"": diff --git a/zotify/printer.py b/zotify/printer.py index 9aa7d325..3bd8772d 100644 --- a/zotify/printer.py +++ b/zotify/printer.py @@ -53,6 +53,7 @@ def progress( unit="it", unit_scale=False, unit_divisor=1000, + disable: bool = False, ) -> tqdm: """ Prints progress bar @@ -63,7 +64,7 @@ def progress( iterable=iterable, desc=desc, total=total, - disable=False, # cls.__config.print_progress, + disable=disable, # cls.__config.print_progress, leave=leave, position=position, unit=unit, diff --git a/zotify/utils.py b/zotify/utils.py index 869976a9..bd5a08a6 100644 --- a/zotify/utils.py +++ b/zotify/utils.py @@ -15,8 +15,8 @@ class AudioCodec(NamedTuple): - ext: str name: str + ext: str class AudioFormat(Enum):