Commit graph

534 commits

Author SHA1 Message Date
Diego Moreda
70cefb516f Prompt event style changes and cleanup
* Rename "ExtraChoice" to "PromptChoice", and add an attribute for the short
letter used by the choice (short).
* Add TerminalImportSession._get_plugin_options() for isolating the sending
of the event and the processing of the returned values (flattening, check for
letter conflicts).
* Remove unnecessary TODO lines and other style cleanups.
2015-12-15 19:43:31 +01:00
Diego Moreda
a15dffad1d Add "before_choose_candidate" event
* Add "before_choose_candidate" event, sent to the plugins during
TerminalImportSession.choose_match(). This event allows plugins to append
additional choice to the user prompt during importer.
* The event is sent on the main loop of choose_match(), with session and task
parameters. The plugins are responsible for checking the task status in order
to append choices in a sensible way.
* Add "ExtraChoice" namedtuple to improve readability and encapsulate the
concept of a single extra choice.
2015-12-11 15:58:52 +01: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
d5b7ce64da Move EDITOR discovery to a util function 2015-11-14 13:23:51 -08:00
Adrian Sampson
80bfd186ae Use should_write for modify, update, and mbsync
This should address the surprising situation in #1697, where `import` went
fine but then `update` unexpectedly changed filenames.
2015-11-07 13:34:47 -08:00
Adrian Sampson
5b761f029e A new should_write configuration wrapper
The idea is that it is so common to check whether we need to write tags (or
move files), and we're constantly re-implementing the same logic everywhere.
It's not even the prettiest logic, as it commingles the importer settings with
general settings. So it's important that we encapsulate the decision so we can
make it better in the future.
2015-11-07 13:14:33 -08:00
Adrian Sampson
cc5aba8294 Roll back PR #1358: regression on recent duplicate
This should fix #1652, which found that this code did the wrong thing when
there were *no* `found_duplicates`: that is, when the duplicate actually came
from the `seen_keys` list, so the album is not in the database yet. This
handling was confusing "no non-empty duplicates" with "no in-database
duplicates", and incorrectly bypassing the duplicates prompt.

Since having empty albums in the database is a rare case (it should be
impossible!), and we should no longer *crash* when it happens, I am
considering it unnecessary to handle it specially. The user will now just see
"Old: 0 items" and that's that.
2015-10-24 12:46:27 -07:00
nath@home
9c663432bd Refactor util/interactive_open: multiple targets
interactive_open should now be invoked with at least the list of
targets and optionally the command to open the targets with.
This allows beets-play to pass multiple file paths directly to
the configured command.

The changes to the existing invocations are pretty trivial in
order to comply to this refactor.
2015-09-01 23:42:42 +02:00
Adrian Sampson
9e83c76762 Changelog for #1582 2015-08-29 12:57:59 -07:00
Adrian Sampson
3f490440b6 Reduce footprint of #1582
No need for a separate function since we only use this once.
2015-08-29 12:56:39 -07:00
Peter Kessen
b857320105 fixed tox style suggestions
also following the "no contrived examples" rule by using
beatles as artist in example
2015-08-28 08:47:25 +02:00
Peter Kessen
eb68d4ddb5 Added extra output for help with subcommand list
An example including output format is given now
2015-08-26 18:38:04 +02:00
Adrian Sampson
5420599839 New all_keys() method on dbcore.Model
Rather than the ad-hoc one on library classes. This also avoids some confusing
duplication in the `beet fields` output, at the cost of turning off the plugin
distinction.
2015-07-28 22:27:43 -07:00
Tom Jaspers
12295376eb Create empty user config file if it does not exist
Running `beet config -e` with a non-existing configuration file
does not always work (e.g., OSX uses `open` by default, which requires
the file to exist). This could occur during e.g. initial setup.

Resolve #1480
2015-07-07 22:56:02 +01:00
Jesse Weinstein
6df54f35ec Fix flake8 warnings 2015-06-26 00:46:30 -07:00
Jesse Weinstein
fa7b780b86 Fix singular/plural issue in move subcommand. 2015-06-24 23:08:28 -07:00
Jesse Weinstein
85244ec177 Fix singular vs plural noun usage 2015-06-24 22:53:16 -07:00
Tom Jaspers
be484f2af0 Implement --pretend option for the move command
The method `show_path_changes` takes a list of tuples (source, destination)
that will be printed on either single / double line, as proposed in #1405.
2015-05-20 13:03:18 +02:00
Pedro Silva
132dc4c617 refactor fields_func logic into Item/Album __dir__ 2015-05-16 15:49:42 +02:00
Barsanuphe
f72172aaa2 Fixed variable referenced before assignment. 2015-04-16 23:44:49 +02:00
Adrian Sampson
58c3e43b78 Ensure we always send bytes to sys.stdout
This is most pertinently important for interacting with nose's
output-capturing, which crashes when we mix bytes and unicode output. It's
also nice to have just for consistency.

Maybe we should enforce in the future that `print_` only gets Unicode
arguments. It's a pain supporting bytes calls and we should really only be
outputting text.

Python 3 can't come soon enough. 😢
2015-04-14 11:28:16 -07:00
Adrian Sampson
018f479ced Revert extra variables and whitespace from #1402 2015-04-07 22:50:37 -05:00
multikatt
c32bb850ca Remove redundant sort() 2015-04-07 21:26:30 -04:00
multikatt
956fa2cc52 Sorting printing of fields 2015-04-07 21:21:03 -04:00
Adrian Sampson
8452a1645c Sort plugin names in version output 2015-04-05 14:28:07 -07:00
Adrian Sampson
c37561c74b Redact by default (#1376) 2015-03-29 14:26:16 -07:00
Adrian Sampson
37860bf2ef --redacted is now --redact
Seems more direct to me.
2015-03-27 22:44:32 -04:00
Adrian Sampson
b477f4a53f Merge pull request #1376 from tomjaspers/config-redacted-fields
Config: new option -r redacts sensitive fields

Conflicts:
	beets/util/confit.py
2015-03-27 22:11:24 -04:00
Tom Jaspers
778138f2cd Config: redact sensitive fields with -r option
- `config -r` will show 'REDACTED' instead of the actual value
- Has a default list of field names that should be redacted (e.g., 'password')
- Plugins can add redacted fields that they introduce
2015-03-24 17:00:37 +01:00
Bruno Cauet
9b5d78bad0 Fix album emptiness test in duplicates resolution
Fix #1367.
Tests are missing for I've not found yet a satisfying way to build them.
2015-03-23 19:11:09 +01:00
Bruno Cauet
bcfdcdc4b7 Automatically remove dups when they're all empty 2015-03-18 17:38:24 +01:00
Bruno Cauet
8e25a70e40 summarize_items(): sort format by decr. freq
Make the summary deterministic.
2015-03-16 14:41:43 +01:00
Bruno Cauet
18fc0cd3de summarize_items(): work even with 0 items
It crashed on empty albums.

Fix #1357
2015-03-16 14:28:56 +01:00
Bruno Cauet
6234fee67d Option parser: add common options with a method
Add a new OptionParser subclass: CommonOptionsOptionParser, which
provides facilities for adding --album, --path and --format options. The
last one is quite versatile.

Update base commands (from beets.ui.commands) to use those.
2015-03-05 15:01:20 +01:00
Adrian Sampson
ca0e9a8c03 Merge pull request #1329 from brunal/play-interactive
play command is now interactive

Conflicts:
	docs/changelog.rst
2015-02-17 17:22:03 -05:00
Bruno Cauet
c47221555f Add beets.util.interactive_open() find cmd + execute
interactive_open() takes a target and an optional command, if it does not
receive a command then it uses open_anything().

It parses command and lexes it with shlex.split(), revieling the client
from that task.

"config -e" command uses it, and gives a better error message in case of
problem. "play" plugin uses it as well, as side-effect being that the
command is now interactive, as requested in issue #1321.

Fix issue #1321.
2015-02-16 12:26:17 +01:00
Bruno Cauet
5d9128aff3 util.interactive_open() return open/xdg-open/start
Depending on the platform return the correct automatic execution
command.
2015-02-16 11:35:13 +01:00
Tom Jaspers
d70a82449e Fields: show computed and flexible fields
- Computed fields from the _getters
- Flexible fields for which a type is defined
  (in _types or in a plugins' item_types/album_types)

Fix #1030
2015-02-16 10:34:35 +01:00
Bruno Cauet
d267741ff3 Delete 'format' variables that shadow the built-in
Also cleanup the 'the' plugin a bit: delete unused variables.

Relates to #1300.
2015-02-11 16:26:16 +01:00
Tom Jaspers
1341ad9b1d Importer UI: Display number of missing/unmatched tracks
Fix #1088
2015-02-03 10:23:52 +01:00
Tom Jaspers
6ed0b2e0f3 Expose an Item's filesize as a field
- Update test-case for info to make sure the item's path is pointing to an actual file.

See #1291
2015-02-02 21:52:23 +01:00
Tom Jaspers
43e9044843 Duplicate album-import summary shows old/new filesize
E.g.:
Old: 13 items, MP3, 256kbps, 44:32, 101MB
New: 13 items, MP3, 320kbps, 44:31, 128MB

Fix #1291
2015-01-31 22:11:43 +01:00
Tom Jaspers
927a53d59b Merge pull request #1281 from tomjaspers/configurable-colors
Colors are now user configurable.

Conflicts:
	beets/ui/__init__.py
	beets/ui/commands.py
2015-01-30 13:48:19 +01:00
Tom Jaspers
f483012183 Colorize is now to be called with the abstract color_name instead of the color.
E.g., `colorize('text_success', 'hello world')`

To ensure compatibility with 3rd party plugins, a valid color ('red') can still be passed,
but it will be logged.
2015-01-29 14:33:57 +01:00
Adrian Sampson
790c41a73d write: Do not try to write non-writable fields
Fix #1268.
2015-01-27 15:03:19 -08:00
Adrian Sampson
b8dab9cf9f Merge pull request #1247 from brunal/future
Use all __future__ imports in beets core

Conflicts:
	beetsplug/web/__init__.py
	test/test_embedart.py
2015-01-26 17:02:07 -08:00
Bruno Cauet
4aba4320e6 Rollback ui.print_() auto-conv of args to string
Since this raises problems the best is probably to maintain the base
behaviour: expect byte strings or unicodes.
2015-01-26 23:47:12 +01:00
Bruno Cauet
4e904c78af Simplify LibModel format management
Delete `ui.format_` and then `ui.print_obj`. Simply ensure that when
there is no format it defaults to '' = default format = config option.
2015-01-26 23:09:56 +01:00
Tom Jaspers
d3fce35481 Colors are user configurable
- Colors are mapped on to a dictionary using abstract names (e.g., text_success)
- Add `colors` option under `ui` to allow users to choose their own color scheme
- Move configuration option `color` from top-level to `ui`
- Show deprecation warning if top-level `color` configuration is used (but respect it)

Fix #1238
2015-01-26 17:24:32 +01:00
Bruno Cauet
065cb59ce7 Restore show_change() logging: MatchInfo, not Item 2015-01-26 09:44:51 +01:00
Bruno Cauet
8165dec985 Delete manual formattings of album & item 2015-01-25 21:32:22 +01:00
Bruno Cauet
62cd6e37aa Update ui.print_obj_(), add ui.format_()
Code now relies on `format()` for items and albums displaying/logging.
`ui.print_()` calls `unicode()` or `str()` on the strings so for most
usages calling `ui.print_(obj)` replaces `ui.print_(obj, lib, None)`.

Where there is a special format `ui.print_(format(obj, fmt))` is fine,
but when `fmt` can be None then one has to call
`ui.print_(ui.format_(obj, fmt))` -- which is what `ui.print_obj` now
does.
2015-01-25 21:07:03 +01:00
Bruno Cauet
f263935a51 Prevent shlex.split from returning strange encodings 2015-01-20 16:57:20 +01:00
Bruno Cauet
8dd7bf0f0b unicode_literals in beets.ui and beets.autotag
Well, that was easy!
2015-01-19 17:18:50 +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
Adrian Sampson
6f2d9845b5 Add an assertion for summarize_items (#1232) 2015-01-17 14:20:53 -08:00
Bruno Cauet
8418fb6083 Use a standard logger for the import log
The import log now relies on a standard logger, named 'beets.importer'
and configured upon initialization of the import session.
2015-01-12 21:47:44 +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
Adrian Sampson
f6dc2cd81c Merge pull request #1198 from brunal/logging
Lazy {}-style logging everywhere
2015-01-05 17:34:30 -08: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
Adrian Sampson
e13e7ed727 config -e: Parse arguments in $EDITOR (fix #1200) 2015-01-04 17:46:08 -08:00
Adrian Sampson
1f3fc60bad Add missing space (fix #1199) 2015-01-04 17:35:16 -08:00
Bruno Cauet
f5c5666729 Attain pep8-cleanliness
No more E12 or E501
2015-01-04 17:29:31 +01:00
Bruno Cauet
7df8bef8b7 Update logging imports: logging → beets.logging 2015-01-04 17:02:27 +01:00
Bruno Cauet
e75f9a703d Convert beets core to lazy logging 2015-01-04 17:02:27 +01:00
Adrian Sampson
a892128996 Changelog and rewording for import --pretend
(#1162)
2014-12-23 09:10:28 -05:00
Malte Ried
440fe9a2ea Reduced the count of accesses of the pretend config option. Now it's only one place where it is read.
Changed the output to use the log system rather than print_.
2014-12-21 21:37:44 +01:00
Malte Ried
2db346388a Added option --pretend to only print the filenames of files to import without importing them 2014-12-21 15:56:56 +01:00
Thomas Scholtes
a5f097a883 Allow invalid configuration files to be edited
Fixes #1123.
2014-12-01 13:02:21 +01:00
Adrian Sampson
14b150090e Fix #1124: avoid crash when deleting fields 2014-11-30 11:42:40 -08:00
Adrian Sampson
2343387a68 beet stats output clarification (#1052)
Explicitly say that size calculation is approximate.
2014-11-01 12:46:14 -07:00
Adrian Sampson
44ff3f782a Remove prefix diff highlighting
This was well-intentioned but ended up being more confusing than it was worth.
It's always confused me when one digit gets un-highlighted in one of these
displays. The straw that broke the camel's back was when I got a "#1 -> #16"
change where the numeral "1" was un-highlighted. To fix this right would be
way more trouble than it's worth; I'm glad to be rid of this detail.

Conflicts:
	docs/changelog.rst
2014-10-04 16:47:00 -07:00
Adrian Sampson
2795a01e28 Default sort configuration is global (#953)
It would be nice to cache the Sort object so we didn't have to re-parse this
every time...
2014-09-16 14:34:21 -07:00
Adrian Sampson
72436644a6 Merge pull request #909 from arogl/master
Clean up of logging messages as described here
2014-09-14 13:14:35 -07:00
Thomas Scholtes
1613a199fa Combine try_write() and store() as try_sync()
This makes sure we store the updated file `mtime`. By providing the
same interface on `Album` and `item` we can also reduce some code
duplication in the `modify` command.
2014-09-14 14:44:32 +02:00
e5e4eaeacd39c5cfba4d7c852c48277ae50331e6
d3386df056 Merge remote-tracking branch 'origin/master'
Conflicts:
	beets/importer.py
	beets/ui/commands.py
	beetsplug/lyrics.py
2014-09-09 12:05:38 +10:00
e5e4eaeacd39c5cfba4d7c852c48277ae50331e6
816e4fb152 clean up after rebase 2014-09-09 11:53:44 +10:00
e5e4eaeacd39c5cfba4d7c852c48277ae50331e6
2100dab379 displayable_path clean up error 2014-09-09 11:31:45 +10:00
e5e4eaeacd39c5cfba4d7c852c48277ae50331e6
65de93941d flake8 cleanup
Cleanup after cleanup
2014-09-09 11:28:43 +10: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
b227aabfee Merge pull request #917 from geigerzaehler/stats
Improvements for stats command
2014-08-25 08:44:55 -07:00
Thomas Scholtes
6d67365df6 PEP8 fix 2014-08-25 17:17:02 +02:00
Thomas Scholtes
9f4b3b811d Refactor modfiy command and tests
Parsing of the modify command line is handled by `modfiy_parse_args()`.
Test use the command line.
2014-08-25 15:46:57 +02:00
Thomas Scholtes
2d2c84b505 Stats only count albums in the database
Items might have the `album` field set without belonging to an album in
the beets database. We only count the albums that are represented in
the database.
2014-08-25 11:34:40 +02:00
Thomas Scholtes
9e2b6d0253 Show album artist stats
See #855
2014-08-25 11:33:10 +02:00
e5e4eaeacd39c5cfba4d7c852c48277ae50331e6
5f5ee40172 displayable_path clean up error 2014-08-23 12:17:24 +10:00
e5e4eaeacd39c5cfba4d7c852c48277ae50331e6
89c5448ef5 flake8 cleanup
Cleanup after cleanup
2014-08-23 11:26:44 +10:00
e5e4eaeacd39c5cfba4d7c852c48277ae50331e6
bd3f1ca5c0 Merge branch 'master' of https://github.com/sampsyo/beets 2014-08-23 11:00:23 +10:00
e5e4eaeacd39c5cfba4d7c852c48277ae50331e6
a8daba2a75 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-08-23 09:26:34 +10:00
Adrian Sampson
eb579cf14b Merge pull request #823 from PierreRust/sortquery
Sorting support in beets query mecanism (dbcore)
2014-08-22 14:59:44 -07:00
Harry Khanna
4944686090 Change flag from --always to --force for symmetry with other beets commands 2014-08-19 14:07:17 -04:00
Harry Khanna
2ffd3e287f Add --always flag for write subcommand
Forces a write of tags to file even if the file's tags match the database.
This is useful to force plugins that respond to write (e.g., Scrub and Zero) to run on those tags.
This may also make the TODO comment in zero.py less important since creates a way to manually run the zero plugin on a file imported as-is.
2014-08-19 13:43:16 -04:00
Adrian Sampson
a45415fd77 Duplicate summaries work with singletons (#900) 2014-08-18 22:07:50 -07:00
Adrian Sampson
0ec285f96c Formatting and style refinements for #900 2014-08-18 21:37:13 -07:00
Howard Jones
4aa783f09d Final reshuffle to put summarize_items in beets.ui
Also improved duration display.
2014-08-18 12:21:45 +01:00
Howard Jones
3ec7426a35 Pass found duplicates between task and session 2014-08-18 10:35:01 +01:00
Howard Jones
a15cf2b001 Moved summarize_items to utils. Cleaned up output
Output now uses K for bitrate.
summarize function now in util
2014-08-18 08:57:59 +01:00
Howard Jones
4bf07aa8a6 Changed to not require collections
collections library is only available in Py 2.7+
2014-08-17 19:11:01 +01:00
Howard Jones
af347d957e Basic summary information for duplicates
Added a one-line summary of each album (in lib, and import target) so
you can easily tell if (for example) you are about to overwrite your
FLAC copy with a low-bitrate mp3 from somewhere else.
2014-08-17 18:53:02 +01:00
Thomas Scholtes
dc53f7907a Fix completion script 2014-07-08 17:52:46 +02:00