Commit graph

307 commits

Author SHA1 Message Date
Carl Suster
546bf3af7e mediafile: import from standalone module 2019-05-29 09:35:14 +10:00
Jan Holthuis
c07903ed66 fetchart: Add some error handling to prevent crashes
Today I had some network problems regarding dbpedia.org, which made
beets crash because a requests.exceptions.ConnectionError was raised
("[Errno 113] No route to host"). This commits adds some error handling
around network requests to prevent further crashes in the future.
2019-02-19 16:16:56 +01:00
Reg
2ea77652a7 Fetchart: Respect ignore and ignore_hidden settings when fetching art
from the local filesystem.
2018-12-20 18:44:46 +01:00
Jack Wilsdon
5ad16983d4
Fix miscellaneous typos 2018-10-09 01:11:06 +01:00
nath@dp7510
399bfb985e fetchart: fix itunes debug info
Some typos + make it more useful overall
2018-08-15 13:56:39 +02:00
nath@dp7510
0107262ed3 fetchart: restore itunes art source
Reimplement minimalistic itunes scraper from scratch
2018-08-15 13:55:55 +02:00
wisp3rwind
318f0c4d16 Advanced fetchart source config: pep8 2018-02-24 11:26:50 +01:00
wordofglass
e7a3e27ed9 Advanced fetchart source config: Actually use the new syntax 2018-02-24 11:26:50 +01:00
wordofglass
2c1e4d878b Advanced fetchart source config: add the (still unused) match_by constructor argument 2018-02-24 11:26:50 +01:00
test
842f6afd7f Fix indentation 2017-11-10 14:04:16 +01:00
test
8544b3a830 Fix long line and add changelog entry 2017-11-10 13:46:26 +01:00
test
54297dbab4 Tentative fix for issue 2734: also check for RETAG 2017-11-05 12:04:40 +01:00
euri10
25fb2453b4 Modified the name of the fetchart plugin switch from missing to quiet 2017-09-05 18:27:47 +02:00
euri10
b2fd274e2c Added a missing switch to the fetchart command so that only missing albums
are displayed
2017-09-05 16:34:26 +02:00
wordofglass
bc582701ff fetchart: Internally pass settings in a cleaner way.
Dump the 'extra' dictionary which only duplicated attributes of the
plugin onject in favor of passing a reference to the plugin directly.
2017-01-25 00:01:05 +01:00
Adrian Sampson
f941fd42de Always use SSL on servers that don't require SNI
I did a little audit using the `openssl` command-line tool to find the servers
that don't require SNI. Here's what I found:

icbrainz.org: SNI
images.weserv.nl: inconclusive, but docs say yes SNI
coverartarchive.org: SNI
webservice.fanart.tv: *no* SNI
dbpedia.org: *no* SNI
en.wikipedia.org: *no* SNI
ws.audioscrobbler.com: *no* SNI
api.microsofttranslator.com: *no* SNI

In summary, *only* MusicBrainz and CoverArtArchive were found to require SNI.
So I'm using SSL unconditionally on all the other sites.
2017-01-02 20:39:10 -05:00
tigranl
471f875dc1 Fix typo 2016-12-10 21:26:51 +03:00
tigranl
68b4a03ecd Add tests for https 2016-12-10 19:54:44 +03:00
tigranl
21208b8c39 Add SNI_SUPPORTED 2016-12-08 19:09:15 +03:00
tigranl
efa90416a0 Add SNI_SUPPORTED
Add SNI_SUPPORTED
2016-12-06 19:51:15 +03:00
tigranl
73a7a4ff67 Add SNI_SUPPORTED variable for https check 2016-12-06 18:38:26 +03:00
nathdwek@laptop
a0877dc092 images: Make sure all jpegs work everywhere
Apply #1545 to a public function used everywhere
2016-11-08 18:48:44 +01:00
Johnny Robeson
fcbfce3984 replace deprecated log.warn() with log.warning() 2016-08-09 00:33:38 -04:00
Johnny Robeson
527b51147e add py3_path to NamedTemporaryFile suffixes 2016-07-02 04:53:57 -04:00
wordofglass
e2c6547635 fetchart: Clarify the deprecation of remote_priority in docs and
warning, closes #2092
2016-06-29 19:18:06 +02: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
Adrian Sampson
736ad66518 Merge pull request #2066 from beetbox/use-six
Use the six package to handle py2/p3 compatibility
2016-06-25 18:09:56 -07:00
wordofglass
5d00ca8bda fetchart: do not unnecessarily reset Candidate.path on download failure 2016-06-25 14:10:55 +02:00
wordofglass
697291b04e fetchart: improve error resilience of the Content-Type detection by file magic 2016-06-25 14:10:50 +02:00
wordofglass
9968288358 fetchart: update comments 2016-06-25 13:49:15 +02:00
Johnny Robeson
edb1cbc5fc replace iter{items|values} with six.iter{items|values} 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
wordofglass
34cdf0f3f3 fetchart: complain about unsupported images only after validating the Content-Type 2016-06-23 17:38:01 +02:00
wordofglass
d47182a3e5 fetchart: do not rely on the server-provided Content-Type, but determine the image format from the file magic 2016-06-23 17:37:55 +02:00
Johnny Robeson
ea02269dee remove ext encode from fetchart (py3 fix for #2068) 2016-06-23 02:29:53 -04:00
wordofglass
c4617c2c1f fetchart: do not hardcode the downloaded extension to jpg, fixes #2053 2016-06-21 10:57:45 +02:00
Johnny Robeson
1c761c60fb bytstringify extra cover_names in fetchart 2016-06-17 03:37:28 -04:00
Johnny Robeson
a76de95183 return a bytestring path from RemoteArtSource 2016-06-12 01:19:39 -04:00
Johnny Robeson
ab67727283 wrap the cover_names map with a list in fetchart
most `cover_names` users expect to operate on a list
2016-06-10 00:09:15 -04:00
Adrian Sampson
f400a2431e fetchart: Fix path types on Windows 2016-06-08 10:20:25 -07:00
Johnny Robeson
81484529c9 remove b' from a few more stdlib calls 2016-05-31 00:13:09 -04:00
Adrian Sampson
09bc250413 Fix #1960: Unicode in fetchart Wikipedia source
The SparQL query needed to use a Unicode literal.
2016-04-26 16:59:23 -07:00
wordofglass
ac2f7fe712 Fix the fanarttv source failing when there were images found, but no cover art 2016-04-20 12:59:18 +02:00
wordofglass
5fbca32ea4 reuse the 'sources' names from the configuration for art_source 2016-04-19 11:25:03 +02:00
wordofglass
740efc0a0e small fixes; consistently use 'source' instead of 'origin' 2016-04-19 11:23:57 +02:00
wordofglass
c27907b043 enable fetchart to store the artworks origin in a flexible field; as of now untested 2016-04-19 11:23:42 +02:00
wordofglass
9e774fdccd Merge branch 'master' into fetchart_almost_square 2016-04-18 19:00:45 +02:00
wordofglass
c3be244109 remove the personal key warning altogether; it's also in the docs and rather obtrusive 2016-04-18 18:52:18 +02:00
wordofglass
20235264a4 rewire logic a bit; reasonable debug messages 2016-04-18 15:23:38 +02:00
wordofglass
30bca5c8af fix unconditionally printing the personal key warning for in fanart.tv in fetchart 2016-04-18 11:39:09 +02:00
wordofglass
6cbbba7dae initial work on allowing slightly non-square images in fetchart 2016-04-18 01:47:39 +02:00
wordofglass
8169983074 fix translation of the old remote_priority option for fetchart, add a test 2016-04-17 21:18:31 +02:00
wordofglass
36e91fc78b fix fanart.tv merge 2016-04-16 14:17:46 +02:00
wordofglass
9ce10c2fda Merge branch 'master' into fetchart_unify_sources,
i.e. adapt the fanart.tv source
2016-04-16 13:34:46 +02:00
wordofglass
4763fec35b fanart.tv: remove overly verbose logging left over from debugging 2016-04-15 19:42:06 +02:00
wordofglass
3a2eb03e0e Add fanart.tv API key 2016-04-15 19:32:17 +02:00
wordofglass
87aa5dab13 fixes according to feedback by @Kraymer 2016-04-15 14:15:25 +02:00
wordofglass
d46b45861b typo, rename project key config option 2016-04-15 02:40:52 +02:00
wordofglass
ecc6e1c3d6 fanart.tv albumart fetching, missing a project API key 2016-04-15 02:28:04 +02:00
wordofglass
7322e212a4 fetchart: adapt test to earlier config read 2016-04-14 16:49:06 +02:00
wordofglass
aaf614c869 fetchart: move config reads to __init__ 2016-04-14 16:00:24 +02:00
wordofglass
6bc3fb8f67 fetchart: make Candidate a new-style class 2016-04-14 15:27:47 +02:00
wordofglass
1cc4d11baf Fetchart: fix tests and fetachart logic 2016-04-13 22:56:18 +02:00
wordofglass
a4994d2bf8 fetchart: fix more tests 2016-04-06 01:36:32 +02:00
wordofglass
bc877a6d7f fetchart: fix tests (mostly pep8, syntax) 2016-04-06 01:19:44 +02:00
wordofglass
bbc06e9de9 fetchart: Adapt ArtForAlbumTest 2016-04-05 23:24:30 +02:00
wordofglass
a2141c6f3a fetchart: fix refactoring 2016-04-05 22:44:13 +02:00
wordofglass
50bf28edd4 move constants into Candidate 2016-03-23 16:46:39 +01:00
wordofglass
8356e7d33d fix syntax 2016-03-23 00:47:11 +01:00
wordofglass
b37cc02f1a fetchart: Introduce the Candidate class, some fixes to the previous commit. 2016-03-22 20:52:25 +01:00
wordofglass
c0a041b87e fetchart: Unify handling of local and remote sources. 2016-03-22 19:42:16 +01: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
7d00ab3b50 Removed unicode_literals from plugins
* fetchart
* freedesktop
* fromfilename
* ftintitle
2016-02-20 13:44:45 +01:00
Adrian Sampson
8cb545b779 Possibly fix #1805: bytes headers for requests 2016-01-11 10:30:33 -08:00
Jack Wilsdon
12cd5306b7 Update copyright dates to 2016 2015-12-30 15:42:06 +00:00
Lachlan Charlick
0d16f764f2 fetchart: Tidier google backend configuration keys 2015-12-30 13:34:58 +10:30
Lachlan Charlick
7b273b4310 fetchart: PEP8 fixes 2015-12-29 17:29:17 +10:30
Lachlan Charlick
be64df6409 fetchart: Handle errors when parsing malformed JSON from google 2015-12-29 01:48:33 +10:30
Lachlan Charlick
2e10b8c284 fetchart: Pass config object to backends when initialized 2015-12-29 01:37:53 +10:30
Lachlan Charlick
03a41e82da fetchart: minor google backend refactor 2015-12-29 00:02:41 +10:30
Lachlan Charlick
99fb656f52 fetchart: Remove some debug logging from google backend 2015-12-28 23:57:38 +10:30
Lachlan Charlick
deadc4d049 fetchart: Automatically disable google backend if no API key is set 2015-12-28 23:57:03 +10:30
Lachlan Charlick
b73cfb9f8d fetchart: Fix typo in google API config key 2015-12-28 23:53:56 +10:30
Lachlan Charlick
ff15f4af9b fetchart: Use config singleton rather than passing object to each backend 2015-12-28 23:42:11 +10:30
Lachlan Charlick
c14abe56a5 fetchart: Add new google backend using google custom search
Requires an API key from google similar to lyrics plugin.
Limited to 100 queries/day.
2015-12-28 23:16:12 +10:30
Adrian Sampson
5597313ea0 fetchart: Remove Google backend (fix #1760) 2015-12-12 16:47:00 -08:00
Adrian Sampson
3314db2f77 fetchart: Better logging for iTunes (#1760) 2015-12-12 16:44:55 -08:00
Adrian Sampson
c90ca1096c fetchart: Log reasons for rejecting art 2015-11-23 17:30:09 -08:00
Adrian Sampson
1d0984a294 Slight log rewording 2015-11-21 12:54:50 -08: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
reiv
81a72f74c9 Merge branch 'master' into 314-reimport-art 2015-11-04 18:37:06 +01:00
reiv
0ebc4c799d fetchart: in auto, ignore albums with art
When re-importing an album, we don't want fetchart to interfere
with any existing album art.
2015-11-04 15:08:42 +01:00
reiv
1625dfc17e Merge branch 'master' into 1264-unnecessary-resize 2015-11-03 02:46:33 +01:00
reiv
19dcc25a93 fetchart: Improve validation of image dimensions
This avoids images being resized unnecessarily if the dimensions
are correct.
2015-11-03 02:19:47 +01:00
reiv
db08896d8c fetchart: add docstring to helper function
_is_valid_image_candidate() now has three different return values.
These are documented here.
2015-11-02 03:04:45 +01:00
reiv
9182fd8f04 PEP8 amendments 2015-11-01 16:20:48 -08:00
reiv
3250fa80ae fetchart: Only resize when necessary
Fixes #1264: When a re-import triggers fetchart, the existing album art is no
longer resized if it already has the correct dimensions. This avoids creating
new album art files with unique filenames ("cover.n.jpg").
2015-11-01 16:20:18 -08:00
reiv
269d0e5403 fetchart: Check if album art file actually exists
Fixes #1126.
2015-11-01 16:14:51 -08:00
Adrian Sampson
854a4539cb Fix #1588: fetchart gets PNGs, not GIFs 2015-09-02 12:45:35 -07:00
Adrian Sampson
e32744a66a Fix extra parameter introduced for #1581 2015-08-30 11:55:06 -07:00
Adrian Sampson
9ce49b7ef0 fetchart: Do not emable Wikipedia by default
Because DBpedia seems to be down (it's responding very slowly with errors),
this seems like a good defensive action. It narrows the default sources to
those that resolve quickly, with only a couple of HTTP requests. We can
re-enable this again in the future if things seem to stabilize over at
DBpedia.
2015-08-29 12:52:57 -07:00
Adrian Sampson
e249fcb06f fetchart: Fix #1581, splitting in Wikipedia source 2015-08-29 12:45:10 -07:00
Adrian Sampson
b5cb4e4cc4 Slightly more efficient image streaming 2015-08-29 12:41:54 -07:00
Adrian Sampson
3d20f25f06 fetchart: Fix bungled Requests API 2015-08-29 12:27:37 -07:00
Adrian Sampson
75e810409b fetchart: Use a mixin for even more logging 2015-08-29 12:13:28 -07:00
Adrian Sampson
608e4ffbef fetchart: Lots more logging 2015-08-29 11:59:46 -07:00
Adrian Sampson
2b1d7fc3aa fetchart: Logging, naming, remove unused option 2015-08-29 11:31:59 -07:00
Adrian Sampson
96c5121f65 Documentation for #1555/#1556 2015-08-01 15:00:13 -07:00
Ben Ockmore
4818264a36 Added TypeError to the list of caught exceptions in fetachart._fetch_image
requests/urllib3 is throwing an exception due to an internal problem triggered
by some sort of timeout. This change catches the TypeError so that beets
reports "error fetching art" instead of crashing when this happens.
2015-08-01 16:50:59 +01:00
Kylie McClain
c7cdadfd49 fetchart: Use text_highlight_minor for color rather than text_success 2015-06-22 02:15:49 -04:00
Kylie McClain
b8d6c37fec fetchart: Use success coloring if album art is found 2015-06-19 20:36:50 -04:00
Tom Jaspers
a7eace81d4 fetchart: improve Wikipedia art source
Artists with non-typical casing (e.g., alt-J, dEUS) would not get matched on
DBPedia, as the RDFS:label uses arbitrary casing, and SPARQL provides only exact
matches. The FOAF:name attribute is always title-cased (e.g., Alt-J, Deus).

Due to a bug in DBPedia, the cover filename is truncated when it contains
parentheses, (e.g., 'Foo bar (band).jpg' gets truncated to 'Foo bar .jpg').
To work around this, an additional Wikipedia call gets made for all its
images, in which we try to match our truncated image.

The Wikipedia art source now catches the correct exceptions, instead of
a broad catch-all.

Wikipedia album images can be gifs, so these are now added to the list of
accepted content types.
2015-05-19 09:57:54 +02:00
Tom Jaspers
a82dee35cb fetchart complains if no imaging backend available
The `enforce_ratio` and `minwidth` options depend on PIL or ImageMagick.
Previously it silently fails. Now it will log a warning, and accept the
image.

Tests concerning these options are skipped when no imaging backend is available.

Fix #1460
2015-05-18 19:44:40 +02:00
Frederik “Freso” S. Olesen
0d21e816d4 Fetchart: Remove hard 500px size limit for CAA cover art.
Using -500 URLs for coverartarchive.org will only ever return images
where the biggest dimension is (width or height) is 500 pixels,
regardless of what fetchart settings are otherwise set.

This commit removes the -500 from the URL entirely rather than using it
conditionally, since a maxwidth of 500 will allow for a 600 high and 500
wide image, but CAA.org/...-500 would return a 500x417 image instead, so
not enforcing a size is the only way to ensure the user's {max,min}width
settings are properly respected.
2015-04-07 15:24:01 +02:00
Tom Jaspers
b5ec26c949 Fetchart: minwidth & enforce_ratio options
- Minimum image width can be specified via minwidth (default `0`)
- The image ratio can be enforced to 1:1 using `enforce_ratio` (default `no`)

See #1058
2015-04-04 20:52:08 +02:00
Tom Jaspers
6572e1bf5a Fetchart: add empty album check to iTunes art
Was causing some tests to fail in test_art.py:CombinedTest
2015-02-09 14:59:56 +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
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
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
060c275fd3 Merge branch 'master' into libmodels-formatting
Conflicts:
	beetsplug/embedart.py
2015-01-26 10:17:15 +01:00
Bruno Cauet
8165dec985 Delete manual formattings of album & item 2015-01-25 21:32:22 +01: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
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
Tom Jaspers
133c21a9c5 Fetchart: add fetching artwork from Wikipedia following the new class-based structure of the plugin 2015-01-18 15:09:36 +01:00
Bruno Cauet
4babc40fd8 Delete useless "config['mypluginname']" mentions
Replace with self.config where this is painless.
More plugins would benefit from this update but that requires turning
functions into methods.
2015-01-12 10:55:59 +01:00
Adrian Sampson
24317fd4c7 Rename BeetsPlugin._import_stages to import_stages
For #1208. Restores backwards-compatibility and matches the development docs.
2015-01-11 14:27:59 -08:00
Bruno Cauet
b27c5304d1 Merge branch 'master' into logging
Conflicts:
	beetsplug/fetchart.py
	beetsplug/mpdstats.py
2015-01-09 15:15:27 +01:00
Adrian Sampson
1654fc82ce Merge pull request #1211 from brunal/fetchart-check-isfile
Fetchart: check that the art found is a file
2015-01-08 13:40:21 -08: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
2e1b0d589d Fetchart: check that the art found is a file
Fixes issue #1177
2015-01-08 10:58:08 +01:00
Bruno Cauet
8097ff8c1d Convert fetchart plugin, with OO rewrite of sources
Art sources are now classes
2015-01-06 21:42:10 +01:00
Bruno Cauet
427f7e7035 Automatic logger level changes on import
Breaking changes: plugins should set set _import_stages instead of
import_stages. From outside the latter is replaced by import_stages().
This is because it is now wrapped with log level-getting & -setting
statements.
2015-01-06 21:27:15 +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
ba044f8e20 fetchart: Privatize global source list (#1148) 2014-12-18 11:14:22 +00:00
Fabrice Laporte
474adffe63 move helper functions from utils to plugins 2014-12-17 22:00:00 +01:00
Fabrice Laporte
0f2f43ca9b lyrics: add musixmatch source 2014-12-17 00:41:21 +01:00
Adrian Sampson
d026e7742b fetchart: Tolerate itunes bugs (fix #1109) 2014-11-22 15:32:52 -08:00
Adrian Sampson
d8211f1d76 fetchart: Fix RG MBID field name (fix #1080) 2014-11-12 20:56:18 -08:00
Adrian Sampson
d3f0742276 Changelog, tweaks for fetchart sources (#1075) 2014-11-11 10:10:43 -08:00
Fabrice Laporte
ef6d3efe6d fetchart: cover engines yield their results 2014-11-10 22:17:34 +01:00
Fabrice Laporte
09bea52a41 fetchart: fix flake8 2014-11-09 20:55:53 +01:00
Fabrice Laporte
6170c3a179 fetchart: make test_art.py tests pass 2014-11-09 20:41:21 +01:00
Fabrice Laporte
4d9ce94426 fetchart: import itunes only if necessary 2014-11-09 20:40:45 +01:00
Fabrice Laporte
41d0f4d674 remove comment 2014-11-08 23:28:10 +01:00
Fabrice Laporte
1b694e569e fetchart: add 'sources' option
Fasten cover search by enabling engines selection and prioritisation.
2014-11-08 23:20:44 +01:00