[templates] Shorten up naturalduration rep

This commit is contained in:
2026-06-21 23:04:01 -04:00
parent d9dfec81aa
commit 893867419a
2 changed files with 10 additions and 8 deletions

View File

@ -88,7 +88,7 @@ fetching and simple saving.
*** Metadata sources *** Metadata sources
**** Scraper **** Scraper
* Backlog [4/26] :vrobbler:project:personal: * Backlog [5/27] :vrobbler:project:personal:
** TODO [#C] Create small utility to clean up tracks scrobbled with wonky playback times :bug:music:scrobbles: ** TODO [#C] Create small utility to clean up tracks scrobbled with wonky playback times :bug:music:scrobbles:
:PROPERTIES: :PROPERTIES:
:ID: 702462cf-d54b-48c6-8a7c-78b8de751deb :ID: 702462cf-d54b-48c6-8a7c-78b8de751deb
@ -604,6 +604,10 @@ independent of the email flow it was originally creatdd for
** TODO [#B] Is there way to create unique slugs for media instances :media_types: ** TODO [#B] Is there way to create unique slugs for media instances :media_types:
** DONE [#A] Scrobble button on some media list pages dont work :bug:scrobbles:
:PROPERTIES:
:ID: a3a5c707-2e3d-a6b1-0f7f-4c6f7433aa1f
:END:
** DONE [#B] Use HTMx to update the Now Playing widget :feature:templates: ** DONE [#B] Use HTMx to update the Now Playing widget :feature:templates:
:PROPERTIES: :PROPERTIES:
:ID: 5f5631fc-9ee1-d5a5-d0f8-94fea6fbbfa4 :ID: 5f5631fc-9ee1-d5a5-d0f8-94fea6fbbfa4

View File

@ -15,13 +15,11 @@ def natural_duration(value):
seconds = remainder % 60 seconds = remainder % 60
parts = [] parts = []
if days: if days:
parts.append(f"{days} day{'s' if days != 1 else ''}") parts.append(f"{days} d")
if hours: if hours:
parts.append(f"{hours} hour{'s' if hours != 1 else ''}") parts.append(f"{hours} hr")
if minutes: if minutes:
parts.append(f"{minutes} minute{'s' if minutes != 1 else ''}") parts.append(f"{minutes} min")
if seconds or not parts: if seconds or not parts:
parts.append(f"{seconds} second{'s' if seconds != 1 else ''}") parts.append(f"{seconds} sec")
if len(parts) == 1: return ", ".join(parts)
return parts[0]
return ", ".join(parts[:-1]) + " and " + parts[-1]