Skip to content

Commit

Permalink
Merge pull request #4698 from ghbrown/discogs_client_check
Browse files Browse the repository at this point in the history
discogs_client version check
  • Loading branch information
sampsyo authored Mar 11, 2023
2 parents 9bc6066 + f1b7832 commit 2e18f84
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
15 changes: 15 additions & 0 deletions beetsplug/discogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from beets.autotag.hooks import AlbumInfo, TrackInfo
from beets.plugins import MetadataSourcePlugin, BeetsPlugin, get_distance
import confuse
from discogs_client import __version__ as dc_string
from discogs_client import Release, Master, Client
from discogs_client.exceptions import DiscogsAPIError
from requests.exceptions import ConnectionError
Expand Down Expand Up @@ -50,6 +51,7 @@ class DiscogsPlugin(BeetsPlugin):

def __init__(self):
super().__init__()
self.check_discogs_client()
self.config.add({
'apikey': API_KEY,
'apisecret': API_SECRET,
Expand All @@ -66,6 +68,19 @@ def __init__(self):
self.discogs_client = None
self.register_listener('import_begin', self.setup)

def check_discogs_client(self):
"""Ensure python3-discogs-client version >= 2.3.15
"""
dc_min_version = [2, 3, 15]
dc_version = [int(elem) for elem in dc_string.split('.')]
min_len = min(len(dc_version), len(dc_min_version))
gt_min = [(elem > elem_min) for elem, elem_min in
zip(dc_version[:min_len],
dc_min_version[:min_len])]
if True not in gt_min:
self._log.warning(('python3-discogs-client version should be '
'>= 2.3.15'))

def setup(self, session=None):
"""Create the `discogs_client` field. Authenticate if necessary.
"""
Expand Down
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ New features:
:bug:`4251`
* :doc:`/plugins/discogs`: Permit appending style to genre.
* :doc:`plugins/discogs`: Implement item_candidates for matching singletons.
* :doc:`plugins/discogs`: Check for compliant discogs_client module.
* :doc:`/plugins/convert`: Add a new `auto_keep` option that automatically
converts files but keeps the *originals* in the library.
:bug:`1840` :bug:`4302`
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def build_manpages():
'requests_oauthlib',
'reflink',
'rarfile',
'python3-discogs-client',
'python3-discogs-client>=2.3.15',
'py7zr',
],
'lint': [
Expand Down Expand Up @@ -139,7 +139,7 @@ def build_manpages():
'embedart': ['Pillow'],
'embyupdate': ['requests'],
'chroma': ['pyacoustid'],
'discogs': ['python3-discogs-client>=2.3.10'],
'discogs': ['python3-discogs-client>=2.3.15'],
'beatport': ['requests-oauthlib>=0.6.1'],
'kodiupdate': ['requests'],
'lastgenre': ['pylast'],
Expand Down

0 comments on commit 2e18f84

Please sign in to comment.