Add extra logic to match albums and tracks to improve match
This commit is contained in:
parent
248e42f841
commit
216940a2b8
2 changed files with 15 additions and 2 deletions
|
@ -76,8 +76,15 @@ export async function search(data, original = {}) {
|
|||
}
|
||||
|
||||
const matches = parse_result_content(result.musicShelfRenderer.contents, data.type)
|
||||
if (matches[0]) {
|
||||
return await lookupId(matches[0], data.type)
|
||||
// This could probably be done without extra lookups, but it would involve parsing deeply the response.
|
||||
// If there's some kind of rate limit on ytmusic's side, this is a good play to start refactoring
|
||||
for (const match of matches) {
|
||||
const possibleMatch = await lookupId(match, data.type)
|
||||
const nameMatch = possibleMatch.name == data.name;
|
||||
const artistMatch = data.artist.name == "" ? possibleMatch.artist.name === 'Various Artists' : data.artist.name == possibleMatch.artist.name;
|
||||
if (nameMatch && artistMatch) {
|
||||
return possibleMatch
|
||||
}
|
||||
}
|
||||
}
|
||||
debug("Finished looking up, no results")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue