-
-
Notifications
You must be signed in to change notification settings - Fork 28
Add series to metadata #196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
476c219
25b4832
fe028f5
e15d8c6
18221b4
48c67b0
c6eac7a
79bf58f
2b92ffd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| """API helper classes for media items.""" | ||
|
|
||
| from dataclasses import dataclass, field | ||
|
|
||
| from mashumaro import DataClassDictMixin | ||
|
|
||
| from .media_item import Audiobook | ||
|
|
||
|
|
||
| @dataclass | ||
| class AudiobookSeries(DataClassDictMixin): | ||
| """An audiobook series as acquired from the database. | ||
|
|
||
| This is used as API response, and not to be used by a provider. | ||
| """ | ||
|
|
||
| title: str | ||
| # sorted list of audiobooks in this series | ||
| audiobooks: list[Audiobook] = field(default_factory=list) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,6 +69,20 @@ def __hash__(self) -> int: | |
| return hash(self.position) | ||
|
|
||
|
|
||
| @dataclass(frozen=True, kw_only=True) | ||
| class MediaItemSeries(DataClassDictMixin): | ||
| """Model for a MediaItem's series.""" | ||
|
|
||
| title: str | ||
| # sequence is used for sorting | ||
| # we will first sort by number, and then alphabetically | ||
| sequence: float | str | None = None | ||
|
|
||
| def __hash__(self) -> int: | ||
| """Return custom hash.""" | ||
| return hash(self.title) | ||
|
|
||
|
|
||
| @dataclass(kw_only=True) | ||
| class MediaItemMetadata(DataClassDictMixin): | ||
| """Model for a MediaItem's metadata.""" | ||
|
|
@@ -95,6 +109,7 @@ class MediaItemMetadata(DataClassDictMixin): | |
| # chapters is a list of available chapters, sorted by position | ||
| # most commonly used for audiobooks and podcast episodes | ||
| chapters: list[MediaItemChapter] | None = None | ||
| series: UniqueList[MediaItemSeries] | None = None | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can a book be part of multiple series?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stumbled across this myself, as I had only a single series previously. I compared that to abs, and it supports multiple series. I googled a bit around, and apparently, there are some occasions where a book can be part of different aspects of e.g. a fantasy story, or you create two series e.g. for published order and chronological order. A naming alternative could be to not name this series, but collection. In the end a series is just a collection of books, which has a defined order, so a sub-type of a collection. Would just be the wording, logic remains the same - what do you think? |
||
| # last_refresh: timestamp the (full) metadata was last collected | ||
| last_refresh: int | None = None | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not too sure about this one. It kinda feels like it belongs in media_item.py, but that also makes it its own MediaItem. @marcelveldt what are your thoughts here?