Commit graph

429 commits

Author SHA1 Message Date
Adrian Sampson
6f19f466fc tests: temporarily modify global configuration 2012-12-14 13:39:14 -08:00
Adrian Sampson
e84a41b550 start fixing up tests for confit overhaul 2012-12-14 13:18:06 -08:00
Adrian Sampson
e17cd6beba merge lots of work on the stable branch 2012-12-12 19:14:30 -08:00
Adrian Sampson
c499be05ea fix some tests under PyPy
In PyPy's pure-Python implementation of the sqlite3 module, sqlite3.Row has no
__len__ method. This works around calling len(row).
2012-11-27 21:47:15 -08:00
Adrian Sampson
f06c7dfbef modernize basic MediaFile tests
These tests were written when I knew almost nothing about Python and even less
about unittest. The class-generating magic never worked with nose for a crazy
reason I won't get into here. This has a bit more copypasta but the workings
are more obvious and we no longer generate enormous numbers of independent
tests. There should be a more representative number of dots in the test runner
output now.
2012-11-27 21:42:36 -08:00
Adrian Sampson
0a21d72a79 tolerate non-UTF8 locale in test 2012-11-27 20:38:47 -08:00
Adrian Sampson
9a4cda60cd autotag: use albumartist if available (GC-423) 2012-11-27 17:05:56 -08:00
Adrian Sampson
eef87c2189 truncation incorporates extension length (GC-461) 2012-11-27 16:54:50 -08:00
Adrian Sampson
6e889bb6d0 fix tests for new explicit urlretrieve() call 2012-11-03 12:47:35 -07:00
Adrian Sampson
a8383b03e9 merge with master 2012-11-01 14:28:25 -07:00
Adrian Sampson
ea128910c5 fix art tests for new URL interface (#64)
The various source helper functions now return URLs instead of calling
_fetch_image themselves.
2012-11-01 00:14:55 -07:00
Adrian Sampson
e3fe9712d5 fetchart fixes for image resizing (#64)
Fixed a number of issues with the changes to fetchart:
- Remove redundant fetches. This was making the Amazon source download every
  image twice even when art resizing was not enabled!
- Restore local_only switch in plugin hook, which got lost in the shuffle at
  some point.
- Don't replace the original image file in-place; use a temporary file instead.
  This would clobber the original source image on the filesystem with the
  downscaled version!
2012-11-01 00:09:35 -07:00
Adrian Sampson
7158c01ff8 clean up outdated FIXMEs 2012-10-27 18:47:04 -07:00
Adrian Sampson
16f207e927 make syspath/bytestring_path roundtrip on Windows
This is an alternative to #58 that makes bytestring_path perform more like the
inverse of syspath on Windows. This way, we can convert to syspath, operate on
the path, and then bring back to internal representation without data loss. This
involves looking for the magic prefix on the Unicode string and removing it
before encoding to the internal (UTF-8) representation.
2012-10-20 23:49:43 -07:00
Adrian Sampson
1f8fff7445 fix tests for recent API changes in commands 2012-10-20 21:19:50 -07:00
Adrian Sampson
3a4e1ca4f7 replaygain: add fields to Item
This has been a long time coming, but we now finally keep track of ReplayGain
values in the database. This is an intermediate step toward a refactoring of the
RG plugin; at the moment, these values are not actually saved!
2012-10-17 20:28:24 -07:00
Adrian Sampson
244ffd71e2 fix "beet modify" for date fields (GC-449)
This is fixed by allowing MediaFiles to convert strings to integers on
assignment. An eventual complete fix will perform these type conversions in the
Item interface.
2012-10-14 20:27:13 -07:00
Blemjhoo Tezoulbr
3eb11355cf ihate plugin: ver 1.0 - initial import 2012-10-05 02:37:21 +03:00
Blemjhoo Tezoulbr
c9fafb8379 plugin the: ver 1.1 - singleton mode, code cleanup 2012-10-05 02:04:51 +03:00
Adrian Sampson
2793af7d70 zero, the: Python 2.6-compatible format strings 2012-09-25 15:13:33 -07:00
Blemjhoo Tezoulbr
aff36fa694 zero plugin, version 0.9 2012-09-22 15:50:33 +03:00
Adrian Sampson
cdc833b8ab Merge pull request #47 from tezoulbr/master
new plugin: "the" (pattern moving in path formats)
2012-09-17 11:06:22 -07:00
Adrian Sampson
ef248576f0 bpd: fix crash w/ unicode extensions (GC-439) 2012-09-17 10:24:34 -07:00
Blemjhoo Tezoulbr
16aa842ccf plugin the: version 1.0 2012-09-16 04:42:39 +03:00
Adrian Sampson
dc054907d5 fix non-string value matching in SubstringQuery 2012-09-09 12:17:13 -07:00
Adrian Sampson
90b3dba085 fix match() on RegexpQuery for non-string values 2012-09-08 16:24:39 -07:00
Adrian Sampson
af2a329477 handle user-visible exceptions at top level
This makes error messages more friendly (i.e., traceback-free) when exceptions
occur during UI setup -- e.g., unopenable database.
2012-08-27 22:45:28 -07:00
Adrian Sampson
44459f88d0 Windows: represent paths as UTF-8 internally
When we store paths in the database, we always use bytestrings for consistency.
But on Windows, these paths are converted back to Unicode before they reach the
FS API. This means that the codec used internally is immaterial.

However, we were naively using sys.getfilesystemencoding() for this internal
representation. On Windows, this is MBCS, a broken encoding that can't represent
all of Unicode. This change replaces that with UTF-8, a "real" codec.

The decoding bit now tries UTF-8 and falls back to MBCS for compatibility with
existing databases. The reality, however, is that existing databases may not
work with this change -- a byte string may represent something different in
UTF-8 from what it represents in MBCS. So users should recreated their DBs if
anything goes wrong.
2012-07-17 10:54:47 -07:00
Jakob Borg
21cff66d08 Handle unicode in replacement config
The 'decode' call fails in what is already a unicode string. I'm not
sure under what circumstances the string is or isn't unicode (apparently
it varies), so I added a check. The test passes with the patch, at
least.
2012-07-05 23:12:36 +02:00
Adrian Sampson
ce166004cb use AlbumMatch/TrackMatch objects everywhere
This allows matches to indicate both missing and unmatched tracks in their
candidates and solves some of the spaghetti tuples that were passed around
during autotagging.
2012-07-01 16:33:48 -07:00
Adrian Sampson
7464b138cf fix tests broken by TrackInfo.index 2012-07-01 14:16:22 -07:00
Adrian Sampson
38b404240d merge 2012-06-29 15:27:05 -07:00
Adrian Sampson
ee3214e0f9 use TrackInfo.index in apply_metadata
enumerate() no longer necessary.
2012-06-29 15:18:10 -07:00
Adrian Sampson
d4c3ea74c6 match ordering without length assumptions
This replaces order_items with assign_items, the first step to allowing unequal
numbers of items on either side of the equation (user files and canonical
tracks). Rather than returning a "holey" list and assuming that the TrackInfo
objects stay static, the function returns a dictionary mapping Item objects to
TrackInfo objects. To indicate unmatched objects, two sets are also returned.

For the moment, some temporary code is included to turn the result from this
new function into the old format (a holey Item list). This allowed me to test
this change in isolation before plunging ahead with the necessary refactoring to
expose all of this to the importer workflow, etc.
2012-06-29 15:11:25 -07:00
Adrian Sampson
98d46be4a5 include global index in TrackInfo objects 2012-06-29 14:06:28 -07:00
Adrian Sampson
fbb5823541 fetchart: command to manually download art 2012-06-24 18:27:00 -07:00
Adrian Sampson
77cbb19564 fetchart: get local art for as-is imports (GC-339) 2012-06-24 17:41:37 -07:00
Adrian Sampson
d807b3fbf1 Cover Art Archive support (GC-71) 2012-06-24 16:57:04 -07:00
Adrian Sampson
11d4fb1abb move album art fetching to a plugin (fetchart) 2012-06-24 00:34:50 -07:00
Adrian Sampson
073ee14e56 fix broken matching of path format queries (#405)
A bug in the shlex module with Unicode strings made these queries unparseable
and thus match every track.
2012-06-23 17:18:28 -07:00
Adrian Sampson
d88afbad11 library maintains per-thread DB conns. (GC-399) 2012-06-08 10:49:47 -07:00
Adrian Sampson
e00f15175a prune is a no-op when file exists
i.e., when moving a file that's already at its destination.
2012-05-30 16:39:47 -07:00
Adrian Sampson
86f513d4ab split apply_choice coroutine
This essential import pipeline stage is now two: one that applies metadata
changes and one that manipulates the filesystem. This will eventually allow
lastgenere to apply its changes before destinations are calculated.
2012-05-22 23:22:34 -07:00
Adrian Sampson
c0da62c2b7 multi-artist sort names 2012-05-19 16:35:52 -07:00
Adrian Sampson
711a1c1113 apply artist credits & add to database (GC-286) 2012-05-19 16:13:15 -07:00
Adrian Sampson
e56ca46b75 add artist credit fields to MediaFile (GC-286) 2012-05-19 15:57:26 -07:00
Adrian Sampson
1387f30295 parse artist credits from MB responses (GC-286) 2012-05-19 15:42:08 -07:00
Adrian Sampson
13995201a1 human-readable filesystem errors (#387) 2012-05-18 15:16:38 -07:00
Adrian Sampson
2b000c47a2 per_disc_numbering config option (GC-335) 2012-05-17 12:44:48 -07:00
Adrian Sampson
a6c1ad2235 reimporting with copying: copy external files 2012-05-17 11:42:58 -07:00
Adrian Sampson
387a2dbc3c fix tests for GC-362 2012-05-16 17:13:01 -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
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
5ebb61bab7 moving import (#266): move album art files 2012-05-03 17:08:52 -07:00
Adrian Sampson
b327455fac prune empty directories when moving (#266) 2012-05-03 16:59:56 -07:00
Adrian Sampson
104aec3c2f cleanup and docs for regular expression queries 2012-05-01 20:03:01 -07:00
Adrian Sampson
a6e6da245a Merge branch 'upstream' of https://github.com/djrtl/beets-dj
Conflicts:
	beets/library.py
2012-05-01 19:17:05 -07:00
Adrian Sampson
d042bed27c pre-parse path format templates
Instead of parsing the template at each call to destination(), it's now possible
to parse them *once*, a priori, and re-use the resulting template object. This
is analogous to the re module's compiled expressions.
2012-04-29 15:30:43 -07:00
Matteo Mecucci
46ec5db3fe Added unit tests for regexps in query expressions. 2012-04-28 15:24:42 +02:00
Adrian Sampson
8f128876e2 %aunique: use a single field instead of a sequence
For a less cumbersome uniquifying string, only a single field value is now used
instead of a prefix of a list of fields. The old semantics had two problems that
made it both unnecessary and insufficient:
- In the vast majority of cases, a single field suffices (year OR label OR
  catalog number, for example) and forcing the string to include many identical
  fields is unnecessary.
- If the albums are very similar, a prefix may be insufficient; a better
  solution may be found with an arbitrary subset. (Of course, we can't afford to
  search the whole power set.)
So we're going with a single field for now. This should cause far less
confusion.
2012-04-24 21:15:50 -07:00
Adrian Sampson
8fe3738710 default arguments to %aunique{} (#190) 2012-04-24 20:34:51 -07:00
Adrian Sampson
f20fbede5e sanitize output of %unique 2012-04-20 10:17:19 -07:00
Adrian Sampson
6b696c842f cleanup and docs for import_move (GH-26, GC-266)
- Copying and moving are mutually exclusive. Moving overrides copying so the
  user only has to add one line ("import_move: true") to disable copying and
  enable moving in its place.
- Deleting is only possible when copying.
- Deprecating the "delete" option (moving is almost always better).
- Removed command-line switch for moving. It's somewhat "unsafe", so this
  removes some potential for accidental irreversible changes.
- Changelog & thanks.
- Update docs to refer to import_move instead of import_delete as the
  correct solution for ending up with only one copy of the file.
2012-04-10 13:41:24 -07:00
Adrian Sampson
d256aeb436 Merge pull request #26 from iElectric/master
import_move: move files (instead of copying & deleting)
2012-04-10 13:02:30 -07:00
Adrian Sampson
ed495765e2 tolerate missing language from MB (#373) 2012-04-10 11:38:45 -07:00
Domen Kožar
1af4f86c17 support move action when importing 2012-04-05 01:14:17 +02:00
Adrian Sampson
4fdebcff2d parse & apply new set of fields 2012-04-04 09:13:26 -07:00
Adrian Sampson
251026b759 add a new batch of metadata fields
The new fields are:
ALBUM: mb_releasegroupid asin catalognum script language country albumstatus
media albumdisambig
TRACK: disctitle encoder
These are not yet parsed from MusicBrainz responses (just added to MediaFile
and the database).
2012-04-04 00:52:57 -07:00
Adrian Sampson
ffa2402ff4 revamp default character substitutions
There's no longer a distinction between Unix and Windows substitutions. Enough
users reported problems with Windows-forbidden characters on Samba shares that
it seems appropriate to make all filenames Windows-safe, even on Unix. Users who
really want those additional characters (<>:"?*|\) can re-enable them via the
"replace" option. Nobody has complained about beets being *too* conservative.

This also adds sanitization of control characters, which is an all-around good
idea, and the substitution now runs in the Unicode (rather than byte) domain.
2012-04-03 14:22:38 -07:00
Adrian Sampson
de6530f4a5 acoustid ID and fingerprint stored/tracked (#332) 2012-04-01 18:22:42 -07:00
Adrian Sampson
781c26ffd0 normalize to NFC on non-Mac platforms (#367) 2012-03-27 10:44:11 -07:00
Adrian Sampson
823e36ad01 normalize new filenames to with NFD 2012-03-26 12:14:30 -07:00
Adrian Sampson
2f1ac61d4f track and album artist sort names (GH-25, GC-77)
Previously, there was just an "artist sort name" field -- now there's a
corresponding sort name for both track artists and album artists. I also made
the names shorter (artist_sort and albumartist_sort).
2012-03-25 17:02:52 -07:00
Adrian Sampson
06f137bff9 %unique path function
Generates disambiguating strings to distinguish albums from one another. To be
used as the basis for a simpler path field, $unique, as a default disambiguator.
2012-03-22 18:04:06 -07:00
Adrian Sampson
24cdf2a72e duplicate trumping: remove items & delete files
Based on the "remove_duplicates" flag on ImportTask, the apply_choices coroutine
now looks for duplicates (using an extended version of the _duplicate_check
functions) and removes items from the library. It also *deletes* files
associated with those items when they are located inside the beets library
directory. Files outside of the directory are left on disk (but their DB entry
is still removed). This should "do the right thing" in most cases -- again, this
is something we can add a config option for if it comes up.
2012-03-20 14:23:44 -07:00
Adrian Sampson
19b08f8e99 duplicate resolution callback function (#164) 2012-03-19 15:32:53 -07:00
Philippe Mongeau
200a98d4df add format option to list_items command
you can provide a custom format option to the list
command.
Example: $ beet ls -f '$title - $album'
2012-02-29 19:14:56 -05:00
Adrian Sampson
6d2df0e4bf import_delete: delete local album art (#242) 2012-02-15 16:46:23 -08:00
Adrian Sampson
ea95fa1373 album art fetcher tests 2012-02-15 16:35:28 -08:00
Adrian Sampson
153f52a6eb import_delete prunes empty imported directories (#243) 2012-02-09 15:06:33 -08:00
Adrian Sampson
7522468f0e set disc and disctotal when autotagging (#226) 2012-02-07 18:03:31 -08:00
Adrian Sampson
5a0105b12c fall back to unittest2 (#275) 2012-01-31 15:25:09 -08:00
Adrian Sampson
bb4be3a303 lower case extensions in destination (#331) 2012-01-31 15:11:19 -08:00
Adrian Sampson
337e2556a6 sanitize path components from plugins (#315) 2012-01-30 16:53:05 -08:00
Adrian Sampson
b7c9d2caf5 prevent divide-by-zero in bitrate property (#319) 2012-01-29 14:08:23 -08:00
Adrian Sampson
fe33926038 add new audio properties to library/DB
$samplerate now expands to "##kHz" in path formats.
2012-01-27 16:04:51 -08:00
Adrian Sampson
9987ab47fd fixes & tests for new audio properties
For the recently-added samplerate, bitdepth, and channels properties on
MediaFile, a few things were fixed:
- tests in test_mediafile_basic
- never return None (zero when unavailable)
- make channels work with MP3 files (by looking at the codec "mode")

Also added some docstrings on all of the properties.
2012-01-27 15:51:14 -08:00
Adrian Sampson
4a1e8fdd6e merge 2012-01-27 12:04:44 -08:00
Adrian Sampson
f685bdd89a unicode in str MediaFile fields (#311, closes #15) 2012-01-27 12:02:26 -08:00
Adrian Sampson
3b37433005 no penalty for "various artists" track artist (#251) 2012-01-25 20:41:59 -08:00
Adrian Sampson
47891b00f7 tolerate per-medium track numbering (#283) 2012-01-25 20:12:04 -08:00
Adrian Sampson
0e81900675 mtime tests at integral second resolution (#298) 2012-01-18 14:08:15 -08:00
Adrian Sampson
c40081808a fix double-removal when re-importing with deletion
With import_delete enabled and performing a re-import (which moves files), the
former location of the file would be "deleted". This would lead to a "file does
not exist" error.
2012-01-06 21:58:17 -08:00
Adrian Sampson
d73c133a53 query-conditioned path formats (#210)
Also, Library.path_formats is now a list of pairs instead of a dictionary. (I
would have used an OrderedDict, but that was added in 2.7.)
2011-12-28 19:01:13 -08:00
Adrian Sampson
b44195853c zero-pad date values in path formats (#282) 2011-12-22 15:57:02 -08:00
Adrian Sampson
112d0f5452 uniquify conflicting filenames (#182) 2011-12-19 22:52:13 -08:00
Adrian Sampson
b493bc7004 configurable pathname substitution (#115) 2011-12-19 18:37:35 -08:00
Adrian Sampson
08b539a80e fix field inference w/ null first item (closes #14 on GitHub)
When a partial match is found, its first item (task.items[0]) may be None, and
_infer_album_fields would crash in this case. This solution walks through the
items list and finds the first non-None item.
2011-12-16 16:45:50 -08:00
Adrian Sampson
46a3bde5b5 fix empty function arguments
Previously, an empty argument was treated as "not an argument at all". Now,
every function call always has at least one argument -- i.e., %foo{} is a
function call whose only argument is "" -- and %foo{,bar} is valid syntax.
2011-12-16 12:08:39 -08:00