projects
/
music-assistant-server.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
495b794
)
Try parsing track number from the filename (#1663)
author
Marcel van der Veldt
<m.vanderveldt@outlook.com>
Sat, 14 Sep 2024 08:26:23 +0000
(10:26 +0200)
committer
GitHub
<noreply@github.com>
Sat, 14 Sep 2024 08:26:23 +0000
(10:26 +0200)
music_assistant/server/helpers/tags.py
patch
|
blob
|
history
diff --git
a/music_assistant/server/helpers/tags.py
b/music_assistant/server/helpers/tags.py
index f0014b17362c44b6c1a4b896d3c9537939b23379..c60ea526de2ddda09f25329553a6de41b56802bf 100644
(file)
--- a/
music_assistant/server/helpers/tags.py
+++ b/
music_assistant/server/helpers/tags.py
@@
-180,6
+180,16
@@
class AudioTags:
"""Return track tag if present."""
if tag := self.tags.get("track"):
return try_parse_int(tag.split("/")[0], None)
+ # fallback to parsing from filename (if present)
+ # this can be in the form of 01 - title.mp3
+ # or 01-title.mp3
+ # or 01.title.mp3
+ # or 01 title.mp3
+ # or 1. title.mp3
+ for splitpos in (4, 3, 2, 1):
+ firstpart = self.filename[:splitpos]
+ if firstpart.isnumeric():
+ return try_parse_int(firstpart, None)
return None
@property