From 413040ecac1a9d7177a53a82b002de57314cbb09 Mon Sep 17 00:00:00 2001 From: 7x11x13 Date: Sun, 21 Jul 2024 11:53:09 -0400 Subject: [PATCH] Fix tracknumber for mp4s --- scdl/__init__.py | 2 +- scdl/metadata_assembler.py | 3 ++- scdl/scdl.py | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/scdl/__init__.py b/scdl/__init__.py index b385482..805e630 100644 --- a/scdl/__init__.py +++ b/scdl/__init__.py @@ -1,3 +1,3 @@ """Python Soundcloud Music Downloader.""" -__version__ = "v2.11.1" +__version__ = "v2.11.2" diff --git a/scdl/metadata_assembler.py b/scdl/metadata_assembler.py index 9dded62..44e5661 100644 --- a/scdl/metadata_assembler.py +++ b/scdl/metadata_assembler.py @@ -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 @@ -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 diff --git a/scdl/scdl.py b/scdl/scdl.py index efca968..820cc2e 100644 --- a/scdl/scdl.py +++ b/scdl/scdl.py @@ -197,6 +197,7 @@ class PlaylistInfo(TypedDict): title: str tracknumber_int: int tracknumber: str + tracknumber_total: int class SoundCloudException(Exception): # noqa: N818 @@ -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"): @@ -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)