Skip to content

Bug: Release date in folder names and file metadata tags contains trailing time / zeros (e.g. [2025-01-01 000000] ) #399

Description

@Bradley-Chen

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

  1. 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'.
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions