picard icon indicating copy to clipboard operation
picard copied to clipboard

PICARD-2729: Allow disabling date sanitization for APE and Vorbis tags

Open ShubhamBhut opened this issue 1 year ago • 11 comments

Summary

  • This is a…
    • [ ] Bug fix
    • [x] Feature addition
    • [ ] Refactoring
    • [ ] Minor / simple change (like a typo)
    • [ ] Other
  • Describe this change in 1-2 sentences:

Problem

  • JIRA ticket (optional): PICARD-2729

Solution

Added a new config setting which is checked before sanitizing date for Vorbis and APE types. Config setting can be changed by a checkbox added in Metadata section of the Options

Action

Similar as Solution

ShubhamBhut avatar Apr 17 '24 07:04 ShubhamBhut

Also a reminder that the documentation will need to be updated once this is merged.

rdswift avatar Apr 17 '24 15:04 rdswift

Perhaps this is a dumb question, but would there ever be a case where you might want to only apply this to one of the formats? If so, would it make sense to have separate settings for APE and Vorbis?

rdswift avatar Apr 17 '24 15:04 rdswift

Perhaps this is a dumb question, but would there ever be a case where you might want to only apply this to one of the formats? If so, would it make sense to have separate settings for APE and Vorbis?

Actually we could have an option that isn't a boolean, but rather a list of formats, so we can apply this to any chosen format instead.

Something like if format in disable_sanitize_date

zas avatar Apr 17 '24 15:04 zas

Added PICARD-2862 to update the documentation.

rdswift avatar Apr 17 '24 18:04 rdswift

@ShubhamBhut what do you think about suggested approach?

zas avatar Apr 19 '24 15:04 zas

@ShubhamBhut what do you think about suggested approach?

I understood it, except that there are only 3 tags vorbis, mp3/id3 and APE which uses sanitize_date so I think it would be implemented for only these 3 tags ?

Also apologies for late update, it's just that I have been tightly occupied for last couple of days. I will implement it tomorrow.

ShubhamBhut avatar Apr 19 '24 16:04 ShubhamBhut

I understood it, except that there are only 3 tags vorbis, mp3/id3 and APE which uses sanitize_date so I think it would be implemented for only these 3 tags ?

I'd add a method to those classes that wraps util.sanitize_date() so we can test if this method exists and add the matching class to the selector.

from picard.util import sanitize_date

class APEv2File(File):

    sanitize_date = sanitize_date
....
                    if name == 'year':
                        name = 'date'
                        value = self.sanitize_date(value)

In formats/util.py we need to add a method returning all known format classes having this method:

def formats_with_sanitize_date():
    for fmt in _formats:
        if hasattr(fmt, 'sanitize_date'):
             yield fmt

In selector code, you can iterate those classes:

from picard.formats.util import formats_with_sanitize_date

for fmt in formats_with_sanitize_date():
    do_something_with(fmt)

Totally untested, but you get the idea I guess.

zas avatar Apr 19 '24 20:04 zas

Hey @zas, actually this is not complete yet. For some reason, the marked formats of multicombobox are not saved. I have yet to figure it out :(

ShubhamBhut avatar Apr 23 '24 17:04 ShubhamBhut

Hey @zas, actually this is not complete yet. For some reason, the marked formats of multicombobox are not saved. I have yet to figure it out :(

See https://github.com/ShubhamBhut/picard/pull/1

  • I don't think we need 2 options, if the set is empty that's enough
  • We don't usually add our own widgets classes to .ui, we just override a dummy widget or just insert it in the layout.
  • take care of import order (see https://github.com/metabrainz/picard/blob/master/CONTRIBUTING.md#coding-style about isort and pre-commit hook.

zas avatar Apr 23 '24 20:04 zas

It looks much better. BTW, you shouldn't rebase all the time,Rebasing is useful, but commit history is too.

You didn't merge my PR?

Apologies, I will keep that in mind. Actually I was using jujutsu for version control and it doesn't have pre-commit hooks support yet. I will stick to vanilla git from now on.

ShubhamBhut avatar Apr 26 '24 08:04 ShubhamBhut

@ShubhamBhut what's the status of this PR?

zas avatar Apr 30 '24 07:04 zas