Include artist names in song/album search results (#241)

This commit is contained in:
sssionek 2023-11-19 09:18:47 -05:00 committed by GitHub
parent 18af088774
commit 41ecfea68d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View File

@ -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,
); );
} }

View File

@ -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,
); );
} }