Commit graph

213 commits

Author SHA1 Message Date
Dmitry Bogdanov
09ee194142 Make Discogs medium indexing code easier to understand 2018-04-28 02:23:46 +02:00
Dmitry Bogdanov
48140f11e7 Use releasegroup_id to store master release IDs from Discogs
Master releases roughly correspond to MusicBrainz' release groups.
It will be usefull to store master IDs, for example to retrieve
original release dates (#1122).
2018-04-27 21:56:51 +02:00
Dmitry Bogdanov
2e422122b3 Invent our own track IDs for Discogs
Discogs does not provide track IDs. As a workaround, invent our own
IDs by combining release ID with original track position strings
returned by Discogs (#2336).
2018-04-27 20:30:35 +02:00
Dmitry Bogdanov
676536efa7 Fix incorrect indexing of two-sided mediums
Fix incorrect split of a tracklist by medium for the case of
two-sided mediums (#2887).

Following the discussion in #2887, the 'medium_total' value should
contain the number of tracks on the medium to which each particular
track belongs, not the total number of different mediums present on
a release.

Fix unit tests accordingly.
2018-04-27 19:28:35 +02:00
Adrian Sampson
74c0e0d6e9 Fix default for user_token
Always match the expected type.
2017-02-21 13:56:20 -05:00
Adrian Sampson
a29b29f533 Docs improvements for #2447 2017-02-21 09:49:22 -05:00
Robin H. Johnson
3e4c9b8c06
discogs: support simple auth.
The official OAuth authentication seems to have broken, so allow usage
of simple configuration instead.

See-Also: https://github.com/discogs/discogs_client/issues/78
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
2017-02-20 20:20:20 -08:00
Mike Cameron
c58c49d77f Fixed trailing whitespace issue. Changed alternate track property name. 2017-01-10 18:39:01 -05:00
Mike Cameron
8a00791ecc Oops. Forgot to actually stage the correct file. 2017-01-01 04:52:32 -05:00
Diego M. Rodriguez
3f36f67940
discogs: tweak pruning of empty candidate albums 2016-12-30 11:39:19 +01:00
Diego M. Rodriguez
37cb1c295f
Merge remote-tracking branch 'upstream/master' into discogs-relax-assumptions
Conflicts:
	docs/changelog.rst
	test/test_discogs.py
2016-12-30 10:42:50 +01:00
Diego M. Rodriguez
072e6de3ae
discogs: add changelog for #2318, fix typo 2016-12-30 10:17:53 +01:00
Diego M. Rodriguez
0a9cb1fd3d
discogs: revise subtrack merging based on subindex
Modify the coalescing of subtracks by taking into account the subindices
of the subtracks for deciding if they represent "logical" tracks
(merging them into one single track, as previously) or if they represent
physical tracks (treating them as individual tracks).
Add unit tests for nested logical/physical subtracks, and disc titles.
2016-12-29 18:03:54 +01:00
Diego M. Rodriguez
30f238151e
discogs: additional sanity checks parsing release
Add extra checks for the presence of specific field (artists, title,
id, tracklist) when parsing a Release from discogs, failing gracefully
if the fields could not be found.
Add a test for releases without required fields.
2016-12-29 13:19:01 +01:00
Diego M. Rodriguez
02666424d4
discogs: improve robustness when parsing an album
Improve the robustness of `get_album_info()` by preferring the use of
`get()` over accesing the dictionary keys directly for several fields,
plus adding extra checks for fields that depend on nested containers on
the Release data.
Add a test for parsing a release that contains a minimal amount of
fields.
2016-12-28 21:07:18 +01:00
Johnny Robeson
bca6d2af01 Remove requests/urllib3 logging override in discogs
Discog plugin overrides the global logging for `requests` for a reason
that seems no longer valid.

I can't seem to reproduce the logging behavior mentioned in the
preceding comment, so I'm removing it.

If we do want to modify `requests` logging in the future, then we should
hook it into beets verbose logging.
2016-12-09 00:52:24 -05:00
kooimens
373cf19f8b Fix discogs disc field is set to zero
Fixes #587. The disc field is only zero when there is only one medium, so I think this will do the trick. I wasn't able to reproduce the real problem within the code. This is just a small workaround.
2016-10-17 19:51:03 +02:00
Diego Moreda
1f4bef9e61 discogs: docstring style fix 2016-10-10 20:30:21 +02:00
Diego Moreda
f4907ca5d0 discogs: handle nested subtracks, add try block
Modify coalesce_tracks() in order to handle the case where subtracks
are defined inside an index track (as `sub_tracks` attribute),
reorganizing the if logic to avoid duplicated code.

Add a try..catch block enclosing the call to clean_tracklist, as a
measure for avoiding side effects (and reverting to just parsing the
raw_list if there are any problems).
2016-10-10 19:59:42 +02:00
Diego Moreda
fb398c5f2c discogs: add medium_total to tracks (#415) 2016-10-10 17:46:41 +02:00
Diego Moreda
1148acaaf1 discogs: revise position regexp, add tests, tox
Revise the regular expression used for extracting information from a
discogs position, making the subtrack_index only be matched if one of
the other groups is matched as well. Split the definition into several
lines in order to try to document it a bit more clearly.
Add unit tests for position parsing and non standard positions.
Fix the underscore on tox dependency.
2016-10-10 17:42:27 +02:00
Diego Moreda
e7f2a111e4 discogs: add test dependencies, fix spelling 2016-10-09 17:57:36 +02:00
Diego Moreda
be223d966e discogs: coalesce subtracks (#1543)
Detect subtracks and merge them into a single track, taking into account
the index tracks if present. This includes a revision of the regular
expression used for converting a discogs "position" into medium, medium
index and subtrack index pieces, following the standard discogs
positions (12.2.9).
2016-10-07 19:09:09 +02:00
Diego Moreda
c55885c9e8 discogs: take into account two-sided media (#1762)
Revise the discogs plugin so two-sided mediums are taking into account
and each pair of consecutive *sides* is treated as single *medium*.
2016-10-07 19:01:50 +02:00
Diego Moreda
911117ef49 discogs: set media on tracks (#1921)
Set the media for all the tracks when fetching a release using discogs,
as autotag.apply_metadata requires it in order to work properly.
2016-10-06 19:49:43 +02:00
Johnny Robeson
6b73aa25d2 Use b'' in discogs medium query regex
Since the first arg to `re.sub()` is bytes, thus must be the
replacement string.
2016-09-20 17:38:39 -04:00
arogl
86d2129c52 Spelling update 2016-08-12 14:48:55 +10: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
Johnny Robeson
e8afcbe7ec replace unicode with six.text_type 2016-06-24 05:53:49 -04:00
Johnny Robeson
7713be4c0f use http_client (really http.client) from six.moves 2016-06-23 04:40:18 -04:00
Johnny Robeson
5e62b39f75 replace TEMPORARY with FIXME in discogs plugin
We're more likely to search for this later by FIXME.

NOTE: the bug is fixed, but the versions with the fix may not be widely
distributed yet
2016-06-10 02:30:00 -04:00
Johnny Robeson
5485bdb706 add missing b' in discogs query regex 2016-06-10 02:23:14 -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
Peter Kessen
40900aa1cb Removed unicode_literals from plugins
* bucket
* chroma
* convert
* discogs
2016-02-20 12:10:01 +01:00
Adrian Sampson
c7045daf90 sampsyo -> beetbox (#1730) 🎉 2016-01-08 20:36:16 -08:00
Adrian Sampson
0301bb517d Update links for our new domain 2016-01-08 16:26:13 -08: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
9165b7cf45 Trailing comma (#1708) 2015-11-08 13:02:07 -08:00
Manfred Urban
485870f288 Made various artist title configurable 2015-11-08 16:22:36 +01:00
Adrian Sampson
7413e17782 Merge pull request #1692 from kooimens/patch-2
Discogs: change album artist to musicbrainz naming
2015-11-06 13:01:23 -08:00
kooimens
414ae131a5 Fix style error 2015-11-06 19:27:36 +01:00
kooimens
da0360bd90 Update discogs.py 2015-11-05 14:50:40 +01:00
Adrian Sampson
a735a6b4a2 discogs: Better exception logging
Might have helped diagnose #1669 more easily.
2015-11-03 22:38:31 -08:00
Adrian Sampson
023a33ca31 Revert "Fix #1656, maybe: encode Discogs token strings"
This reverts commit f784cd1a22.
2015-11-03 22:29:33 -08:00
kooimens
2293e1e09d Discogs: option to change 'various' album artist to 'Various Artists' (Musicbrainz naming)
Just a simple config option to change 'various' album artist to the one that MusicBrainz uses: Various Artists.
2015-11-03 20:03:24 +01:00
Adrian Sampson
f784cd1a22 Fix #1656, maybe: encode Discogs token strings 2015-10-24 12:07:40 -07:00
Bruno Cauet
d134ad922d Discogs: add API errors to CONNECTION_ERRORS
This avoids potential crashes when DiscogsAPIError is not explicitely
caught.

Relates to #1417.
2015-04-17 17:32:42 +02:00
Adrian Sampson
0507f80fcd discogs: Handle errors on auth setup (fix #1417) 2015-04-14 10:26:39 -07: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
944d38064d Config: implement redacted fields more idiomatic
- `add_redacted_fields(self, *field_names)` to use argument unpacking
- foo =| bar instead of foo = foo | bar
2015-03-25 14:55:29 +01:00
Tom Jaspers
f4ed3e16b1 Config: Add redacted fields from included plugins 2015-03-24 17:01:33 +01:00
Bruno Cauet
1722c26ffe Fix DiscogsPlugin.setup() arguments
Session is optional. This fixes re-authorization.

Improve #1347.
2015-03-07 14:00:47 +01:00
Adrian Sampson
bcc591bf97 Generalize exception handler for #1347 2015-03-06 12:01:09 -08:00
Bruno Cauet
d1f6bbaf01 Discogs plugin: catch client lib ValueErrors
When search fails, log the query which caused it and return an empty
result.

Kind of fixes #1347.
2015-03-06 11:16:20 +01:00
Bruno Cauet
457afdc55d Auto re-auth for discogs plugin upon error 401
This goes in the direction of #1299 and #1305.
2015-02-18 15:11:52 +01:00
Bruno Cauet
5a1f499c64 Discogs plugin: fix event listener params
Also delete related deprecated comment.
2015-02-11 09:11:20 +01:00
Adrian Sampson
0247785440 discogs: Catch JSON decode errors
Fix #1305 *again*.
2015-02-03 23:42:47 -08:00
Adrian Sampson
cc01d87209 discogs: Catch *another* exception (fix #1305)
Everything but requests is a travesty.
2015-02-03 23:04:14 -08:00
Adrian Sampson
77833f6c05 Oops 😳 #1299 2015-02-02 22:34:22 -08:00
Adrian Sampson
8151a40f1f discogs: Catch socket errors (#1299)
See also:

https://github.com/discogs/discogs_client/issues/44
2015-02-02 22:27:14 -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
438044c6ae Fix bytes/str with unicode-nazi
Further cleaning will require setting unicode_literals on plugins
2015-01-20 15:25:12 +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
7c2d5f0948 Import beets.ui in discogs plugin
The discogs plugin uses beets.ui but did not explicitely import it,
which might cause it to crash when used in standalone.
2015-01-16 17:59:35 +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
e14a54df05 Convert multiple plugins' logger usage (easy ones)
Those plugins only called methods and no function, which eases the
conversion.
2015-01-06 21:34:13 +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
Bruno Cauet
8cac47af2a Convert beets plugins to lazy logging 2015-01-04 17:02:27 +01:00
Adrian Sampson
fe655e4610 discogs: Only authenticate on import (#1123)
No need to authenticate for other commands.
2014-11-30 11:18:32 -08:00
Adrian Sampson
a9981c1dc7 Comment about workaround in #1073 2014-11-07 19:51:38 -08:00
David
5480ceeaf8 Encode to ascii,not utf8.Replace missing chars 2014-11-07 20:46:35 -05:00
Adrian Sampson
50c7cf0f56 discogs: Fix #1049: intermittent trailing comma 2014-10-30 09:36:39 -07:00
Adrian Sampson
eb35d7084a Save Discogs token (#1040) 2014-10-26 15:45:34 -07:00
Adrian Sampson
a8a5191cf5 discogs #1040: Standard API key, handle failure 2014-10-26 15:24:17 -07:00
David
d9c9e06674 Add authentication to discogs plugin 2014-10-26 16:26:59 -04:00
Dustin Rodriguez
020c96d99f Added handler for requests.exceptions.ConnectionError to discogs plugin. 2014-10-11 20:50:31 -04: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
Andrii Kohut
4279ac0b67 New api requires client and dict as parameters for Release initialization 2014-08-25 20:22:47 +03:00
Andrii Kohut
34584eadd1 Works faster then checking each result item with isinstance 2014-08-25 19:14:41 +03:00
Andrii Kohut
f8af931caa Seems like something broken in new version of discogs_client 2014-08-24 17:34:31 +03:00
Andrii Kohut
9a80179059 this should fix UnicodeEncodeError with non-ascii queries 2014-08-24 16:37:24 +03:00
Andrii Kohut
d0115f1110 set user agent as Client parameter, remove imports 2014-08-23 13:12:28 +03:00
Andrii Kohut
a663e52bad Fix problems with new discogs_client version 2014-08-23 13:00:25 +03: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
Adrian Sampson
f6faf72328 move Distance class to hooks module 2013-06-10 15:21:32 -07:00
Tai Lee
e6ac8e1646 Use a Distance object instead of floats for distance calculations.
The new Distance object knows how to perform various types of distance
calculations (expression, equality, number, priority, string).

It will keep track of each individual penalty that has been applied so
that we can utilise that information in the UI and when making decisions
about the recommendation level.

We now display the top 3 penalties (sorted by weight) on the release
list (and "..." if there are more than 3), and we display all penalties
on the album info line and track change line.

The implementation of the `max_rec` setting has been simplified by
removing duplicate validation and instead looking at the penalties that
have been applied to a distance. As a result, we can now configure a
maximum recommendation for any penalty that might be applied.

We have a few new checks when calculating album distance:

`match: preferred: countries` and `match: preferred: media` can each be
set to a list of countries and media in order of your preference. These
are empty by default. A value that matches the first item will have no
penalty, and a value that doesn't match any item will have an unweighted
penalty of 1.0.

If `match: preferred: original_year` is set to "yes", beets will apply
an unweighted penalty of 1.0 for each year of difference between the
release year and the original year.

We now configure individual weights for `mediums` (disctotal), `label`,
`catalognum`, `country` and `albumdisambig` instead of a single generic
`minor` weight. This gives more control, but more importantly separates
and names the applied penalties so that the UI can convey exactly which
fields have contributed to the overall distance penalty.

Likewise, `missing tracks` and `unmatched tracks` are penalised and
displayed in the UI separately, instead of a combined `partial` penalty.

Display non-MusicBrainz source in the disambiguation string, and
"source" in the list of penalties if a release is penalised for being
a non-MusicBrainz.
2013-06-02 18:25:10 +10:00
Jayme
5bb0881cdd Replace two more flag arguments 2013-05-30 10:09:39 +02:00
Jayme
32e1c13510 Fix Python 2.6 compatibility 2013-05-30 09:30:00 +02:00
Adrian Sampson
303cd9ba00 Merge pull request #291 from jbaiter/discogs_albumid
Support for manually entered IDs in plugins
2013-05-29 14:43:59 -07:00
Johannes Baiter
3df635eca2 Make regex for Discogs ID more specific 2013-05-29 20:31:58 +02:00
Johannes Baiter
2d4ea4e49b Fix bug in discogs.album_for_id for ID-Strings that end in a bracket 2013-05-29 10:59:04 +02:00
Johannes Baiter
40a6e03ba6 Improve regular expression for Discogs IDs 2013-05-29 10:54:15 +02:00
Adrian Sampson
9f927438ca fix some dumb mistakes from most recent flurry 2013-05-28 22:04:20 -07:00
Adrian Sampson
72449caccf discogs: move config default into constructor
Such is the new convention for plugin configuratino defaults.
2013-05-28 21:45:31 -07:00
Adrian Sampson
480fa80e47 discogs: penalty only for matches from discogs
Otherwise, this was penalizing all album matches.

This also applies the same treatment as the previous commit: only load the
config at run time (at the expense of code clutter).
2013-05-28 21:25:28 -07:00
Johannes Baiter
f17e8550ca Determine IDs from MusicBrainz and Discogs URLs 2013-05-28 13:49:34 +02:00
Johannes Baiter
e3418be75d Add support for manually entered release ID in Discogs 2013-05-28 12:58:05 +02:00
Tai Lee
35e926a51b Add Discogs and general source weight penalty (configurable, undocumented).
Discogs (and other individual plugins) should return a penalty between
0.0 and 0.1, which will be multiplied by the general source weight. This
allows individual plugins to be weighted against relative to each other,
and amplified together against other penalty categories (track, title,
etc.)
2013-05-27 01:28:40 +10:00
Tai Lee
a6b1bb1bbc Move articles to the front of Discogs artist names. 2013-05-25 14:05:03 +10:00
Tai Lee
3f4e194c41 We only need to strip the disambiguation from artist names, not the join strings. 2013-05-25 12:19:48 +10:00
Adrian Sampson
72f0505744 discogs: extra space in ambiguous artists (#289) 2013-05-24 12:31:18 -07:00
Adrian Sampson
d877f5e3e8 Merge pull request #289 from Smyds/master
Remove discogs artist disambiguation number
2013-05-24 12:28:50 -07:00
César Prouté
726c84674b remove discogs artist disambiguation number 2013-05-24 20:15:24 +01:00
Tai Lee
835a3c2a73 Improved parsing of Discogs' position field.
Some albums have a single disc with positions like I, II, III, IV, etc.
Previously beets thought each track on these albums was a new medium.

Now we assume that if there is no explicit medium index and the ordinal
of an alpha medium does not appear to be sequential (e.g. A, B, C) that
the medium is actually the medium index.
2013-05-25 01:36:12 +10:00
Tai Lee
4c06c96630 Extract disc titles from Discogs' "index tracks". 2013-05-25 01:32:06 +10:00
Tai Lee
7f068a8c03 Add AlbumInfo.data_url property, populate it for Discogs matches and display it when it is non-empty.
Makes it easier for people to find the best Discogs (or other) match
and import it to Music Brainz using a grease monkey or similar script.
2013-05-24 22:50:14 +10:00
Tai Lee
3eb6f8e5eb Add discogs plugin, which extends the autotagger to include results from the discogs database.
This is a refactor of the plugin developed by `imenem`.

- Pass `artist`, `album` and `va_likely` to `candidates()` so that
  plugins don't have to work this out from `items` all over again.
- Pass `artist` and `title` to `item_candidates()`.
- Silence spurious `urllib3` info log lines.
- Use a proper "beets" user agent with `discogs_client`.
- Remove `abstract_search` plugin. It seems unnecessary. How many
  music databases are there? How many will beets support? How much
  common code might there be between them? We can add some abstraction
  if or when more databases are supported.
- Derive more AlbumInfo and TrackInfo properties from discogs Release
  objects, especially album ID so that beets doesn't just use the first
  release and think all subsequent releases are duplicates.
- Add basic documentation, doc strings and code comments.
- Sanitise search query. Remove non-word characters and medium info that
  might filter out good search results.
- Use artist `join` strings from discogs Release object when an album
  or track has multiple artists.
- Don't rely on discogs track position, which is unreliable. But tracks
  are in order, so we can recalculate medium and medium_index as long as
  we can extract a consistent medium across tracks from the position.
- Add "various" as a known signal to indicate various artists.
- Prevent `chroma` plugin from returning a a huge track distance for any
  track that is missing an ID (e.g. all discog tracks).
- `TrackInfo.index` should be the release index (calculated by beets),
  not the medium index (derived from discogs track position).
- Add `AlbumInfo.data_source`. It's "Unknown" by default which is shown
  in red when displaying a suggested or selected match. The built in
  auto tagger sets it to "MusicBrainz" which is shown in green. Anything
  else (e.g. "Discogs") is shown in yellow.
- Remove double spaces from album titles (bad data from Discogs).
2013-05-21 21:16:52 +10:00
imenem
12476ca22e Added Discogs search plugin. 2013-03-07 17:59:52 +02:00