Commit graph

166 commits

Author SHA1 Message Date
Carl Suster
28db7d3d33 bpd: provide precision time in status 2019-04-02 11:15:00 +11:00
Carl Suster
4be2e1b5e6 Remove beets.util.inspect wrapper 2019-04-02 10:22:47 +11:00
Carl Suster
36c85a8aeb Fix beets.util.inspect for Python 3
Under the original compatibility shim we weren't correctly inclusing
`self` in the argument list for bound methods.
2019-04-02 10:11:43 +11:00
Carl Suster
9622e7433b bpd: return real audio data 2019-04-02 09:44:34 +11:00
Carl Suster
e839e4ea19 bpd: improve exception handling
Check function signature instead of using TypeError to crudely guess
that the wrong number of arguments were provided.

Prevent bpd from crashing when trying to log a traceback. The
`traceback.format_exc` function takes an optional argument which is
supposed to be an integer restricting the length of the backtrace to
show. Instead we were passing the exception object to this function and
causing a new exception to be raised.
2019-04-02 09:39:07 +11:00
Carl Suster
146c5f5e13 bpd: fix repeat, consume and single in reverse
These flags are all relevant to the 'previous' command as well as the
'next' command.
2019-04-01 18:05:10 +11:00
Carl Suster
12e49b3c88 bpd: skipping backwards through zero keeps playing
Previously issuing the 'previous' command when at position 0 on the
playlist would cause bpd to stop playing. MPD instead just restarts the
currently playing song instead, so we now match this behaviour.
2019-04-01 17:51:21 +11:00
Carl Suster
a4fe6875a1 bpd: fix bug in bounds check of current song index
The songs are indexed starting from zero for the play command, however
the bound check was off by one. An index matching the length of the
playlist would crash the server instead of responding with an error
message over the protocol.
2019-04-01 17:41:25 +11:00
Carl Suster
0c3a63ef9f bpd: fix repeat mode behaviour
The repeat flag indicates that the entire playlist should be repeated.
If both the repeat and single flags are set then this triggers the old
behaviour of looping over a single track.
2019-04-01 17:39:35 +11:00
Carl Suster
b245c0e755 bpd: test fields returned by status command 2019-04-01 16:42:39 +11:00
Carl Suster
bae9c40600 bpd: support the single command
This command instructs bpd to stop playing when the current song
finishes. In the MPD 0.20 protocol this flag gains a value 'oneshot' but
for now we just support its older version with a boolean value.
2019-04-01 16:30:02 +11:00
Carl Suster
71e7621642 bpd: no-op support for persistent playlists
The real MPD offers persistent playlist manipulation, storing the
playlists in a directory set in the config file. If that directory is
not available then the feature is disabled and the relevant commands all
respond with errors. Based on this, the initial support in bpd just
returns errors matching the MPD server in the disabled mode.

For playlistadd, extend the _bpd_add helper to work with playlists other
than the queue in order to support testing the real implementations of
these commands in the future.
2019-04-01 16:30:02 +11:00
Carl Suster
859e16d1e3 bpd: support consume command 2019-04-01 16:30:02 +11:00
Carl Suster
e5851866d7 bpd: add replay_gain_* commands
There's a special status command for checking the replay gain mode,
which can be set to one of a short list of possible values. For now at
least we can ignore this feature, but track the setting anyway.
2019-04-01 14:49:27 +11:00
Carl Suster
67a0b38d20 bpd: add dummy command for volume
MPD supports a deprecated command 'volume' which was used to change the
volume by a relative amount unlike its replacement 'setvol' which uses
an absolute amount. As far as I can tell 'volume' always responds with a system
error message "No mixer".
2019-04-01 14:49:27 +11:00
Carl Suster
1511e313f7 bpd: add mixramp commands
These are a more sophisticated version of crossfade so we're free to
ignore them, at least for now. We now track the values of the two
settings, and show them in the status output. Like MPD, we suppress the
mixrampdb value if it's set to nan, which is how it signals that the
feature should be turned off.
2019-04-01 14:49:27 +11:00
Carl Suster
0f53ae9a87 bpd: error instead of crashing on extra argument
If an MPC client is expecting a command to take an argument that bpd
isn't expecting (e.g. because of a difference in protocol versions) then
bpd currently crashes completely. Instead, do what the real MPD does and
return an error message over the protocol.
2019-04-01 14:49:27 +11:00
Carl Suster
d94a5393b2 bpd: fix crossfade command
Although crossfade is not implemented in bpd, we can store the setting
and repeat is back to clients. Also log a warning that the operation is
not implemented.

The real MPD doesn't show the crossfade in status if it's zero since
that means no crossfade, so now we don't either.
2019-04-01 14:49:27 +11:00
Carl Suster
b4c4f3ca19 bpd: use plugin logger instead of global logger 2019-03-31 22:06:43 +11:00
Carl Suster
7557bb06d6 bpd: use log instead of stdout 2019-03-31 18:43:18 +11:00
Adrian Sampson
958ad430fc bpd: Use integers for time values (fix 2394) 2017-01-17 11:37:10 -08:00
Adrian Sampson
a063336446 Fix #2332: Unicode trouble in bpd 2016-12-20 15:16:46 -05:00
Johnny Robeson
7a2bdf502f s/utf8/utf-8/ in all encoding/decoding contexts
This matches up with the python documentation.
2016-09-06 23:10:24 -04:00
Adrian Sampson
58afaf07a5 Switch to new noqa syntax for flake8 3.0
Apparently, `# noqa ignore=X` worked before, but now the syntax is more terse,
like this: `# noqa: X`.

See the changelog here:
http://flake8.pycqa.org/en/latest/release-notes/3.0.0.html
2016-07-25 15:02:10 -04:00
Johnny Robeson
a1edf1928d treat bpd command and args as strings, not bytes 2016-07-10 19:21:52 -04:00
Johnny Robeson
cb6efc4c22 Reorganize Gst import and version req in bpd
This avoids

```sh
PyGIWarning: Gst was imported without specifying a version first. Use
gi.require_version('Gst', '1.0') before import to ensure that the right
version gets loaded.
```

by silencing E401 import ordering warning
2016-07-08 05:48:26 -04:00
Adrian Sampson
5efd5b21c5 Use new as_str method
Instead of `get(six.text_type)`, which was a surprisingly large portion of our
uses of six.
2016-06-25 19:16:14 -07:00
Adrian Sampson
e16cc58cb9 Walk back some six.iter* uses
In places where it doesn't much matter whether we use an iterator or the old
Python 2 list way, using the six name just hurts legibility.
2016-06-25 18:29:55 -07:00
Johnny Robeson
edb1cbc5fc replace iter{items|values} with six.iter{items|values} 2016-06-24 05:53:55 -04:00
Johnny Robeson
e57b7faf69 replace basestring with six.text_types 2016-06-24 05:53:55 -04:00
Johnny Robeson
e8afcbe7ec replace unicode with six.text_type 2016-06-24 05:53:49 -04:00
Johnny Robeson
4649226b9b use urllib from six.moves 2016-06-23 04:40:18 -04:00
Johnny Robeson
1f8fe0f9a6 use _thread from six.moves 2016-06-23 04:40:18 -04:00
Philipp Beckmann
f9ed53a096 Multiple corrections as advised in the codereview 2016-06-20 18:44:37 +02:00
Philipp Beckmann
7b154cedd7 Added double line spacings between definitions 2016-06-20 18:29:46 +02:00
Philipp Beckmann
9fd227c8cc Fixed flake8 errors 2016-06-20 18:22:07 +02:00
Philipp Beckmann
5613d9d4ea bpd: Added correct error check for query_position/query_duration 2016-06-20 18:09:37 +02:00
Philipp Beckmann
0917e675d7 bpg: Converted gstplayer.py to GStreamer 1.0 2016-06-19 22:06:55 +02:00
Adrian Sampson
71b9fd785c Revert "Do __name__ comparison with bytes and not unicode"
This reverts commit 9c41c39913.
That commit used byte strings for the `if __name__ == '__main__'` pattern,
which was necessary when we were doing unicode_literals. But it is wrong on
Python 3, and now that we're liberated from unicode_literals, we need to go
back to native strings for this comparison.
2016-05-29 19:19:59 -07: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
Peter Kessen
5db57bdc01 Removed unicode_literals from plugin bpd 2016-02-20 11:57:36 +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
90178ab380 Always log a template literal (fix #1481)
Otherwise, we risk the user-provided string looking like a format string! If
it contains curly braces, it can behave unexpectedly.
2015-05-28 23:44:41 -04:00
Adrian Sampson
8ae0317014 bpd: Process commands as bytes (fix #1388) 2015-03-31 07:13:13 -05:00
Adrian Sampson
07516b2bca Redact some passwords in plugins 2015-03-27 22:42:28 -04:00
Adrian Sampson
e7f8a627e9 Style fixes for pep8 1.6 2015-02-07 12:51:54 -08:00
Bruno Cauet
a5026100a3 All plugins use unicode_literals
Given that part of them has no test I may have broke them
2015-01-20 16:22:27 +01:00
Bruno Cauet
02d8e88ef1 Replace all mentions of 'str' with 'bytes' 2015-01-20 12:48:15 +01:00
Bruno Cauet
9c41c39913 Do __name__ comparison with bytes and not unicode 2015-01-20 12:03:57 +01:00
Bruno Cauet
90b388b775 Use __future__ imports but unicode_literals everywhere
Include import of __future__ features division, absolute_imports and
print_function everywhere. Don't add unicode_literals yet for it is
harder to convert.

Goal is smoothing the transition to python 3.
2015-01-19 12:25:16 +01:00
Bruno Cauet
b27c5304d1 Merge branch 'master' into logging
Conflicts:
	beetsplug/fetchart.py
	beetsplug/mpdstats.py
2015-01-09 15:15:27 +01:00
Frederik “Freso” S. Olesen
4b1f0cbf48 Happy 2015. ;)
See 7a410f636b

Command used:

    git grep -l 'Copyright 201'|xargs sed -i -E 's/Copyright 201./Copyright 2015/'`
2015-01-08 21:37:09 +01:00
Bruno Cauet
23e6760e19 Partial rollback of bpd logging 2015-01-08 17:55:40 +01:00
Bruno Cauet
74e18afa94 Convert bdp: pass around with static setter on classes 2015-01-06 21:42:09 +01:00
Bruno Cauet
b8211a3c4c Every plugin uses its own logger
logging.getLogger(__name__) everywhere!
Several loggers prefixed every log message with [logername], which we
delete here.
2015-01-06 10:35:44 +01:00
Bruno Cauet
30f158a95e Move "from beets import logging" statements
Move the import next to other beets-related imports
2015-01-05 10:05:21 +01:00
Bruno Cauet
7df8bef8b7 Update logging imports: logging → beets.logging 2015-01-04 17:02:27 +01:00
Ralf Sieger
ab5c5dcfd5 added option for initial volume setting 2014-09-30 09:34:04 +02:00
e5e4eaeacd39c5cfba4d7c852c48277ae50331e6
66aee8094f Clean up of logging messages as described here
All logging now prefers the ' (single quote) over the " (double quote)

https://github.com/sampsyo/beets/wiki/Hacking
2014-09-09 11:28:43 +10:00
Adrian Sampson
e5a9db1cac fix up some indentation warnings in plugins 2014-04-13 17:55:49 -07:00
Fabrice Laporte
3ead936fe5 flake8 cleaning beetsplug/*
Remaining warnings are related to visual indentation.
2014-04-13 23:24:57 +02:00
Thomas Scholtes
f6f974ec87 Remove ITEM_* constants
We might consider renaming `Item._fields` to `Item.fields` since other parts of
beets use it as a replacement for `ITEM_KEYS`.

See also #650.
2014-04-10 17:11:21 +02:00
Thomas Scholtes
4b1a1e3d65 Remove ITEM_KEYS_WRITABLE 2014-04-04 00:03:40 +02:00
Adrian Sampson
9ee4adc5e1 move remaining generic Query types to dbcore.query
NumericQuery is still broken. This, of course, is the whole reason for the
change.
2014-01-20 16:40:50 -08:00
Adrian Sampson
cbbb38c417 new BytesQuery factors out MatchQuery's path logic 2014-01-13 16:17:30 -08:00
Adrian Sampson
c5032f925e move Destination method to Item class 2013-09-17 09:09:10 -07:00
Adrian Sampson
ec10f8c223 remove count() calls
I removed this method in an earlier commit.
2013-08-20 14:28:28 -07:00
Simon Chopin
e30f8f8fb9 bpd: Use AnyFieldQuery when searching "any" fields
BPD hadn't been ported when AnySubstringQuery was removed, resulting in
crash, death and horror when using the search function.
2013-07-02 11:00:10 +02:00
Adrian Sampson
89689899c9 changelog note and indentation fix for #86 2013-02-02 12:27:42 -08:00
steini
476adf40af Support for AlbumArtist and AlbumArtistSort tag listings. 2013-02-01 02:35:19 +00:00
Adrian Sampson
7a410f636b happy new year
For future reference, this command did the trick:
ack -l 'Copyright 201' | xargs perl -pi -E 's/Copyright 201./Copyright 2013/'
2013-01-11 10:43:41 -08:00
Adrian Sampson
4a5594bec6 begin adding convenient plugin defaults
We need plugins to set their config values at run time instead of module import
time. That is, defaults should be put in the __init__ method. This is easy
enough, but to make it even more convenient, I added a BeetsPlugin.config
field, which is a Confit view into a subsection of the configuration named
after the plugin.
2012-12-18 20:42:42 -08:00
Adrian Sampson
6c94358b13 begin Confit-ifying plugins in alphabetical order 2012-12-13 12:31:10 -08:00
Adrian Sampson
7158c01ff8 clean up outdated FIXMEs 2012-10-27 18:47:04 -07:00
Adrian Sampson
749b19955e bpd: use pygst.require() before importing gst
A user reports that this fixes BPD on OS X.
2012-09-12 17:57:37 -07:00
Adrian Sampson
26fa3bcac6 remove outdated call in BPD 2012-07-24 14:26:47 -07:00
Adrian Sampson
e634b95996 Merge pull request #40 from djrtl/upstream
Fixed an issue with a readline from socket in bpd
2012-06-03 22:53:57 -07:00
Matteo Mecucci
469fb95e3e Added a second check for empty line in bpd after my latest change 2012-06-03 22:07:16 +02:00
Matteo Mecucci
df25de89f7 Fixed an issue with a readline from socket in bpd 2012-06-03 11:40:57 +02:00
Adrian Sampson
d82d74b422 move bluelet to util subpackage
This way, it can be shared among multiple plugins (as could happen
eventually...)
2012-05-13 21:22:50 -07:00
Adrian Sampson
760fff3ace use new "except ... as ...:" syntax
This replaces the older "except ..., ...:" syntax.
2012-05-13 21:18:50 -07:00
Adrian Sampson
429af42e14 use print_function __future__ import
All code should now use Python 3-style "print"s.
2012-05-13 21:08:27 -07:00
Adrian Sampson
b68e87b92c The Great Trailing Whitespace Purge of 2012
What can I say? I used to use TextMate!
2012-05-13 20:22:17 -07:00
Matteo Mecucci
030c656a75 Added support for random and repeat in the bpd plugin. 2012-05-08 22:53:17 +02:00
Adrian Sampson
a28f930c52 transaction objects to control DB access
In an attempt to finally address the longstanding SQLite locking issues, I'm
introducing a way to explicitly, lexically scope transactions. The Transaction
class is a context manager that always fully fetches after SELECTs and
automatically commits on exit. No direct access to the library is allowed, so
all changes will eventually be committed and all queries will be completed. This
will also provide a debugging mechanism to show where concurrent transactions
are beginning and ending.

To support composition (transaction reentrancy), an internal, per-Library stack
of transactions is maintained. Commits only happen when the outermost
transaction exits. This means that, while it's possible to introduce atomicity
bugs by invoking Library methods outside of a transaction, you can conveniently
call them *without* a currently-active transaction to get a single atomic
action.

Note that this "transaction stack" concepts assumes a single Library object per
thread. Because we need to duplicate Library objects for concurrent access due
to sqlite3 limitation already, this is fine for now. Later, the interface should
provide one transaction stack per thread for shared Library objects.
2012-05-06 23:24:05 -07:00
Adrian Sampson
fa3e41c86a BPD: print messages reflecting tree (re)build 2012-04-30 12:02:00 -07:00
Matteo Mecucci
43cebabcb6 Added sorting in listing command of bpd 2012-04-15 17:05:16 +02:00
Adrian Sampson
22e8695172 BPD: use playbin2 instead of playbin (#364) 2012-03-21 14:25:01 -07:00
Simon Chopin
52a34c7510 Fix the list command in BPD
The cmd_list method wasn't a generator as run() expected, but instead
loaded directly the data onto the connection withoutactually sending it.
2012-02-17 20:15:25 +01:00
Adrian Sampson
fed9e206c0 sync with latest bluelet version (824609773a85) 2011-12-14 14:11:49 -08:00
Adrian Sampson
59b4338f81 fix BPD lsinfo results for libmpc (#277) 2011-12-14 14:04:00 -08:00
Adrian Sampson
f48fefdf61 merge 2011-09-18 15:39:38 -07:00
Adrian Sampson
6fbe69d454 spelling errors in comments 2011-09-18 13:00:36 -07:00
Adrian Sampson
9d1870af16 fix reference to old greenlet client 2011-09-05 13:06:01 -07:00
Adrian Sampson
7310e9ea10 fix playlist versioning & directory recursion in BPD 2011-05-07 12:08:13 -07:00
Adrian Sampson
e5e11503ad a couple more cursor closings 2011-05-05 18:26:29 -07:00
Adrian Sampson
8341dee3ab reorder items() and albums() parameters to reflect common use 2011-05-05 17:20:24 -07:00
Adrian Sampson
3e90579a6c BPD uses new VFS as a backend (#131) 2011-05-05 17:00:05 -07:00
Adrian Sampson
30080bc520 fix memory leak in bluelet, syncing with latest source (#151) 2011-04-21 21:40:28 -07:00