How to change lastfmng plugin decade tag from '90s' to '1990's? (Regex)

Hello

I’d like to edit the lastfmng decade tag to show ‘1990’s’ but no idea how to code this. The current coding is…

regexp = ^([1-9][0-9])*[0-9]0s$

I’ve used trial and error but to no avail. Give a dog a bone please! :slight_smile:

Thank you

Any ideas please? I believe this is Java, so reckon it’s pretty straight forward for someone with the knowledge. I actually resolved this on the old forum a few years back, but unfortunately those posts no longer exist and can’t start tagging again until I fix this. Keen to get started again as there is something strangely satisfying about tagging music! Just me?! :smile:

Picard is written in Python, actually. (Sorry I can’t help with your question though).

Ok thanks.

Can any one help please as can’t start tagging again until I’ve sorted this.

I suspect the reason that you’re not getting any responses is because people really don’t know what you’re trying to do. At least, that’s my situation.

Are these existing tags in your files? What is the value of the tag? Are you trying to update the value of the existing tag or create a new tag (or something else)? Is this used to file naming or does it require a plug-in?

Hi rdswift

Thank you for your reply, and sorry if I didn’t make myself clear.

So I’m using the ‘Lastfmng’ plugin and it’s this that I am trying to edit. This plugin doesn’t have a GUI but users can change the settings by editing the defaults.ini file. I’m trying to amend the ‘category-decade’ section so that it tags music files with decade displayed as ‘1990s’ instead of the default which is ‘90s’.

I hope that makes more sense now?

regex is beyond me.
But searching around
regex replace decade format
gives


If you don’t get a solution here then stackoverflow looks productive of solutions.
Good luck.
(I hate regex.)

Thanks mmirG, but info link is beyond me too and I’ve already tried stackoverflow with my own question but without success. I spent a good few hours editing code too trying to use a bit of logic… but failed!

1 Like

I see that you asked the author and he provided a solution using entries in the “translations” section of the defaults.ini file, which you said didn’t work. What did you put in the translations section, and what did it not do for you?

I put as he suggested, but decade still tagged as ‘10s’ instead of ‘2010s’ for example.

It’s 100% possible as had it working before as someone on old MBP forum provided working code for me.

Anyone have any idea please? From memory it was just a simply edit.

I suggest:

  1. Edit the title of this thread to include “regex”.

  2. Edit your the title of your question on stackoverflow.
    New Title: regex change/replace decade format

Struth, regex is opaque.

Then I don’t know what the problem is. The regex in the ini file simply reads the decade tag, regardless of whether it’s 2-digit or 4-digit. I don’t have time right now to go through all the plug-in code to see how it’s set to write the tag. Sorry. I’ll let you know if something else comes to mind.

Ok thanks guys.

I understand, but it also produces the output to however it’s set. The only code that needs to be amended is in my first post, and here again…

regexp = ^([1-9][0-9])*[0-9]0s$

Hopefully some one here will have the know-how. Seemed such a simply edit and was resolve very quickly on old forum, just wish I had backup my plugin folder before reinstalling Windows :roll_eyes:

But without understanding how/where that regular expression is used, there’s not much else that can be done. ^([1-9][0-9])*[0-9]0s$ will match strings in the form of both “2000s” and “70s”, but it all depends on both the tracks having those tags on Last.FM to begin with and on how the regex is being used in the plugin code. That’s why e.g., @rdswift says he can’t help more without going through the code.

1 Like

Additionally, while that will match everything, no single regex can both match and replace, and while sometimes possible depending on the extensions added, conditional tests (which you need to determine which millennium a decade should be in) are really not what it’s intended for; you’ll almost always use the language the regex is embedded in for that sort of logic. If you’re wanting to put together a Picard script to do that, then we can indeed help, but not with a pure regex.

As said don’t understand regex at all, but all I know is that I had this working before. My entire album collection has the decade tagged as ‘2010s, 2000s, 1990s’ etc so I can assure you it’s possible. I posted the same question on old forum and someone was able to provide a working code for me. I’m sure all that was edited was the code as posted above.

If there is any one that uses lastfmng, understands regexp and can take a look at this please, I’d be most grateful.

This is a completely wild shot, but try changing it to regexp = ^([1-9][0-9])?[0-9]0s$. There’s no reason the current one is not working if this works, but hey. :man_shrugging:

1 Like

Thanks Freso, but unfortunately that didn’t work, as in it still tags as ‘90s’ instead of ‘1990s’ which is what I need.

That’s why I’m thinking you only have half the solution. As it is, and based purely on what you’ve posted, you have a regex that will very happily go “Yep, there’s a decade here! It’s at this part of the string!” but unless something else is happening in part of the code you haven’t posted, it doesn’t do anything beyond simply finding it.

Also, based on the code you’ve posted, it looks like you might be trying to edit the source directly. That is definitely one way of fixing things, but as you’ve seen, it’s not the most maintainable. I’d recommend leaving the plugin as it’s written, and just creating a script to do the same (obviously replacing each decade with the variable the plugin actually uses):

$if($rsearch(%decade%,^[0-9]0s?\$),$set(decade,$if($lte($left(%decade%,1),2),20,19)%decade%))

That doesn’t handle cases where the decade is preceeded with an apostrophe ('90s), but that doesn’t sound necessary for this particular plugin and better coverage for manually-set fields isn’t worth the hassle of typing it out on my phone – by the way, someone might want to test that line.

3 Likes