mirror of
https://github.com/beetbox/beets.git
synced 2026-02-25 16:53:17 +01:00
discogs: Only authenticate on import (#1123)
No need to authenticate for other commands.
This commit is contained in:
parent
00c8f6ac25
commit
fe655e4610
5 changed files with 21 additions and 4 deletions
|
|
@ -294,6 +294,7 @@ class ImportSession(object):
|
|||
pl = pipeline.Pipeline(stages)
|
||||
|
||||
# Run the pipeline.
|
||||
plugins.send('import_begin', session=self)
|
||||
try:
|
||||
if config['threaded']:
|
||||
pl.run_parallel(QUEUE_SIZE)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# This file is part of beets.
|
||||
# Copyright 2013, Adrian Sampson.
|
||||
# Copyright 2014, Adrian Sampson.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
|
|
@ -46,7 +46,12 @@ class DiscogsPlugin(BeetsPlugin):
|
|||
'tokenfile': 'discogs_token.json',
|
||||
'source_weight': 0.5,
|
||||
})
|
||||
self.discogs_client = None
|
||||
self.register_listener('import_begin', self.setup)
|
||||
|
||||
def setup(self):
|
||||
"""Create the `discogs_client` field. Authenticate if necessary.
|
||||
"""
|
||||
c_key = self.config['apikey'].get(unicode)
|
||||
c_secret = self.config['apisecret'].get(unicode)
|
||||
|
||||
|
|
@ -102,6 +107,9 @@ class DiscogsPlugin(BeetsPlugin):
|
|||
"""Returns a list of AlbumInfo objects for discogs search results
|
||||
matching an album and artist (if not various).
|
||||
"""
|
||||
if not self.discogs_client:
|
||||
return
|
||||
|
||||
if va_likely:
|
||||
query = album
|
||||
else:
|
||||
|
|
@ -119,6 +127,9 @@ class DiscogsPlugin(BeetsPlugin):
|
|||
"""Fetches an album by its Discogs ID and returns an AlbumInfo object
|
||||
or None if the album is not found.
|
||||
"""
|
||||
if not self.discogs_client:
|
||||
return
|
||||
|
||||
log.debug(u'Searching Discogs for release {0}'.format(str(album_id)))
|
||||
# Discogs-IDs are simple integers. We only look for those at the end
|
||||
# of an input string as to avoid confusion with other metadata plugins.
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ Fixed:
|
|||
|
||||
* Fix a new crash with the latest version of Mutagen (1.26).
|
||||
* We now print a better error message when the database file is corrupted.
|
||||
* :doc:`/plugins/discogs`: Only prompt for authentication when running the
|
||||
:ref:`import-cmd` command. :bug:`1123`
|
||||
|
||||
.. _Plex: https://plex.tv/
|
||||
|
||||
|
|
|
|||
|
|
@ -183,6 +183,9 @@ currently available are:
|
|||
* *cli_exit*: called just before the ``beet`` command-line program exits.
|
||||
Parameter: ``lib``.
|
||||
|
||||
* *import_begin*: called just before a ``beet import`` session starts up.
|
||||
Parameter: ``session``.
|
||||
|
||||
The included ``mpdupdate`` plugin provides an example use case for event listeners.
|
||||
|
||||
Extend the Autotagger
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ To use the ``discogs`` plugin, first enable it in your configuration (see
|
|||
pip install discogs-client
|
||||
|
||||
You will also need to register for a `Discogs`_ account. The first time you
|
||||
run beets after enabling the plugin, it will ask you to authorize with Discogs
|
||||
by visiting the site in a browser. Subsequent runs will not require
|
||||
re-authorization.
|
||||
run the :ref:`import-cmd` command after enabling the plugin, it will ask you
|
||||
to authorize with Discogs by visiting the site in a browser. Subsequent runs
|
||||
will not require re-authorization.
|
||||
|
||||
Matches from Discogs will now show up during import alongside matches from
|
||||
MusicBrainz.
|
||||
|
|
|
|||
Loading…
Reference in a new issue