smartplaylist: change encoding of additional field #5563
+6
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
URL-encode additional item
fields
within generated EXTM3U playlists instead of JSON-encoding them.This is because JSON-encoding additional fields/attributes made it difficult to parse the
EXTINF
line but using URL-encoding for these values makes parsing easy (because URL-encoded values cannot contain commas, quotation marks and spaces; see here and here).I introduced the generation of additional EXTM3U item fields earlier this year and I want to correct that now.
cc @j000
Design/definition background:
Unfortunately, I didn't find a clear definition of how additional playlist item attributes should be encoded - apparently there is none. Given that item URIs within an M3U playlist can be URL-encoded already, defining the values of additional attributes to be URL-encoded is consistent design. I didn't find examples of additional EXTM3U item attributes in the web where the attribute value contains a comma, space or quotation mark but examples that specified numeric IDs and URLs as attribute values. Because the URL attribute examples I found didn't contain URL-encoded characters and because it is more readable and unproblematic for parsing, I've let the attribute URL encoding treat
:
and/
as safe characters.Breaking change:
While this is a breaking change in theory, in practice it is not since afaik all integrations of the smartplaylist plugin's additional EXTM3U item attribute generation feature (beets-webm3u) work with simple attribute values such as the item ID (numeric) whose formatting/encoding is not affected when changing from JSON to URL-encoding. In other words the change is backward-compatible with the beets-webm3u plugin (which I am adjusting correspondingly).
To Do
docs/
to describe it.)docs/changelog.rst
to the bottom of one of the lists near the top of the document.)