Files
tiddl/examples/track_templating.py
T
Oskar Dudziński 06b1eded7c Added explicit and dolby templates (#223)
* strip formatted parts of path

* handle "None" explicit attribute

* add explicit field to items

* add explicit to template example

* add docs for explicit

* add `dolby` field to items

* add `dolby` docs
2025-11-17 02:58:13 +01:00

27 lines
748 B
Python

from tiddl.core.utils.format import format_template
# we reuse Tidal API from another example
from .fetch_api import api
ALBUM_ID = 465173294
if __name__ == "__main__":
album = api.get_album(ALBUM_ID)
album_items = api.get_album_items(ALBUM_ID)
TEMPLATE = "{album.artists}/{album.title}, {album.date:%Y}, {album.explicit}/{item.number:02d}. {item.artists} - {item.title} ({custom_field}) {item.explicit:full}"
for album_item in album_items.items:
track = album_item.item
print(
format_template(
template=TEMPLATE,
item=track,
album=album,
with_asterisk_ext=False,
custom_field="custom_field",
)
)