fromfilename: Add debug log messages

that inform when the plugin replaced bad artist, title or tracknumber metadata.
This commit is contained in:
J0J0 T 2022-03-23 21:23:19 +01:00 committed by J0J0 Todos
parent 5461ddf9f2
commit c1abcf3310

View file

@ -18,9 +18,11 @@ filename.
from beets import plugins
from beets.util import displayable_path
from beets import logging
import os
import re
log = logging.getLogger('beets')
# Filename field extraction patterns.
PATTERNS = [
@ -113,6 +115,9 @@ def apply_matches(d):
for item in d:
if not item.artist:
item.artist = artist
log.debug(
'fromfilename: Artist replaced with: {}'
.format(item.artist))
# No artist field: remaining field is the title.
else:
@ -122,8 +127,14 @@ def apply_matches(d):
for item in d:
if bad_title(item.title):
item.title = str(d[item][title_field])
log.debug(
'fromfilename: Title replaced with: {}'
.format(item.title))
if 'track' in d[item] and item.track == 0:
item.track = int(d[item]['track'])
log.debug(
'fromfilename: Track replaced with: {}'
.format(item.track))
# Plugin structure and hook into import process.