Skip to content

Commit

Permalink
Fix tracknumber for mp4s
Browse files Browse the repository at this point in the history
  • Loading branch information
7x11x13 committed Jul 21, 2024
1 parent 61dc702 commit 413040e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scdl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Python Soundcloud Music Downloader."""

__version__ = "v2.11.1"
__version__ = "v2.11.2"
3 changes: 2 additions & 1 deletion scdl/metadata_assembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class MetadataInfo:
album_title: Optional[str]
album_author: Optional[str]
album_track_num: Optional[int]
album_total_track_num: Optional[int]


@singledispatch
Expand Down Expand Up @@ -161,7 +162,7 @@ def _(file: mp4.MP4, meta: MetadataInfo) -> None:
file["aART"] = meta.album_author

if meta.album_track_num is not None:
file["trkn"] = str(meta.album_track_num)
file["trkn"] = [(meta.album_track_num, meta.album_total_track_num)]

if meta.description:
file["\251cmt"] = meta.description
Expand Down
3 changes: 3 additions & 0 deletions scdl/scdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ class PlaylistInfo(TypedDict):
title: str
tracknumber_int: int
tracknumber: str
tracknumber_total: int


class SoundCloudException(Exception): # noqa: N818
Expand Down Expand Up @@ -698,6 +699,7 @@ def download_playlist(
"title": playlist.title,
"tracknumber_int": 0,
"tracknumber": "0",
"tracknumber_total": playlist.track_count,
}

if not kwargs.get("no_playlist_folder"):
Expand Down Expand Up @@ -1319,6 +1321,7 @@ def _add_metadata_to_stream(
album_title=playlist_info["title"] if album_available else None, # type: ignore[index]
album_author=playlist_info["author"] if album_available else None, # type: ignore[index]
album_track_num=playlist_info["tracknumber_int"] if album_available else None, # type: ignore[index]
album_total_track_num=playlist_info["tracknumber_total"] if album_available else None, # type: ignore[index]
)

mutagen_file = mutagen.File(stream)
Expand Down

0 comments on commit 413040e

Please sign in to comment.