Skip to content

Commit 2e18f84

Browse files
authored
Merge pull request #4698 from ghbrown/discogs_client_check
discogs_client version check
2 parents 9bc6066 + f1b7832 commit 2e18f84

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

beetsplug/discogs.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from beets.autotag.hooks import AlbumInfo, TrackInfo
2323
from beets.plugins import MetadataSourcePlugin, BeetsPlugin, get_distance
2424
import confuse
25+
from discogs_client import __version__ as dc_string
2526
from discogs_client import Release, Master, Client
2627
from discogs_client.exceptions import DiscogsAPIError
2728
from requests.exceptions import ConnectionError
@@ -50,6 +51,7 @@ class DiscogsPlugin(BeetsPlugin):
5051

5152
def __init__(self):
5253
super().__init__()
54+
self.check_discogs_client()
5355
self.config.add({
5456
'apikey': API_KEY,
5557
'apisecret': API_SECRET,
@@ -66,6 +68,19 @@ def __init__(self):
6668
self.discogs_client = None
6769
self.register_listener('import_begin', self.setup)
6870

71+
def check_discogs_client(self):
72+
"""Ensure python3-discogs-client version >= 2.3.15
73+
"""
74+
dc_min_version = [2, 3, 15]
75+
dc_version = [int(elem) for elem in dc_string.split('.')]
76+
min_len = min(len(dc_version), len(dc_min_version))
77+
gt_min = [(elem > elem_min) for elem, elem_min in
78+
zip(dc_version[:min_len],
79+
dc_min_version[:min_len])]
80+
if True not in gt_min:
81+
self._log.warning(('python3-discogs-client version should be '
82+
'>= 2.3.15'))
83+
6984
def setup(self, session=None):
7085
"""Create the `discogs_client` field. Authenticate if necessary.
7186
"""

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ New features:
4343
:bug:`4251`
4444
* :doc:`/plugins/discogs`: Permit appending style to genre.
4545
* :doc:`plugins/discogs`: Implement item_candidates for matching singletons.
46+
* :doc:`plugins/discogs`: Check for compliant discogs_client module.
4647
* :doc:`/plugins/convert`: Add a new `auto_keep` option that automatically
4748
converts files but keeps the *originals* in the library.
4849
:bug:`1840` :bug:`4302`

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def build_manpages():
111111
'requests_oauthlib',
112112
'reflink',
113113
'rarfile',
114-
'python3-discogs-client',
114+
'python3-discogs-client>=2.3.15',
115115
'py7zr',
116116
],
117117
'lint': [
@@ -139,7 +139,7 @@ def build_manpages():
139139
'embedart': ['Pillow'],
140140
'embyupdate': ['requests'],
141141
'chroma': ['pyacoustid'],
142-
'discogs': ['python3-discogs-client>=2.3.10'],
142+
'discogs': ['python3-discogs-client>=2.3.15'],
143143
'beatport': ['requests-oauthlib>=0.6.1'],
144144
'kodiupdate': ['requests'],
145145
'lastgenre': ['pylast'],

0 commit comments

Comments
 (0)