mirror of
https://github.com/informaticker/discord-jellyfin-bot.git
synced 2024-11-25 02:51:57 +01:00
Include artist names in song/album search results (#241)
This commit is contained in:
parent
18af088774
commit
41ecfea68d
@ -17,10 +17,14 @@ export class AlbumSearchHint extends SearchHint {
|
|||||||
'Unable to construct playlist search hint, required properties were undefined',
|
'Unable to construct playlist search hint, required properties were undefined',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
var artist = ""
|
||||||
|
if(hint.AlbumArtist) {
|
||||||
|
artist = hint.AlbumArtist + " - "
|
||||||
|
}
|
||||||
|
|
||||||
return new AlbumSearchHint(
|
return new AlbumSearchHint(
|
||||||
hint.Id,
|
hint.Id,
|
||||||
trimStringToFixedLength(hint.Name, 50),
|
trimStringToFixedLength(artist + hint.Name, 70),
|
||||||
hint.RunTimeTicks / 10000,
|
hint.RunTimeTicks / 10000,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ export class SearchHint {
|
|||||||
static constructFromHint(hint: JellyfinSearchHint) {
|
static constructFromHint(hint: JellyfinSearchHint) {
|
||||||
const schema = z.object({
|
const schema = z.object({
|
||||||
Id: z.string(),
|
Id: z.string(),
|
||||||
|
Artists: z.array(z.string()),
|
||||||
Name: z.string(),
|
Name: z.string(),
|
||||||
RunTimeTicks: z.number(),
|
RunTimeTicks: z.number(),
|
||||||
});
|
});
|
||||||
@ -44,10 +45,18 @@ export class SearchHint {
|
|||||||
)}`,
|
)}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
var artist = "";
|
||||||
|
if (result.data.Artists !== null) {
|
||||||
|
artist = result.data.Artists[0]
|
||||||
|
if (result.data.Artists.length > 1) {
|
||||||
|
artist += ",... - "
|
||||||
|
} else {
|
||||||
|
artist += " - "
|
||||||
|
}
|
||||||
|
}
|
||||||
return new SearchHint(
|
return new SearchHint(
|
||||||
result.data.Id,
|
result.data.Id,
|
||||||
trimStringToFixedLength(result.data.Name, 50),
|
trimStringToFixedLength(artist + result.data.Name, 70),
|
||||||
result.data.RunTimeTicks / 10000,
|
result.data.RunTimeTicks / 10000,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user