Align the fetch-lyrics summary with fetch-artists via shared utils

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-04 15:34:26 +08:00
co-authored by Claude Fable 5
parent 105664e93b
commit a7806c0c9d
8 changed files with 68 additions and 36 deletions
+24
View File
@@ -0,0 +1,24 @@
# Tools for A Feminist Audit of Pop Music.
# Copyright 2026 imacat. All rights reserved.
# Authors:
# imacat@mail.imacat.idv.tw (imacat), 2026/8/4
"""The shared utilities of the package."""
def format_duration(seconds: float) -> str:
"""Format an elapsed duration for the closing summary line.
:param seconds: The elapsed duration, in seconds.
:return: The duration formatted ``mm:ss``, or ``h:mm:ss``
once it reaches one hour.
"""
total: int = round(seconds)
hours: int
remainder: int
hours, remainder = divmod(total, 3600)
minutes: int
secs: int
minutes, secs = divmod(remainder, 60)
if hours > 0:
return f"{hours}:{minutes:02d}:{secs:02d}"
return f"{minutes:02d}:{secs:02d}"