WIP V3: smarten up section timings
This commit is contained in:
parent
ab084ccf97
commit
2907514eb7
@ -252,7 +252,12 @@ def send_mail(to_addr, from_addr, subj, body):
|
|||||||
s.quit()
|
s.quit()
|
||||||
|
|
||||||
|
|
||||||
def ms_to_mmss(ms: Optional[int], decimals: int = 0, negative: bool = False) -> str:
|
def ms_to_mmss(
|
||||||
|
ms: Optional[int],
|
||||||
|
decimals: int = 0,
|
||||||
|
negative: bool = False,
|
||||||
|
none: Optional[str] = None,
|
||||||
|
) -> str:
|
||||||
"""Convert milliseconds to mm:ss"""
|
"""Convert milliseconds to mm:ss"""
|
||||||
|
|
||||||
minutes: int
|
minutes: int
|
||||||
@ -260,7 +265,10 @@ def ms_to_mmss(ms: Optional[int], decimals: int = 0, negative: bool = False) ->
|
|||||||
seconds: float
|
seconds: float
|
||||||
|
|
||||||
if not ms:
|
if not ms:
|
||||||
return "-"
|
if none:
|
||||||
|
return none
|
||||||
|
else:
|
||||||
|
return "-"
|
||||||
sign = ""
|
sign = ""
|
||||||
if ms < 0:
|
if ms < 0:
|
||||||
if negative:
|
if negative:
|
||||||
|
|||||||
@ -485,24 +485,28 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
duration += row_prd.duration
|
duration += row_prd.duration
|
||||||
return (
|
return (
|
||||||
f"{prd.note[:-1].strip()} "
|
f"{prd.note[:-1].strip()} "
|
||||||
f"[{count} tracks, {ms_to_mmss(duration)} unplayed (to end of playlist)]"
|
f"[{count} tracks, {ms_to_mmss(duration, none='none')} "
|
||||||
|
"unplayed (to end of playlist)]"
|
||||||
)
|
)
|
||||||
elif prd.note.endswith("="):
|
elif prd.note.endswith("="):
|
||||||
# Show subtotal
|
# Show subtotal
|
||||||
for row_number in range(prd.plr_rownum - 1, -1, -1):
|
for row_number in range(prd.plr_rownum - 1, -1, -1):
|
||||||
row_prd = self.playlist_rows[row_number]
|
row_prd = self.playlist_rows[row_number]
|
||||||
if self.is_header_row(row_number):
|
if self.is_header_row(row_number):
|
||||||
|
if row_prd.note.endswith("-"):
|
||||||
|
# There was no start of section
|
||||||
|
return prd.note
|
||||||
if row_prd.note.endswith(("+", "=")):
|
if row_prd.note.endswith(("+", "=")):
|
||||||
stripped_note = prd.note[:-1].strip()
|
stripped_note = prd.note[:-1].strip()
|
||||||
if stripped_note:
|
if stripped_note:
|
||||||
return (
|
return (
|
||||||
f"{stripped_note} [{count} tracks, "
|
f"{stripped_note} [{count} track{'s' if count > 1 else ''}, "
|
||||||
f"{ms_to_mmss(duration)} unplayed]"
|
f"{ms_to_mmss(duration)} unplayed]"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return (
|
return (
|
||||||
f"[Subtotal: {count} tracks, "
|
f"[Subtotal: {count} track{'s' if count > 1 else ''}, "
|
||||||
f"{ms_to_mmss(duration)} unplayed]"
|
f"{ms_to_mmss(duration, none='none')} unplayed]"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user