From cee7b771ced4d03cf380a169e8687b929e7f4176 Mon Sep 17 00:00:00 2001 From: "d.rathmer" Date: Mon, 28 Aug 2023 12:36:20 +0200 Subject: [PATCH 1/6] feat(progress_bar): Allow progress bar to be disabled --- zotify/playable.py | 2 ++ zotify/printer.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) 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, From 6cbea15b10e64086583be557c556f806f2c5397a Mon Sep 17 00:00:00 2001 From: "d.rathmer" Date: Mon, 28 Aug 2023 13:29:49 +0200 Subject: [PATCH 2/6] fix(transcoding): Extension is missing a dot --- zotify/file.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/zotify/file.py b/zotify/file.py index 4cf1bfc8..ad84e9e2 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." From e22d53882d07bf89c4693f5efc6e8859f38245ae Mon Sep 17 00:00:00 2001 From: "d.rathmer" Date: Mon, 28 Aug 2023 13:34:55 +0200 Subject: [PATCH 3/6] fix(transcoding): name was used instead of ext for audio_format --- zotify/file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zotify/file.py b/zotify/file.py index ad84e9e2..a08691c6 100644 --- a/zotify/file.py +++ b/zotify/file.py @@ -65,7 +65,7 @@ def transcode( ) cmd.extend(["-b:a", str(bitrate) + "k"]) if bitrate > 0 else None - cmd.extend(["-c:a", audio_format.value.name]) if audio_format else None + cmd.extend(["-c:a", audio_format.value.ext]) if audio_format else None cmd.extend(opt_args) cmd.append(str(path)) From 7fdf39b343026b44b76452a410ba1faea1b53f64 Mon Sep 17 00:00:00 2001 From: "d.rathmer" Date: Mon, 28 Aug 2023 13:46:33 +0200 Subject: [PATCH 4/6] feat(metadata): Transform wrong metadata to correct ones --- zotify/file.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/zotify/file.py b/zotify/file.py index a08691c6..df2b531c 100644 --- a/zotify/file.py +++ b/zotify/file.py @@ -100,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: From 68bdc51acf12b81b460c669fd976f06d8a6dab11 Mon Sep 17 00:00:00 2001 From: "d.rathmer" Date: Mon, 28 Aug 2023 13:58:50 +0200 Subject: [PATCH 5/6] Revert "fix(transcoding): name was used instead of ext for audio_format" This reverts commit e22d53882d07bf89c4693f5efc6e8859f38245ae. --- zotify/file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zotify/file.py b/zotify/file.py index df2b531c..2722fb14 100644 --- a/zotify/file.py +++ b/zotify/file.py @@ -65,7 +65,7 @@ def transcode( ) cmd.extend(["-b:a", str(bitrate) + "k"]) if bitrate > 0 else None - cmd.extend(["-c:a", audio_format.value.ext]) if audio_format else None + cmd.extend(["-c:a", audio_format.value.name]) if audio_format else None cmd.extend(opt_args) cmd.append(str(path)) From b713351c62a0b6ee5adc7caa8498e4f37ff51e09 Mon Sep 17 00:00:00 2001 From: "d.rathmer" Date: Mon, 28 Aug 2023 14:00:02 +0200 Subject: [PATCH 6/6] fix(audio_codec): Properties are switched --- zotify/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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):