mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 18:41:47 +00:00
fix(synced-lyric): optimize logic
This commit is contained in:
@ -132,23 +132,12 @@ export const getLyricsList = async (
|
|||||||
const artists = artist.split(/[&,]/g).map((i) => i.trim());
|
const artists = artist.split(/[&,]/g).map((i) => i.trim());
|
||||||
const itemArtists = artistName.split(/[&,]/g).map((i) => i.trim());
|
const itemArtists = artistName.split(/[&,]/g).map((i) => i.trim());
|
||||||
|
|
||||||
const permutations = [];
|
const permutations = artists.flatMap((artistA) =>
|
||||||
for (const artistA of artists) {
|
itemArtists.map((artistB) => [artistA.toLowerCase(), artistB.toLowerCase()])
|
||||||
for (const artistB of itemArtists) {
|
);
|
||||||
permutations.push([artistA.toLowerCase(), artistB.toLowerCase()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const artistA of itemArtists) {
|
|
||||||
for (const artistB of artists) {
|
|
||||||
permutations.push([artistA.toLowerCase(), artistB.toLowerCase()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const ratio = Math.max(...permutations.map(([x, y]) => jaroWinkler(x, y)));
|
const ratio = Math.max(...permutations.map(([x, y]) => jaroWinkler(x, y)));
|
||||||
|
if (ratio > 0.9) filteredResults.push(item);
|
||||||
if (ratio <= 0.9) continue;
|
|
||||||
filteredResults.push(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const duration = songData.songDuration;
|
const duration = songData.songDuration;
|
||||||
|
|||||||
Reference in New Issue
Block a user