This commit is contained in:
everbarry 2026-04-10 13:37:17 +02:00
parent 7d12c4defa
commit ce8c934436
2 changed files with 14 additions and 3 deletions

15
main.py
View File

@ -10,7 +10,7 @@ import sys
from contextlib import contextmanager
from functools import cmp_to_key
__title__ = "KeyJ's iPod shuffle Database Builder"
__title__ = "iPod shuffle Database Builder" # by Sylvain
__version__ = "1.0-rc1"
KNOWN_PROPS = frozenset(
("filename", "size", "ignore", "type", "shuffle", "reuse", "bookmark")
@ -240,6 +240,17 @@ class ShuffleRebuild:
ka, kb = cls._key_repr(a), cls._key_repr(b)
return (ka > kb) - (ka < kb)
@classmethod
def _cmp_file_entry(cls, a, b) -> int:
c = (a[0] > b[0]) - (a[0] < b[0])
if c:
return c
c = cls._cmp_sort_key(a[1], b[1])
if c:
return c
pa, pb = a[2], b[2]
return (pa > pb) - (pa < pb)
def _file_entry(self, path: str, name: str, prefix: str = ""):
if not name or name[0] == ".":
return None
@ -302,7 +313,7 @@ class ShuffleRebuild:
)
except OSError:
pass
files.sort(key=cmp_to_key(self._cmp_sort_key))
files.sort(key=cmp_to_key(self._cmp_file_entry))
nfiles = sum(1 for x in files if x[0])
if nfiles:
self.domains.append([])

2
uv.lock generated
View File

@ -4,7 +4,7 @@ requires-python = ">=3.14"
[[package]]
name = "ipodutils"
version = "0.1.0"
version = "0.1.1"
source = { editable = "." }
[package.dev-dependencies]