Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions zotify/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions zotify/playable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"":
Expand Down
3 changes: 2 additions & 1 deletion zotify/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def progress(
unit="it",
unit_scale=False,
unit_divisor=1000,
disable: bool = False,
) -> tqdm:
"""
Prints progress bar
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion zotify/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@


class AudioCodec(NamedTuple):
ext: str
name: str
ext: str


class AudioFormat(Enum):
Expand Down