Environment / Version Info
- tiddl Version:
v3.4.3
- Python Version:
3.13.13
- OS: Windows 11
Description
When downloading tracks or albums, the formatted folder/file names contain [YYYY-MM-DD 000000] (e.g., Folded [2025-01-01 000000]) instead of just the date [YYYY-MM-DD]. Additionally, the date written to the file metadata tags (e.g., Vorbis comments/ID3) is written with the full timestamp YYYY-MM-DD 00:00:00.
Root Cause
- Metadata Date Tag: In
tiddl/cli/commands/download/__init__.py (lines 360 and 436), the date passed to the metadata writer is converted directly to string via date=str(album.releaseDate). Because album.releaseDate is parsed as a datetime object, converting it to a string returns the time portion '2025-01-01 00:00:00'.
- Folder/File Names: In
tiddl/core/utils/format.py, {album.date} formats the datetime object, printing '2025-01-01 00:00:00'. The path sanitizer _clean_segment() then strips the colons (:), resulting in the trailing 000000.
Proposed Fix
1. In tiddl/core/utils/format.py
Introduce a custom DateFormat wrapper to format the date to YYYY-MM-DD by default, while retaining backward compatibility for user-defined format specifiers (e.g. {album.date:%Y}):
class DateFormat:
def __init__(self, value: datetime | None) -> None:
self.value = value
def __format__(self, format_spec: str) -> str:
if self.value is None or self.value == datetime.min:
return ""
if not format_spec:
return self.value.strftime("%Y-%m-%d")
return self.value.__format__(format_spec)
Then, update AlbumTemplate's date field and wrap the value inside generate_template_data():
# In AlbumTemplate
date: DateFormat = field(default_factory=lambda: DateFormat(None))
# In generate_template_data()
date=DateFormat(album.releaseDate or datetime.min),
2. In tiddl/cli/commands/download/__init__.py
Reformat the date parameter explicitly using strftime at lines 360 and 436:
# Around line 360 & 436
date=album.releaseDate.strftime("%Y-%m-%d") if album.releaseDate else "",
Note
This issue and its proposed code fixes were analyzed and drafted with the help of an AI coding assistant.
Environment / Version Info
v3.4.33.13.13Description
When downloading tracks or albums, the formatted folder/file names contain
[YYYY-MM-DD 000000](e.g.,Folded [2025-01-01 000000]) instead of just the date[YYYY-MM-DD]. Additionally, the date written to the file metadata tags (e.g., Vorbis comments/ID3) is written with the full timestampYYYY-MM-DD 00:00:00.Root Cause
tiddl/cli/commands/download/__init__.py(lines 360 and 436), the date passed to the metadata writer is converted directly to string viadate=str(album.releaseDate). Becausealbum.releaseDateis parsed as adatetimeobject, converting it to a string returns the time portion'2025-01-01 00:00:00'.tiddl/core/utils/format.py,{album.date}formats thedatetimeobject, printing'2025-01-01 00:00:00'. The path sanitizer_clean_segment()then strips the colons (:), resulting in the trailing000000.Proposed Fix
1. In
tiddl/core/utils/format.pyIntroduce a custom
DateFormatwrapper to format the date toYYYY-MM-DDby default, while retaining backward compatibility for user-defined format specifiers (e.g.{album.date:%Y}):Then, update
AlbumTemplate'sdatefield and wrap the value insidegenerate_template_data():2. In
tiddl/cli/commands/download/__init__.pyReformat the date parameter explicitly using
strftimeat lines 360 and 436:Note
This issue and its proposed code fixes were analyzed and drafted with the help of an AI coding assistant.