Commit graph

96 commits

Author SHA1 Message Date
Šarūnas Nejus
7cada1c9f8
Remove no-op decargs 2025-07-08 11:37:33 +01:00
Šarūnas Nejus
c490ac5810
Fix formatting 2025-05-07 10:41:01 +01:00
Max Goltzsche
5d96509cfe
smartplaylist: change encoding of additional field
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).

I introduced the generation of additional EXTM3U item fields earlier this year and I want to correct that now.

**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'll adjust correspondingly after this beets PR was merged).
2025-02-01 01:14:27 +01:00
Šarūnas Nejus
85a17ee503
Reformat the codebase 2024-09-21 11:57:48 +01:00
Max Goltzsche
883bbb3e4b
smartplaylist: rename output format m3u8 to extm3u 2024-04-13 04:55:43 +02:00
Max Goltzsche
c0afd3eb3c
smartplaylist: allow exporting item fields
Allow generating extm3u playlists so that they contain additional item fields such as the `id`.

The feature is required by the mgoltzsche/beets-webm3u plugin (M3U server) to transform playlists using a request based item URI template which may require additional fields such as the `id`, e.g. `beets:library:track;$id`.
2024-04-13 04:55:37 +02:00
Max Goltzsche
58e5b02929
smartplaylist: add --uri-format option
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 #5037
2023-12-16 05:37:27 +01:00
Max Goltzsche
385c05f98e
smartplaylist: change option --extm3u to --output
The boolean flags `--extm3u` and `--no-extm3u` are replaced with a string option `--output=m3u|m3u8`.
This reduces the amount of options and allows to evolve the CLI to support more playlist output formats in the future (e.g. JSON) without polluting the CLI at that point.
2023-12-16 00:23:03 +01:00
Max Goltzsche
222b3a34f9
smartplaylist: expose config as CLI options
Add CLI options to `splupdate` command:
* `--playlist-dir`, `-d`
* `--relative-to`
* `--prefix`
* `--urlencode`
* `--forward-slash`
* `--pretend-paths`
2023-12-15 03:51:27 +01:00
Max Goltzsche
b07a2e42f4
smartplaylist: add extm3u/extinf/m3u8 support
This is to be able to display meaningful metadata and search a playlist within a player without having to load the linked audio files of a playlist.
2023-12-14 01:46:14 +01:00
Serene-Arc
a6e5201ff3 Apply formatting tools to all files
This is 'the big one', which touches every file so that it all conforms
to the given standard.
2023-10-22 09:53:18 +10:00
J0J0 Todos
e9f840580a Trigger subsonicupdate on db_change and splupdate
- Trigger subsonicupdate on database_change event instead of only at import
  event.
- Send a new event from smartplaylist plugin whenever lists are updated/created
  and have subsonicupdate plugin listen to it.
- Make sure the both events register a new listener that launches the actual
  subsonic library update at the very end of a beets run (cli_exit) instead of
  during each change (similar to how mpdupdate plugin does it).
2023-07-27 07:41:50 +02:00
J0J0 Todos
871be9c98b Log smartplaylist create msg as info log
instead of debug log. In an explicit run (not while importing) it doesn't hurt
to get some progress to the UI.
2023-07-25 07:52:51 +02:00
Benedikt
22ca6eff82
Merge pull request #4374 from wisp3rwind/pr_drop_old_python
Drop Python 3.6, some Python 2 + Python <= 3.6 cleanup
2023-02-19 10:19:36 +01:00
wisp3rwind
bd09cc90b6 drop Python 3.6: docs, a few safe simplifications 2022-12-18 09:20:04 +01:00
J0J0 Todos
87ed0f12ea Add --pretend option to splupdate command 2022-12-06 07:03:02 +01:00
Andrew Rogl
ee4268dabb Remove unused imports
Fix imports
Fix formatting
2021-08-26 20:59:48 +10:00
Andrew Rogl
1ec87a3bdd pyupgrade beetsplug and tests
All tests working
More tidy up to be done
2021-08-26 19:12:51 +10:00
Kirill A. Korinsky
b0f7418372
Stream-friendly smart playlists
This commit introduced a way to generate a stream-frienldy playlists.
2021-08-14 02:41:22 +02:00
Jef LeCompte
42e5844564
fix: revert flake8 change 2020-06-04 02:09:04 -04:00
Jef LeCompte
0c3201930c
feat: added github actions
only working with linux for now. exact replica of travis basically.
should probably try to implement the rest of tox or deprecate some
functionality.
2020-05-25 19:35:15 -04:00
MartyLake
076a82daa6 Review: Rename method 2019-07-24 00:09:52 +02:00
MartyLake
dd9de05968 Review: Remove unnecessary split of concat 2019-07-23 23:50:20 +02:00
MartyLake
d1ba309f36 Add a new method that copied pathlib.path.as_posix 2019-07-23 17:17:40 +02:00
Jack Wilsdon
5ad16983d4
Fix miscellaneous typos 2018-10-09 01:11:06 +01:00
Adrian Sampson
8d14e1b6df smartplaylist: Support overlapping playlist defs
See http://discourse.beets.io/t/beets-path-handling-for-delimited-fields/44
2017-03-06 19:07:06 -05:00
michaelbub
0a88338f8b obey style guide 2016-11-11 16:23:32 +01:00
michaelbub
0bdc621d99 sanitizing playlist name AFTER values have been filled in and updated test accordingly 2016-11-11 15:21:34 +01:00
michaelbub
5942adba01 fixed/updated test to consider sanitized playlist names 2016-11-11 10:07:25 +01:00
michaelbub
3e53d4caff sanitize playlist names
Make e. g.
- name: $albumartist/$year-$album.m3u'
work when album data includes non fs-friendly characters
2016-11-10 13:05:18 +01:00
Johnny Robeson
fcbfce3984 replace deprecated log.warn() with log.warning() 2016-08-09 00:33:38 -04:00
Johnny Robeson
e57b7faf69 replace basestring with six.text_types 2016-06-24 05:53:55 -04:00
Johnny Robeson
cb54955485 more bytecasting in smartplaylist plugin 2016-06-15 23:55:17 -04:00
Johnny Robeson
6745759ea5 open even more files in binary mode
* play plugin
* smartplaylist plugin
2016-06-13 05:18:33 -04:00
Adrian Sampson
e54c7eec3d Standardize __future__ imports without parentheses
Since the list is short enough now, we don't need parentheses for the line
wrap. This is a little less ugly.
2016-02-28 15:03:51 -08:00
Adrian Sampson
d53019f9db Further whitespace fiddling
Most commonly, this sticks with:

    log.debug(
        'some long message here'
    )

instead of placing the closing ) at the end of the string literal.
2016-02-28 14:48:10 -08:00
Peter Kessen
30cf407074 Removed import of unicode_literals from plugins
* rewrite
* scrub
* smartplaylist
* spotify
* the
2016-02-20 14:31:27 +01:00
Jack Wilsdon
12cd5306b7 Update copyright dates to 2016 2015-12-30 15:42:06 +00:00
Peter Kessen
3eb8008b11 added encoding as comment in files
added line like
# -*- coding: utf-8 -*-
to all files with correct license in header
2015-11-19 18:41:01 +01:00
Adrian Sampson
48637f22e9 smartplaylist: Handle exceptional cases in setup 2015-11-09 21:52:10 -08:00
Bruno Cauet
8f5bae26fd Smartplaylists: improve tests & code modularization 2015-03-25 10:44:33 +01:00
Bruno Cauet
bcd57bd2b5 Test queries building sort management in smartplaylist
Slighly modify Sort parsing: avoid building MultiplSort() instances
comptised of a single sort, but return that sort instead, since it wraps
things with any gain.
2015-03-18 18:53:41 +01:00
Bruno Cauet
45c0c9b3cb Deal with sorting
Try to follow any sort found & manage absence of sort. When there are
multiple sort directives given, concatenate them.

Tests not extended yet.
2015-03-18 18:09:42 +01:00
Bruno Cauet
65b52b9c48 python 2.6 compat: don't use set literals
In smartplaylist and test_smartplaylist.
2015-03-16 19:42:54 +01:00
Bruno Cauet
b79c025142 CLI tests for smartplaylist plugin
No import CLI test.
2015-03-16 18:36:08 +01:00
Bruno Cauet
40e793cdb1 Fix flake8 errors 2015-03-16 16:25:43 +01:00
Bruno Cauet
774decda7d Smartplayist: parse_query_parts() → ...ry_string() 2015-03-16 16:21:49 +01:00
Bruno Cauet
2d9f665848 Smartplaylist: offer "splupdate <playlist names>"
splupdate command of the SmartPlaylistPlugin looks in "args" for matches
of playlist names.
2015-03-16 16:03:14 +01:00
Bruno Cauet
f06c33cb71 Smartplaylist: update only if item changed 2015-03-16 15:16:40 +01:00
Bruno Cauet
4bfa439ee1 database_change: send model that changed 2015-03-16 14:32:37 +01:00