mirror of
https://github.com/oskvr37/tiddl.git
synced 2026-06-13 04:05:08 +03:00
✨ Added {album.master} template (#225)
* add `MediaMetadataTags` literal * add `album.master` template * add docs
This commit is contained in:
+35
-33
@@ -28,37 +28,38 @@ Each object type exposes fields you can use inside templates.
|
||||
|
||||
### `item` (Track or Video)
|
||||
|
||||
| Field | Description | Example |
|
||||
| ---------------------------- | ------------------------------- | ------------------------------- |
|
||||
| `item.id` | Track/Video ID | `123456` |
|
||||
| `item.title` | Title | `Harder Better Faster Stronger` |
|
||||
| `item.title_version` | Title + version (if present) | `One More Time (Radio Edit)` |
|
||||
| `item.number` | Track number | `3` |
|
||||
| `item.volume` | Disc/volume number | `1` |
|
||||
| `item.version` | Version string (track only) | `Remastered` |
|
||||
| `item.copyright` | Copyright info (track only) | `© 2023 Sony Music` |
|
||||
| `item.bpm` | Beats per minute (if available) | `120` |
|
||||
| `item.isrc` | ISRC code (track only) | `USQX91501234` |
|
||||
| `item.quality` | Audio/video quality | `HIGH` |
|
||||
| `item.artist` | Primary artist name | `Daft Punk` |
|
||||
| `item.artists` | All main artists | `Daft Punk, Pharrell Williams` |
|
||||
| `item.features` | Featured artists | `Pharrell Williams` |
|
||||
| `item.artists_with_features` | Main + featured artists | `Daft Punk, Pharrell Williams` |
|
||||
| `item.explicit` | Explicit content | `E` |
|
||||
| `item.dolby:(Dolby Atmos)` | Dolby Atmos (track only) | `(Dolby Atmos)` |
|
||||
| Field | Description | Example |
|
||||
| ---------------------------- | -------------------------------------- | ------------------------------- |
|
||||
| `item.id` | Track/Video ID | `123456` |
|
||||
| `item.title` | Title | `Harder Better Faster Stronger` |
|
||||
| `item.title_version` | Title + version (if present) | `One More Time (Radio Edit)` |
|
||||
| `item.number` | Track number | `3` |
|
||||
| `item.volume` | Disc/volume number | `1` |
|
||||
| `item.version` | Version string (track only) | `Remastered` |
|
||||
| `item.copyright` | Copyright info (track only) | `© 2023 Sony Music` |
|
||||
| `item.bpm` | Beats per minute (if available) | `120` |
|
||||
| `item.isrc` | ISRC code (track only) | `USQX91501234` |
|
||||
| `item.quality` | Audio/video quality | `HIGH` |
|
||||
| `item.artist` | Primary artist name | `Daft Punk` |
|
||||
| `item.artists` | All main artists | `Daft Punk, Pharrell Williams` |
|
||||
| `item.features` | Featured artists | `Pharrell Williams` |
|
||||
| `item.artists_with_features` | Main + featured artists | `Daft Punk, Pharrell Williams` |
|
||||
| `item.explicit` | Explicit content | `E` |
|
||||
| `item.dolby:(Dolby Atmos)` | Dolby Atmos (track only, `UserFormat`) | `(Dolby Atmos)` |
|
||||
|
||||
---
|
||||
|
||||
### `album`
|
||||
|
||||
| Field | Description | Example |
|
||||
| ---------------- | ------------------------- | ------------ |
|
||||
| `album.id` | Album ID | `98765` |
|
||||
| `album.title` | Album title | `Discovery` |
|
||||
| `album.artist` | Primary artist | `Daft Punk` |
|
||||
| `album.artists` | All main artists | `Daft Punk` |
|
||||
| `album.date` | Release date (`datetime`) | `2001-03-13` |
|
||||
| `album.explicit` | Explicit content | `clean` |
|
||||
| Field | Description | Example |
|
||||
| -------------------- | ----------------------------------- | ------------ |
|
||||
| `album.id` | Album ID | `98765` |
|
||||
| `album.title` | Album title | `Discovery` |
|
||||
| `album.artist` | Primary artist | `Daft Punk` |
|
||||
| `album.artists` | All main artists | `Daft Punk` |
|
||||
| `album.date` | Release date (`datetime`) | `2001-03-13` |
|
||||
| `album.explicit` | Explicit content | `clean` |
|
||||
| `album.master:[MAX]` | Is album max quality (`UserFormat`) | `[MAX]` |
|
||||
|
||||
---
|
||||
|
||||
@@ -82,15 +83,16 @@ Each object type exposes fields you can use inside templates.
|
||||
| `.explicit:long` | explicit | |
|
||||
| `.explicit:full` | explicit | clean |
|
||||
|
||||
### Dolby Atmos
|
||||
### User Format
|
||||
|
||||
Dolby Atmos is only available in tracks. Format it like this: `item.dolby:<value>`.
|
||||
You can format `UserFormat` fields how you want:
|
||||
|
||||
| Format | True Value | False Value |
|
||||
| ------------------ | ---------- | ----------- |
|
||||
| `item.dolby:D` | D | |
|
||||
| `item.dolby:DOLBY` | DOLBY | |
|
||||
| `item.dolby:dolby` | dolby | |
|
||||
| Format | True Value | False Value |
|
||||
| ---------------------------- | ------------- | ----------- |
|
||||
| `item.dolby:D` | D | |
|
||||
| `item.dolby:DOLBY` | DOLBY | |
|
||||
| `item.dolby:dolby` | dolby | |
|
||||
| `album.master:(Max Quality)` | [Max Quality] | |
|
||||
|
||||
### `extra` and `custom` fields
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ TrackQuality = Literal["LOW", "HIGH", "LOSSLESS", "HI_RES_LOSSLESS"]
|
||||
# audio_only is not stable
|
||||
VideoQuality = Literal["AUDIO_ONLY", "LOW", "MEDIUM", "HIGH"]
|
||||
|
||||
MediaMetadataTags = Literal["LOSSLESS", "HIRES_LOSSLESS", "DOLBY_ATMOS"]
|
||||
|
||||
|
||||
class Track(BaseModel):
|
||||
|
||||
@@ -24,7 +26,7 @@ class Track(BaseModel):
|
||||
videoCover: Optional[str] = None
|
||||
|
||||
class MediaMetadata(BaseModel):
|
||||
tags: list[str]
|
||||
tags: list[MediaMetadataTags]
|
||||
|
||||
id: int
|
||||
title: str
|
||||
@@ -107,7 +109,7 @@ class Album(BaseModel):
|
||||
picture: Optional[str] = None
|
||||
|
||||
class MediaMetadata(BaseModel):
|
||||
tags: List[Literal["LOSSLESS", "HIRES_LOSSLESS", "DOLBY_ATMOS"]]
|
||||
tags: List[MediaMetadataTags]
|
||||
|
||||
id: int
|
||||
title: str
|
||||
|
||||
@@ -35,7 +35,7 @@ class Explicit:
|
||||
return base
|
||||
|
||||
|
||||
class DolbyAtmos:
|
||||
class UserFormat:
|
||||
def __init__(self, value: bool) -> None:
|
||||
self.value = value
|
||||
|
||||
@@ -51,6 +51,7 @@ class AlbumTemplate:
|
||||
artists: str
|
||||
date: datetime
|
||||
explicit: Explicit
|
||||
master: UserFormat
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
@@ -70,7 +71,7 @@ class ItemTemplate:
|
||||
features: str
|
||||
artists_with_features: str
|
||||
explicit: Explicit
|
||||
dolby: DolbyAtmos
|
||||
dolby: UserFormat
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
@@ -105,13 +106,13 @@ def generate_template_data(
|
||||
copyright_ = item.copyright or ""
|
||||
bpm = item.bpm or 0
|
||||
isrc = item.isrc or ""
|
||||
dolby = DolbyAtmos("DOLBY_ATMOS" in item.mediaMetadata.tags)
|
||||
dolby = UserFormat("DOLBY_ATMOS" in item.mediaMetadata.tags)
|
||||
else: # Video
|
||||
version = ""
|
||||
copyright_ = ""
|
||||
bpm = 0
|
||||
isrc = ""
|
||||
dolby = DolbyAtmos(False)
|
||||
dolby = UserFormat(False)
|
||||
|
||||
item_template = ItemTemplate(
|
||||
id=item.id,
|
||||
@@ -143,6 +144,7 @@ def generate_template_data(
|
||||
),
|
||||
date=album.releaseDate,
|
||||
explicit=Explicit(getattr(album, "explicit", None)),
|
||||
master=UserFormat("HIRES_LOSSLESS" in album.mediaMetadata.tags),
|
||||
)
|
||||
|
||||
playlist_template = None
|
||||
|
||||
Reference in New Issue
Block a user