mirror of
https://github.com/beetbox/beets.git
synced 2026-02-22 23:33:50 +01:00
Convert multiple plugins' logger usage (easy ones)
Those plugins only called methods and no function, which eases the conversion.
This commit is contained in:
parent
0617c0410f
commit
e14a54df05
9 changed files with 85 additions and 102 deletions
|
|
@ -19,12 +19,9 @@ from datetime import datetime, timedelta
|
|||
|
||||
import requests
|
||||
|
||||
from beets import logging
|
||||
from beets.autotag.hooks import AlbumInfo, TrackInfo, Distance
|
||||
from beets.plugins import BeetsPlugin
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class BeatportAPIError(Exception):
|
||||
pass
|
||||
|
|
@ -194,7 +191,7 @@ class BeatportPlugin(BeetsPlugin):
|
|||
try:
|
||||
return self._get_releases(query)
|
||||
except BeatportAPIError as e:
|
||||
log.debug(u'Beatport API Error: {0} (query: {1})', e, query)
|
||||
self._log.debug(u'Beatport API Error: {0} (query: {1})', e, query)
|
||||
return []
|
||||
|
||||
def item_candidates(self, item, artist, title):
|
||||
|
|
@ -205,14 +202,14 @@ class BeatportPlugin(BeetsPlugin):
|
|||
try:
|
||||
return self._get_tracks(query)
|
||||
except BeatportAPIError as e:
|
||||
log.debug(u'API Error: {0} (query: {1})', e, query)
|
||||
self._log.debug(u'API Error: {0} (query: {1})', e, query)
|
||||
return []
|
||||
|
||||
def album_for_id(self, release_id):
|
||||
"""Fetches a release by its Beatport ID and returns an AlbumInfo object
|
||||
or None if the release is not found.
|
||||
"""
|
||||
log.debug(u'Searching for release {0}', release_id)
|
||||
self._log.debug(u'Searching for release {0}', release_id)
|
||||
match = re.search(r'(^|beatport\.com/release/.+/)(\d+)$', release_id)
|
||||
if not match:
|
||||
return None
|
||||
|
|
@ -224,7 +221,7 @@ class BeatportPlugin(BeetsPlugin):
|
|||
"""Fetches a track by its Beatport ID and returns a TrackInfo object
|
||||
or None if the track is not found.
|
||||
"""
|
||||
log.debug(u'Searching for track {0}', track_id)
|
||||
self._log.debug(u'Searching for track {0}', track_id)
|
||||
match = re.search(r'(^|beatport\.com/track/.+/)(\d+)$', track_id)
|
||||
if not match:
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -16,11 +16,9 @@
|
|||
|
||||
import time
|
||||
|
||||
from beets import ui, logging
|
||||
from beets import ui
|
||||
from beets.plugins import BeetsPlugin
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def bpm(max_strokes):
|
||||
"""Returns average BPM (possibly of a playing song)
|
||||
|
|
@ -72,15 +70,15 @@ class BPMPlugin(BeetsPlugin):
|
|||
|
||||
item = items[0]
|
||||
if item['bpm']:
|
||||
log.info(u'Found bpm {0}', item['bpm'])
|
||||
self._log.info(u'Found bpm {0}', item['bpm'])
|
||||
if not overwrite:
|
||||
return
|
||||
|
||||
log.info(u'Press Enter {0} times to the rhythm or Ctrl-D '
|
||||
u'to exit', self.config['max_strokes'].get(int))
|
||||
self._log.info(u'Press Enter {0} times to the rhythm or Ctrl-D '
|
||||
u'to exit', self.config['max_strokes'].get(int))
|
||||
new_bpm = bpm(self.config['max_strokes'].get(int))
|
||||
item['bpm'] = int(new_bpm)
|
||||
if write:
|
||||
item.try_write()
|
||||
item.store()
|
||||
log.info(u'Added new bpm {0}', item['bpm'])
|
||||
self._log.info(u'Added new bpm {0}', item['bpm'])
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import re
|
|||
import time
|
||||
import json
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
# Silence spurious INFO log lines generated by urllib3.
|
||||
urllib3_logger = logging.getLogger('requests.packages.urllib3')
|
||||
|
|
@ -89,7 +88,7 @@ class DiscogsPlugin(BeetsPlugin):
|
|||
raise beets.ui.UserError('Discogs authorization failed')
|
||||
|
||||
# Save the token for later use.
|
||||
log.debug('Discogs token {0}, secret {1}', token, secret)
|
||||
self._log.debug('Discogs token {0}, secret {1}', token, secret)
|
||||
with open(self._tokenfile(), 'w') as f:
|
||||
json.dump({'token': token, 'secret': secret}, f)
|
||||
|
||||
|
|
@ -117,10 +116,10 @@ class DiscogsPlugin(BeetsPlugin):
|
|||
try:
|
||||
return self.get_albums(query)
|
||||
except DiscogsAPIError as e:
|
||||
log.debug(u'API Error: {0} (query: {1})', e, query)
|
||||
self._log.debug(u'API Error: {0} (query: {1})', e, query)
|
||||
return []
|
||||
except ConnectionError as e:
|
||||
log.debug(u'HTTP Connection Error: {0}', e)
|
||||
self._log.debug(u'HTTP Connection Error: {0}', e)
|
||||
return []
|
||||
|
||||
def album_for_id(self, album_id):
|
||||
|
|
@ -130,7 +129,7 @@ class DiscogsPlugin(BeetsPlugin):
|
|||
if not self.discogs_client:
|
||||
return
|
||||
|
||||
log.debug(u'Searching for release {0}', album_id)
|
||||
self._log.debug(u'Searching for release {0}', 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.
|
||||
# An optional bracket can follow the integer, as this is how discogs
|
||||
|
|
@ -145,10 +144,10 @@ class DiscogsPlugin(BeetsPlugin):
|
|||
getattr(result, 'title')
|
||||
except DiscogsAPIError as e:
|
||||
if e.message != '404 Not Found':
|
||||
log.debug(u'API Error: {0} (query: {1})', e, result._uri)
|
||||
self._log.debug(u'API Error: {0} (query: {1})', e, result._uri)
|
||||
return None
|
||||
except ConnectionError as e:
|
||||
log.debug(u'HTTP Connection Error: {0}', e)
|
||||
self._log.debug(u'HTTP Connection Error: {0}', e)
|
||||
return None
|
||||
return self.get_album_info(result)
|
||||
|
||||
|
|
@ -293,7 +292,7 @@ class DiscogsPlugin(BeetsPlugin):
|
|||
if match:
|
||||
medium, index = match.groups()
|
||||
else:
|
||||
log.debug(u'Invalid position: {0}', position)
|
||||
self._log.debug(u'Invalid position: {0}', position)
|
||||
medium = index = None
|
||||
return medium or None, index or None
|
||||
|
||||
|
|
|
|||
|
|
@ -21,14 +21,12 @@ import tempfile
|
|||
from string import Template
|
||||
import subprocess
|
||||
|
||||
from beets import util, config, plugins, ui, logging
|
||||
from beets import util, config, plugins, ui
|
||||
from beets.dbcore import types
|
||||
import pyechonest
|
||||
import pyechonest.song
|
||||
import pyechonest.track
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
# If a request at the EchoNest fails, we want to retry the request RETRIES
|
||||
# times and wait between retries for RETRY_INTERVAL seconds.
|
||||
RETRIES = 10
|
||||
|
|
@ -152,30 +150,30 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
|
|||
except pyechonest.util.EchoNestAPIError as e:
|
||||
if e.code == 3:
|
||||
# reached access limit per minute
|
||||
log.debug(u'rate-limited on try {0}; waiting {1} seconds',
|
||||
i + 1, RETRY_INTERVAL)
|
||||
self._log.debug(u'rate-limited on try {0}; waiting {1} '
|
||||
u'seconds', i + 1, RETRY_INTERVAL)
|
||||
time.sleep(RETRY_INTERVAL)
|
||||
elif e.code == 5:
|
||||
# specified identifier does not exist
|
||||
# no use in trying again.
|
||||
log.debug(u'{0}', e)
|
||||
self._log.debug(u'{0}', e)
|
||||
return None
|
||||
else:
|
||||
log.error(u'{0}', e.args[0][0])
|
||||
self._log.error(u'{0}', e.args[0][0])
|
||||
return None
|
||||
except (pyechonest.util.EchoNestIOError, socket.error) as e:
|
||||
log.warn(u'IO error: {0}', e)
|
||||
self._log.warn(u'IO error: {0}', e)
|
||||
time.sleep(RETRY_INTERVAL)
|
||||
except Exception as e:
|
||||
# there was an error analyzing the track, status: error
|
||||
log.debug(u'{0}', e)
|
||||
self._log.debug(u'{0}', e)
|
||||
return None
|
||||
else:
|
||||
break
|
||||
else:
|
||||
# If we exited the loop without breaking, then we used up all
|
||||
# our allotted retries.
|
||||
log.error(u'request failed repeatedly')
|
||||
self._log.error(u'request failed repeatedly')
|
||||
return None
|
||||
return result
|
||||
|
||||
|
|
@ -186,7 +184,7 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
|
|||
seconds, it's considered a match.
|
||||
"""
|
||||
if not songs:
|
||||
log.debug(u'no songs found')
|
||||
self._log.debug(u'no songs found')
|
||||
return
|
||||
|
||||
pick = None
|
||||
|
|
@ -224,13 +222,13 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
|
|||
# Look up the Echo Nest ID based on the MBID.
|
||||
else:
|
||||
if not item.mb_trackid:
|
||||
log.debug(u'no ID available')
|
||||
self._log.debug(u'no ID available')
|
||||
return
|
||||
mbid = 'musicbrainz:track:{0}'.format(item.mb_trackid)
|
||||
track = self._echofun(pyechonest.track.track_from_id,
|
||||
identifier=mbid)
|
||||
if not track:
|
||||
log.debug(u'lookup by MBID failed')
|
||||
self._log.debug(u'lookup by MBID failed')
|
||||
return
|
||||
enid = track.song_id
|
||||
|
||||
|
|
@ -290,9 +288,9 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
|
|||
fd, dest = tempfile.mkstemp(u'.ogg')
|
||||
os.close(fd)
|
||||
|
||||
log.info(u'encoding {0} to {1}',
|
||||
util.displayable_path(source),
|
||||
util.displayable_path(dest))
|
||||
self._log.info(u'encoding {0} to {1}',
|
||||
util.displayable_path(source),
|
||||
util.displayable_path(dest))
|
||||
|
||||
opts = []
|
||||
for arg in CONVERT_COMMAND.split():
|
||||
|
|
@ -303,12 +301,11 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
|
|||
try:
|
||||
util.command_output(opts)
|
||||
except (OSError, subprocess.CalledProcessError) as exc:
|
||||
log.debug(u'encode failed: {0}', exc)
|
||||
self._log.debug(u'encode failed: {0}', exc)
|
||||
util.remove(dest)
|
||||
return
|
||||
|
||||
log.info(u'finished encoding {0}',
|
||||
util.displayable_path(source))
|
||||
self._log.info(u'finished encoding {0}', util.displayable_path(source))
|
||||
return dest
|
||||
|
||||
def truncate(self, source):
|
||||
|
|
@ -316,9 +313,9 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
|
|||
fd, dest = tempfile.mkstemp(u'.ogg')
|
||||
os.close(fd)
|
||||
|
||||
log.info(u'truncating {0} to {1}',
|
||||
util.displayable_path(source),
|
||||
util.displayable_path(dest))
|
||||
self._log.info(u'truncating {0} to {1}',
|
||||
util.displayable_path(source),
|
||||
util.displayable_path(dest))
|
||||
|
||||
opts = []
|
||||
for arg in TRUNCATE_COMMAND.split():
|
||||
|
|
@ -329,12 +326,11 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
|
|||
try:
|
||||
util.command_output(opts)
|
||||
except (OSError, subprocess.CalledProcessError) as exc:
|
||||
log.debug(u'truncate failed: {0}', exc)
|
||||
self._log.debug(u'truncate failed: {0}', exc)
|
||||
util.remove(dest)
|
||||
return
|
||||
|
||||
log.info(u'truncate encoding {0}',
|
||||
util.displayable_path(source))
|
||||
self._log.info(u'truncate encoding {0}', util.displayable_path(source))
|
||||
return dest
|
||||
|
||||
def analyze(self, item):
|
||||
|
|
@ -343,18 +339,18 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
|
|||
"""
|
||||
prepared = self.prepare_upload(item)
|
||||
if not prepared:
|
||||
log.debug(u'could not prepare file for upload')
|
||||
self._log.debug(u'could not prepare file for upload')
|
||||
return
|
||||
|
||||
source, tmp = prepared
|
||||
log.info(u'uploading file, please be patient')
|
||||
self._log.info(u'uploading file, please be patient')
|
||||
track = self._echofun(pyechonest.track.track_from_filename,
|
||||
filename=source)
|
||||
if tmp is not None:
|
||||
util.remove(tmp)
|
||||
|
||||
if not track:
|
||||
log.debug(u'failed to upload file')
|
||||
self._log.debug(u'failed to upload file')
|
||||
return
|
||||
|
||||
# Sometimes we have a track but no song. I guess this happens for
|
||||
|
|
@ -405,12 +401,12 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
|
|||
for method in methods:
|
||||
song = method(item)
|
||||
if song:
|
||||
log.debug(u'got song through {0}: {1} - {2} [{3}]',
|
||||
method.__name__,
|
||||
item.artist,
|
||||
item.title,
|
||||
song.get('duration'),
|
||||
)
|
||||
self._log.debug(u'got song through {0}: {1} - {2} [{3}]',
|
||||
method.__name__,
|
||||
item.artist,
|
||||
item.title,
|
||||
song.get('duration'),
|
||||
)
|
||||
return song
|
||||
|
||||
def apply_metadata(self, item, values, write=False):
|
||||
|
|
@ -421,7 +417,7 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
|
|||
for k, v in values.iteritems():
|
||||
if k in ATTRIBUTES:
|
||||
field = ATTRIBUTES[k]
|
||||
log.debug(u'metadata: {0} = {1}', field, v)
|
||||
self._log.debug(u'metadata: {0} = {1}', field, v)
|
||||
if field == 'bpm':
|
||||
item[field] = int(v)
|
||||
else:
|
||||
|
|
@ -433,7 +429,7 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
|
|||
item['initial_key'] = key
|
||||
if 'id' in values:
|
||||
enid = values['id']
|
||||
log.debug(u'metadata: {0} = {1}', ID_KEY, enid)
|
||||
self._log.debug(u'metadata: {0} = {1}', ID_KEY, enid)
|
||||
item[ID_KEY] = enid
|
||||
|
||||
# Write and save.
|
||||
|
|
@ -460,7 +456,7 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
|
|||
for field in ATTRIBUTES.values():
|
||||
if not item.get(field):
|
||||
return True
|
||||
log.info(u'no update required')
|
||||
self._log.info(u'no update required')
|
||||
return False
|
||||
|
||||
def commands(self):
|
||||
|
|
@ -475,7 +471,7 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
|
|||
self.config.set_args(opts)
|
||||
write = config['import']['write'].get(bool)
|
||||
for item in lib.items(ui.decargs(args)):
|
||||
log.info(u'{0} - {1}', item.artist, item.title)
|
||||
self._log.info(u'{0} - {1}', item.artist, item.title)
|
||||
if self.config['force'] or self.requires_update(item):
|
||||
song = self.fetch_song(item)
|
||||
if song:
|
||||
|
|
|
|||
|
|
@ -111,14 +111,14 @@ class InlinePlugin(BeetsPlugin):
|
|||
# Item fields.
|
||||
for key, view in itertools.chain(config['item_fields'].items(),
|
||||
config['pathfields'].items()):
|
||||
log.debug(u'adding item field {0}', key)
|
||||
self._log.debug(u'adding item field {0}', key)
|
||||
func = compile_inline(view.get(unicode), False)
|
||||
if func is not None:
|
||||
self.template_fields[key] = func
|
||||
|
||||
# Album fields.
|
||||
for key, view in config['album_fields'].items():
|
||||
log.debug(u'adding album field {0}', key)
|
||||
self._log.debug(u'adding album field {0}', key)
|
||||
func = compile_inline(view.get(unicode), True)
|
||||
if func is not None:
|
||||
self.album_template_fields[key] = func
|
||||
|
|
|
|||
|
|
@ -17,15 +17,11 @@
|
|||
|
||||
import subprocess
|
||||
|
||||
from beets import logging
|
||||
from beets import ui
|
||||
from beets import util
|
||||
from beets.plugins import BeetsPlugin
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class KeyFinderPlugin(BeetsPlugin):
|
||||
|
||||
def __init__(self):
|
||||
|
|
@ -62,11 +58,11 @@ class KeyFinderPlugin(BeetsPlugin):
|
|||
try:
|
||||
key = util.command_output([bin, '-f', item.path])
|
||||
except (subprocess.CalledProcessError, OSError) as exc:
|
||||
log.error(u'execution failed: {0}', exc)
|
||||
self._log.error(u'execution failed: {0}', exc)
|
||||
continue
|
||||
|
||||
item['initial_key'] = key
|
||||
log.debug(u'added computed initial key {0} for {1}',
|
||||
key, util.displayable_path(item.path))
|
||||
self._log.debug(u'added computed initial key {0} for {1}',
|
||||
key, util.displayable_path(item.path))
|
||||
item.try_write()
|
||||
item.store()
|
||||
|
|
|
|||
|
|
@ -19,12 +19,9 @@ import re
|
|||
from collections import defaultdict
|
||||
|
||||
from beets.plugins import BeetsPlugin
|
||||
from beets import logging
|
||||
from beets import ui
|
||||
from beets import library
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def rewriter(field, rules):
|
||||
"""Create a template field function that rewrites the given field
|
||||
|
|
@ -59,7 +56,7 @@ class RewritePlugin(BeetsPlugin):
|
|||
if fieldname not in library.Item._fields:
|
||||
raise ui.UserError("invalid field name (%s) in rewriter" %
|
||||
fieldname)
|
||||
log.debug(u'adding template field {0}', key)
|
||||
self._log.debug(u'adding template field {0}', key)
|
||||
pattern = re.compile(pattern.lower())
|
||||
rules[fieldname].append((pattern, value))
|
||||
if fieldname == 'artist':
|
||||
|
|
|
|||
|
|
@ -4,11 +4,9 @@ import webbrowser
|
|||
import requests
|
||||
from beets.plugins import BeetsPlugin
|
||||
from beets.ui import decargs
|
||||
from beets import ui, logging
|
||||
from beets import ui
|
||||
from requests.exceptions import HTTPError
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class SpotifyPlugin(BeetsPlugin):
|
||||
|
||||
|
|
@ -62,7 +60,8 @@ class SpotifyPlugin(BeetsPlugin):
|
|||
self.config['show_failures'].set(True)
|
||||
|
||||
if self.config['mode'].get() not in ['list', 'open']:
|
||||
log.warn(u'{0} is not a valid mode', self.config['mode'].get())
|
||||
self._log.warn(u'{0} is not a valid mode',
|
||||
self.config['mode'].get())
|
||||
return False
|
||||
|
||||
self.opts = opts
|
||||
|
|
@ -76,10 +75,11 @@ class SpotifyPlugin(BeetsPlugin):
|
|||
items = lib.items(query)
|
||||
|
||||
if not items:
|
||||
log.debug(u'Your beets query returned no items, skipping spotify')
|
||||
self._log.debug(u'Your beets query returned no items, '
|
||||
u'skipping spotify')
|
||||
return
|
||||
|
||||
log.info(u'Processing {0} tracks...', len(items))
|
||||
self._log.info(u'Processing {0} tracks...', len(items))
|
||||
|
||||
for item in items:
|
||||
|
||||
|
|
@ -107,11 +107,12 @@ class SpotifyPlugin(BeetsPlugin):
|
|||
r = requests.get(self.base_url, params={
|
||||
"q": search_url, "type": "track"
|
||||
})
|
||||
log.debug(r.url)
|
||||
self._log.debug(r.url)
|
||||
try:
|
||||
r.raise_for_status()
|
||||
except HTTPError as e:
|
||||
log.debug(u'URL returned a {0} error', e.response.status_code)
|
||||
self._log.debug(u'URL returned a {0} error',
|
||||
e.response.status_code)
|
||||
failures.append(search_url)
|
||||
continue
|
||||
|
||||
|
|
@ -127,31 +128,33 @@ class SpotifyPlugin(BeetsPlugin):
|
|||
# Simplest, take the first result
|
||||
chosen_result = None
|
||||
if len(r_data) == 1 or self.config['tiebreak'].get() == "first":
|
||||
log.debug(u'Spotify track(s) found, count: {0}', len(r_data))
|
||||
self._log.debug(u'Spotify track(s) found, count: {0}',
|
||||
len(r_data))
|
||||
chosen_result = r_data[0]
|
||||
elif len(r_data) > 1:
|
||||
# Use the popularity filter
|
||||
log.debug(u'Most popular track chosen, count: {0}',
|
||||
len(r_data))
|
||||
self._log.debug(u'Most popular track chosen, count: {0}',
|
||||
len(r_data))
|
||||
chosen_result = max(r_data, key=lambda x: x['popularity'])
|
||||
|
||||
if chosen_result:
|
||||
results.append(chosen_result)
|
||||
else:
|
||||
log.debug(u'No spotify track found: {0}', search_url)
|
||||
self._log.debug(u'No spotify track found: {0}', search_url)
|
||||
failures.append(search_url)
|
||||
|
||||
failure_count = len(failures)
|
||||
if failure_count > 0:
|
||||
if self.config['show_failures'].get():
|
||||
log.info(u'{0} track(s) did not match a Spotify ID:',
|
||||
failure_count)
|
||||
self._log.info(u'{0} track(s) did not match a Spotify ID:',
|
||||
failure_count)
|
||||
for track in failures:
|
||||
log.info(u'track: {0}', track)
|
||||
log.info(u'')
|
||||
self._log.info(u'track: {0}', track)
|
||||
self._log.info(u'')
|
||||
else:
|
||||
log.warn(u'{0} track(s) did not match a Spotify ID;\n'
|
||||
u'use --show-failures to display', failure_count)
|
||||
self._log.warn(u'{0} track(s) did not match a Spotify ID;\n'
|
||||
u'use --show-failures to display',
|
||||
failure_count)
|
||||
|
||||
return results
|
||||
|
||||
|
|
@ -159,7 +162,7 @@ class SpotifyPlugin(BeetsPlugin):
|
|||
if results:
|
||||
ids = map(lambda x: x['id'], results)
|
||||
if self.config['mode'].get() == "open":
|
||||
log.info(u'Attempting to open Spotify with playlist')
|
||||
self._log.info(u'Attempting to open Spotify with playlist')
|
||||
spotify_url = self.playlist_partial + ",".join(ids)
|
||||
webbrowser.open(spotify_url)
|
||||
|
||||
|
|
@ -167,4 +170,4 @@ class SpotifyPlugin(BeetsPlugin):
|
|||
for item in ids:
|
||||
print(unicode.encode(self.open_url + item))
|
||||
else:
|
||||
log.warn(u'No Spotify tracks found from beets query')
|
||||
self._log.warn(u'No Spotify tracks found from beets query')
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
""" Clears tag fields in media files."""
|
||||
|
||||
import re
|
||||
from beets import logging
|
||||
from beets.plugins import BeetsPlugin
|
||||
from beets.mediafile import MediaFile
|
||||
from beets.importer import action
|
||||
|
|
@ -24,8 +23,6 @@ from beets.util import confit
|
|||
__author__ = 'baobab@heresiarch.info'
|
||||
__version__ = '0.10'
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ZeroPlugin(BeetsPlugin):
|
||||
|
||||
|
|
@ -48,11 +45,11 @@ class ZeroPlugin(BeetsPlugin):
|
|||
|
||||
for field in self.config['fields'].as_str_seq():
|
||||
if field in ('id', 'path', 'album_id'):
|
||||
log.warn(u'field \'{0}\' ignored, zeroing '
|
||||
u'it would be dangerous', field)
|
||||
self._log.warn(u'field \'{0}\' ignored, zeroing '
|
||||
u'it would be dangerous', field)
|
||||
continue
|
||||
if field not in MediaFile.fields():
|
||||
log.error(u'invalid field: {0}', field)
|
||||
self._log.error(u'invalid field: {0}', field)
|
||||
continue
|
||||
|
||||
try:
|
||||
|
|
@ -64,7 +61,7 @@ class ZeroPlugin(BeetsPlugin):
|
|||
def import_task_choice_event(self, session, task):
|
||||
"""Listen for import_task_choice event."""
|
||||
if task.choice_flag == action.ASIS and not self.warned:
|
||||
log.warn(u'cannot zero in \"as-is\" mode')
|
||||
self._log.warn(u'cannot zero in \"as-is\" mode')
|
||||
self.warned = True
|
||||
# TODO request write in as-is mode
|
||||
|
||||
|
|
@ -85,7 +82,7 @@ class ZeroPlugin(BeetsPlugin):
|
|||
by `self.patterns`.
|
||||
"""
|
||||
if not self.patterns:
|
||||
log.warn(u'no fields, nothing to do')
|
||||
self._log.warn(u'no fields, nothing to do')
|
||||
return
|
||||
|
||||
for field, patterns in self.patterns.items():
|
||||
|
|
@ -97,5 +94,5 @@ class ZeroPlugin(BeetsPlugin):
|
|||
match = patterns is True
|
||||
|
||||
if match:
|
||||
log.debug(u'{0}: {1} -> None', field, value)
|
||||
self._log.debug(u'{0}: {1} -> None', field, value)
|
||||
tags[field] = None
|
||||
|
|
|
|||
Loading…
Reference in a new issue