-
-
Notifications
You must be signed in to change notification settings - Fork 697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(lyrics-plus/netease): check correctly for songs #3018
base: main
Are you sure you want to change the base?
Conversation
…example:给我一首歌的时间)lyrics content mismatch
Graphite Automations"Add `custom app` label on custom app(s) related changes" took an action on this PR • (05/10/24)1 label was added to this PR based on ririxi's automation. |
1.汉化 2.增加第三方翻译,需在有歌词的情况下
1.汉化 2.增加第三方翻译,需在有歌词的情况下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change your code to align with biome errors. Also run biome formatter on it too.
let itemId = items.findIndex(val => Utils.normalize(val.album.name) === expectedAlbumName); | ||
|
||
if (itemId === -1) { | ||
itemId = items.findIndex(val => Math.abs(info.duration - val.duration) < 3000); | ||
} | ||
|
||
if (itemId === -1) { | ||
itemId = items.findIndex(val => val.name === cleanTitle); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let itemId = items.findIndex(val => Utils.normalize(val.album.name) === expectedAlbumName); | |
if (itemId === -1) { | |
itemId = items.findIndex(val => Math.abs(info.duration - val.duration) < 3000); | |
} | |
if (itemId === -1) { | |
itemId = items.findIndex(val => val.name === cleanTitle); | |
} | |
const itemId = items.findIndex(val => | |
Utils.normalize(val.album.name) === expectedAlbumName || | |
Math.abs(info.duration - val.duration) < 3000 || | |
val.name === cleanTitle | |
); | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your reply, but there may be an album mismatch, and then there may be a market match for that data, but it's not actually the original lyrics, so it's more accurate to iterate over it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What you did, with these two ifs, can be shortened into the change I proposed. There's no difference - just better looking code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This piece of code does indeed have a more concise and elegant logic, but it only loops once. During this loop, if a condition is met, it terminates. There might be cases where the lyrics match the time condition but the album does not, causing premature termination of the loop. I encountered a situation where a song had a matching duration but mismatched lyrics. Therefore, the ideal scenario would be one condition per loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, the translation of the provided code snippet would be:
(Utils.normalize(val.album.name) === expectedAlbumName ||
Math.abs(info.duration - val.duration) < 3000 ) && val.name === cleanTitle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then just do how you got it working, however do it inside the items.findIndex
and not separate if statements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your help
Any update on this? I'm still waiting for implementing the changes |
lyrics time matching logic(For example:给我一首歌的时间)lyrics content mismatch