feat: add support for playlist cover art on filesystem

closes #650

Co-authored-by: Matteo <girardi.matteo.dev@gmail.com>
This commit is contained in:
sentriz
2026-01-19 17:56:10 +00:00
co-authored by Matteo
parent db9aa2b2e3
commit aad729e3ea
6 changed files with 210 additions and 20 deletions

No files matched your search

+17 -5
View File
@@ -27,13 +27,15 @@ const (
Podcast IDT = "pd"
PodcastEpisode IDT = "pe"
InternetRadioStation IDT = "ir"
Playlist IDT = "pl"
separator = "-"
)
//nolint:musttag
type ID struct {
Type IDT
Value int
Type IDT
Value int
StringValue string
}
func New(in string) (ID, error) {
@@ -41,10 +43,17 @@ func New(in string) (ID, error) {
if !ok {
return ID{}, ErrBadSeparator
}
switch IDT(partType) {
case Playlist:
return ID{Type: Playlist, StringValue: partValue}, nil
}
val, err := strconv.Atoi(partValue)
if err != nil {
return ID{}, fmt.Errorf("%q: %w", partValue, ErrNotAnInt)
}
switch IDT(partType) {
case Artist:
return ID{Type: Artist, Value: val}, nil
@@ -64,10 +73,13 @@ func New(in string) (ID, error) {
}
func (i ID) String() string {
if i.Value == 0 {
return "-1"
switch {
case i.Value != 0:
return fmt.Sprintf("%s%s%d", i.Type, separator, i.Value)
case i.StringValue != "":
return fmt.Sprintf("%s%s%s", i.Type, separator, i.StringValue)
}
return fmt.Sprintf("%s%s%d", i.Type, separator, i.Value)
return "-1"
}
func (i ID) MarshalJSON() ([]byte, error) {