-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
smartplaylist: add --uri-format option #5048
smartplaylist: add --uri-format option #5048
Conversation
a7c3aea
to
36f3db4
Compare
36f3db4
to
b80777e
Compare
Looks good overall, and it doesn't seem likely to disrupt other users of this plugin! Here is one small design-choice: currently, the template uses the literal string |
@sampsyo I am fine with making the change you suggested. However, can you please elaborate in which way your suggested change is making it more future-proof. |
b80777e
to
29ffebc
Compare
Thinking about consistency, I realize it would be more consistent to call the option |
29ffebc
to
b723c5b
Compare
I adjusted both PRs correspondingly ( |
b723c5b
to
3b6b6c6
Compare
3b6b6c6
to
a0b34e0
Compare
I renamed the option again: it is now called |
Beets web API already allows remote players to access audio files but it doesn't provide a way to expose the playlists defined using the smartplaylist plugin. Now the smartplaylist plugin provides an option to generate ID-based item URIs/URLs instead of paths. Once playlists are generated this way, they can be served using a regular HTTP server such as nginx. To provide sufficient flexibility for various ways of integrating beets remotely (e.g. beets API, beets API with context path, AURA API, mopidy resource URI, etc), the new option has been defined as a template with an `$id` placeholder (assuming each remote integration requires a different path schema but they all rely on using the beets item `id` as identifier/path segment). To prevent local path-related plugin configuration from leaking into a HTTP URL-based playlist generation (invoked with CLI option in addition to the local playlists generated into another directory), setting the new option makes the plugin ignore the other path-related options `prefix`, `relative_to`, `forward_slash` and `urlencode`. Usage examples: * `beet splupdate --uri-format 'http://beets:8337/item/$id/file'` (for beets web API) * `beet splupdate --uri-format 'http://beets:8337/aura/tracks/$id/audio'` (for AURA API) (While it was already possible to generate playlists containing HTTP URLs previously using the `prefix` option, it did not allow to generate ID-based URLs pointing to the beets web API but required to expose the audio files using a web server directly and refer to them using their file system `$path`.) Relates to beetbox#5037
a0b34e0
to
58e5b02
Compare
Basically, I just meant that—if we ever want to have more complex formatting going on here than just substituting a single number with no conversion—we might want a more flexible way to specify the format. But you make a good point that, even if we did that, we might still want beets's |
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.
This all looks great to me!! I like the new name uri_format
; it is a bit more consistent. I'll merge this now!
Beets' web API already allows remote players to access audio files but it doesn't provide a way to expose the playlists defined using the smartplaylist plugin.
This PR makes the smartplaylist plugin provides an option to generate ID-based item URIs/URLs instead of paths.
Once playlists are generated this way, they can be served using a regular HTTP server such as nginx or copied to clients/players.
To provide sufficient flexibility for various ways of integrating beets remotely (e.g. beets API, beets API with context path, AURA API, mopidy resource URI, etc), the new option has been defined as a template with an
$id
placeholder (assuming each remote integration requires a different path schema but they all rely on using the beets itemid
as identifier/path segment).To prevent local path-related plugin configuration from leaking into a HTTP URL-based playlist generation (invoked with CLI option in addition to the local playlists generated into another directory), setting the new option makes the plugin ignore the other path-related options
prefix
,relative_to
,forward_slash
andurlencode
.Usage examples:
beet splupdate --uri-format 'http://beets:8337/item/$id/file'
(for beets web API)beet splupdate --uri-format 'http://beets:8337/aura/tracks/$id/audio'
(for AURA API)beet splupdate --uri-format 'beets:library:track;$id'
(for mopidy-beets)(While it was already possible to generate playlists containing HTTP URLs previously using the
prefix
option, it did not allow to generate ID-based URLs pointing to the beets web API but required to expose the audio files using a web server directly and refer to them using their file system$path
.)Depends on:
Relates to:
To Do
docs/
to describe it.)docs/changelog.rst
to the bottom of one of the lists near the top of the document.)