Skip to content
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 the no_convert option of the convert plugin stopping conversion when there is only a partial match. #5376

Merged
merged 5 commits into from
Oct 27, 2024

Conversation

sanpoChew
Copy link
Contributor

@sanpoChew sanpoChew commented Aug 1, 2024

Description

I was running the convert plugin with the following config:

no_convert: samplerate:..48000 bitdepth:..16

but anything that was 24/48 was also not being converted, this was due to the code returning False for should_transcode if any part of the query matches, rather than considering the whole query. This meant that bitdepth:...16 was being ignored.

I have changed this so the no_convert value is considered as one query.

To Do

  • Documentation.
  • Changelog.
  • Tests.

@bal-e
Copy link
Member

bal-e commented Aug 5, 2024

I'm looking at the documentation for no_convert:

Does not transcode items matching the query string provided (see Queries). For example, to not convert AAC or WMA formats, you can use format:AAC, format:WMA or path::\.(m4a|wma)$. If you only want to transcode WMA format, you can use a negative query, e.g., ^path::\.(wma)$, to not convert any other format except WMA.

I understand that the comma should work as a logical OR operator. @sanpoChew, can you confirm that format:AAC, format:WMA works as the documentation suggests, with your patches applied?

Also, this may break users' configurations, please add some information in the changelog so that users know how to adjust.

Copy link
Contributor

@Serene-Arc Serene-Arc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, and for catching this bug! This seems like a good fix.

Copy link
Contributor

@Serene-Arc Serene-Arc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, just one request. Can you add a test that confirms that the comma OR functionality still works as expected with this change? Just as a test-coverage thing.

After that, if @bal-e is fine, this can be merged.

@sanpoChew
Copy link
Contributor Author

I'm looking at the documentation for no_convert:

Does not transcode items matching the query string provided (see Queries). For example, to not convert AAC or WMA formats, you can use format:AAC, format:WMA or path::\.(m4a|wma)$. If you only want to transcode WMA format, you can use a negative query, e.g., ^path::\.(wma)$, to not convert any other format except WMA.

I understand that the comma should work as a logical OR operator. @sanpoChew, can you confirm that format:AAC, format:WMA works as the documentation suggests, with your patches applied?

Also, this may break users' configurations, please add some information in the changelog so that users know how to adjust.

That is correct yes, if users want to maintain the existing behaviour they would need to add a comma. I have updated the changelog entry so that it is more helpful 👍

@sanpoChew
Copy link
Contributor Author

sanpoChew commented Aug 16, 2024

Actually, just one request. Can you add a test that confirms that the comma OR functionality still works as expected with this change? Just as a test-coverage thing.

After that, if @bal-e is fine, this can be merged.

That makes sense, have added that test 👍

Copy link
Member

@bal-e bal-e left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, @sanpoChew. LGTM!

test/plugins/test_convert.py Outdated Show resolved Hide resolved
@sanpoChew
Copy link
Contributor Author

There seems to be some failures unrelated to my code in the lint checks

@snejus
Copy link
Member

snejus commented Sep 29, 2024

There seems to be some failures unrelated to my code in the lint checks

Seems like this was caused by GitHub failing DNS resolution internally. Have re-ran the workflows and it worked fine now.

Copy link
Member

@snejus snejus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested something which should simplify testing

docs/changelog.rst Outdated Show resolved Hide resolved
test/plugins/test_convert.py Outdated Show resolved Hide resolved
beetsplug/convert.py Outdated Show resolved Hide resolved
@sanpoChew sanpoChew requested a review from snejus October 26, 2024 18:16
snejus
snejus previously approved these changes Oct 27, 2024
Copy link
Member

@snejus snejus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing stuff, looks super clean now! Thanks for catching this.

@snejus snejus merged commit f0f87cc into beetbox:master Oct 27, 2024
12 checks passed
@sanpoChew
Copy link
Contributor Author

fantastic! thanks a lot for the guidance all 👍

@sanpoChew sanpoChew deleted the convert-no-convert-query-fix branch October 28, 2024 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants