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
Add Regex/Bulk Edits #3671
Add Regex/Bulk Edits #3671
Conversation
Updated the editing system to now edit each field once. The new system means that any number of edits can be applied before/after the metadata fetching, but once a field has been modified by a regex edit, the same field cannot be modified again (the same field can be the subject of multiple searches, but not replaces) This limitation carries over between the regex application before and after metadata fetching. I think this behavior should feel a lot more consistent. EDIT: It still goes from recent to oldest regex edit. |
Fixed up casing stuff i shouldve done in the first place. Also changed up the previews to now show information prior to doing any regex edits instead of showing warning. |
Note that this commit was breaking, and as of this commit the branch is incompatible with the previous commit of the branch. Remove and readd extension to browser to fix. This issue will not occur between this branch and V2, it should smoothly migrate. |
Not sure I am doing it properly but for example if I go to https://youngspice.bandcamp.com/album/basic-couch-formula Play a song and edit in artist field replace left It doesn't seem to change anything for me :/ like still plays correctly. Am I doing something wrong? |
Found the issue, it's caused by an error from the track not existing in lastfm. I think maybe quite a lot of the pipeline actually breaks because of this, and it was only noticeable now because of the regex edits. Let me have a look into it. |
My suspicion was correct, all this time the normalize pipeline has literally not been running at all 🤦🏼♀️ |
Alright, added a new pipeline step at the very top that copies parsed data into processed before starting. Some steps rely on processed data being there even if it is the same as parsed, including the regex edits. I don't see anything in the code that should break from this change - with that said I don't guarantee anything, this should be viewed pretty critically as it's a relatively significant change to how the pipeline operates. Anyway the bug you described should be fixed now (and the normalize pipeline should actually work now! On the negative side that might cause some differences in scrobbled tracks for users between v2 and v3, but it would be v3 working correctly) This PR should now be considered breaking compared to v2, though other than normalization potentially messing things up a bit I don't think it should be noticeable for users. EDIT: needless to say that last commit should be scrutinized extra thoroughly. |
Added tests now. This uses the node fetch API, meaning required node version is bumped to node 18. It's LTS so I think it's fine. Now that there are tests. I think I'm ok with undrafting this, though more tests might be needed. |
Nice improvements! It's def working for me now. However I noticed this behaviour. Play music and edit regex rule -> all works How does one remove this rule? I tried changing it to match and replace with $1 which the preview it works but it seems to only scrobble the first change? Perhaps do you think we need some UI to see regex rules to remove them? like with edited tracks (just noticed we can't remove them either here too) |
The way it currently works is that there are four flags for each of the four fields indicating if they have been edited by a regex edit. Once a regex edit is applied to a field (So that an actual replace operation occurs, this would include just a $1 replace), that field can no longer be modified by any other regex edit. This allows you to use regex edits to override other regex edits (such as having a regex edit changing last comma to ampersand, and then having a separate rule telling it to be ignored for a specific artist with comma in the name). The most recently added regex edit will be applied first. The full list of regex edits can be viewed and deleted in options menu, just like normal song edits. Should I add a link to the popup linking to the section of options? I don't see an elegant way of adding regex edit deletion within the popup itself. |
How did I miss that UI section in options 🙈 i think it's clear enough for now 👍 |
I think it will become clearer once there is a separate entry in the sidebar for edits, which I want to do. I want this to be merged first though in the interest of trying to keep the PR at least somewhat remotely atomic. |
try { | ||
await RegexEdits.loadSongInfo(song); | ||
} catch (e) { | ||
// Do nothing |
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.
Should we log debug here to make debugging easier if something really went wrong?
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.
Not sure. To be honest I dont know how we would even get an error here.
But this pipeline is directly copied from pipeline/user-input, as the user-input function works basically the same due to regex edit class being directly based off the user edit model.
I assume the try catch is there for some reason, but there was no comment in the original telling me why, so I mindlessly copy pasted.
We could add some logging for sure, it shouldnt spam the user.
I’ll merge this as is for now and I can make a new PR adding some logging later, as due to the size of the changes on this PR this not being merged is blocking several future modifications needed before release.
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.
Aside the comments seems reasonable 👍
Hey, awesome news! Which version it is supposed to be released with? |
It is scheduled for release in version 3.0.0, we’re working on getting it out now |
love the new web scrobbler design, thanks for your work search: "(\s?(con\s)" replace "(feat. " example: |
Currently, regex demands full text matches. I plan to add some options that will allow you to tweak this behavior a bit and help make the behavior more clear to the user in the future. |
it works =) hope you can put this rules in the future, thanks for your work! https://github.com/web-scrobbler/web-scrobbler/issues/3069#issuecomment-1013927834 |
I managed to improve the regex rule if you want to add it in the future: https://regex101.com/r/rz997G/1 Regular Expression Example: thanks for your work |
BREAKING: upgrades required node version to 18
BREAKING: modifies some legacy pipeline behavior, potentially causing inconsisten behavior to v2, in particular with normalize pipeline.
Adds a regex/bulk editing system on top of the existing one, accessed through a "regex mode" button in the edit menu.
Some base rules of how this should work:
/^{searchField}$/
). All four fields must be true for the bulk edit to be applied./^{searchField}$/
to the replace field. Capture groups work.The rules of this are admittedly a bit magic, but from my experience it is the ruleset that feels the most right to use. We might need to add an explainer somewhere in the extension though.
Adds some more locale stuff. Some of it is trivial for us to add ourselves based on existing properties, but most isn't.
Closes #2588 Closes #3432 Closes #2948 Closes #2943 Closes #2608 Closes #1552 Closes #3069 Closes #3046 Closes #1643 Closes #2157
Also adds two default filters that remove - EP and - Single at the end of album fields, applied by apple music (which is also commonly fetched for other connectors when no album can be fetched from the website itself).
Hence also closes #3186
Any more issues this closes?
I think this PR needs a bit more love before being pushed so setting it to draft for now, but it's pretty close.