Skip to content

Commit 1b534dc

Browse files
authored
Merge pull request #505 from exislow/playlist-create-file-type-fix
refactor(constants): streamline enums and enhance type annotations
2 parents 0d8bc88 + 8dd7589 commit 1b534dc

File tree

2 files changed

+36
-26
lines changed

2 files changed

+36
-26
lines changed

tidal_dl_ng/constants.py

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,48 +16,57 @@
1616

1717

1818
class QualityVideo(StrEnum):
19-
P360: str = "360"
20-
P480: str = "480"
21-
P720: str = "720"
22-
P1080: str = "1080"
19+
P360 = "360"
20+
P480 = "480"
21+
P720 = "720"
22+
P1080 = "1080"
2323

2424

2525
class MediaType(StrEnum):
26-
TRACK: str = "track"
27-
VIDEO: str = "video"
28-
PLAYLIST: str = "playlist"
29-
ALBUM: str = "album"
30-
MIX: str = "mix"
31-
ARTIST: str = "artist"
26+
TRACK = "track"
27+
VIDEO = "video"
28+
PLAYLIST = "playlist"
29+
ALBUM = "album"
30+
MIX = "mix"
31+
ARTIST = "artist"
3232

3333

3434
class CoverDimensions(StrEnum):
35-
Px80: str = "80"
36-
Px160: str = "160"
37-
Px320: str = "320"
38-
Px640: str = "640"
39-
Px1280: str = "1280"
40-
PxORIGIN: str = "origin"
35+
Px80 = "80"
36+
Px160 = "160"
37+
Px320 = "320"
38+
Px640 = "640"
39+
Px1280 = "1280"
40+
PxORIGIN = "origin"
4141

4242

4343
class TidalLists(StrEnum):
44-
Playlists: str = "Playlists"
45-
Favorites: str = "Favorites"
46-
Mixes: str = "Mixes"
44+
Playlists = "Playlists"
45+
Favorites = "Favorites"
46+
Mixes = "Mixes"
4747

4848

4949
class QueueDownloadStatus(StrEnum):
50-
Waiting: str = "⏳️"
51-
Downloading: str = "▶️"
52-
Finished: str = "✅"
53-
Failed: str = "❌"
54-
Skipped: str = "↪️"
50+
Waiting = "⏳️"
51+
Downloading = "▶️"
52+
Finished = "✅"
53+
Failed = "❌"
54+
Skipped = "↪️"
5555

5656

57-
FAVORITES: {} = {
57+
FAVORITES: dict[str, dict[str, str]] = {
5858
"fav_videos": {"name": "Videos", "function_name": "videos"},
5959
"fav_tracks": {"name": "Tracks", "function_name": "tracks"},
6060
"fav_mixes": {"name": "Mixes & Radio", "function_name": "mixes"},
6161
"fav_artists": {"name": "Artists", "function_name": "artists"},
6262
"fav_albums": {"name": "Albums", "function_name": "albums"},
6363
}
64+
65+
66+
class AudioExtensionsValid(StrEnum):
67+
FLAC = ".flac"
68+
M4A = ".m4a"
69+
MP4 = ".mp4"
70+
MP3 = ".mp3"
71+
OGG = ".ogg"
72+
ALAC = ".alac"

tidal_dl_ng/download.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
PLAYLIST_EXTENSION,
3939
PLAYLIST_PREFIX,
4040
REQUESTS_TIMEOUT_SEC,
41+
AudioExtensionsValid,
4142
CoverDimensions,
4243
MediaType,
4344
QualityVideo,
@@ -1496,7 +1497,7 @@ def playlist_populate(
14961497
# Get all tracks in the directory
14971498
path_tracks: list[pathlib.Path] = []
14981499

1499-
for extension_audio in AudioExtensions:
1500+
for extension_audio in AudioExtensionsValid:
15001501
path_tracks = path_tracks + list(dir_scoped.glob(f"*{extension_audio!s}"))
15011502

15021503
# Sort alphabetically, e.g. if items are prefixed with numbers

0 commit comments

Comments
 (0)