mirror of
https://github.com/beetbox/beets.git
synced 2025-12-15 21:14:19 +01:00
info: eager error detection (closes #371)
This commit is contained in:
parent
38bceaa073
commit
46df8c4f0d
2 changed files with 14 additions and 2 deletions
|
|
@ -15,12 +15,15 @@
|
|||
"""Shows file metadata.
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from beets.plugins import BeetsPlugin
|
||||
from beets import library
|
||||
from beets import ui
|
||||
from beets import mediafile
|
||||
from beets import util
|
||||
|
||||
|
||||
def info(paths):
|
||||
# Set up fields to output.
|
||||
fields = []
|
||||
|
|
@ -39,11 +42,18 @@ def info(paths):
|
|||
ui.print_()
|
||||
|
||||
path = util.normpath(path)
|
||||
if not os.path.isfile(path):
|
||||
ui.print_(u'not a file: {0}'.format(
|
||||
util.displayable_path(path)
|
||||
))
|
||||
continue
|
||||
ui.print_(path)
|
||||
try:
|
||||
mf = mediafile.MediaFile(path)
|
||||
except mediafile.UnreadableFileError:
|
||||
ui.print_('cannot read file')
|
||||
ui.print_('cannot read file: {0}'.format(
|
||||
util.displayable_path(path)
|
||||
))
|
||||
continue
|
||||
|
||||
# Basic fields.
|
||||
|
|
@ -52,9 +62,9 @@ def info(paths):
|
|||
# Extra stuff.
|
||||
ui.print_(lineformat.format('album art', mf.art is not None))
|
||||
|
||||
|
||||
first = False
|
||||
|
||||
|
||||
class InfoPlugin(BeetsPlugin):
|
||||
def commands(self):
|
||||
cmd = ui.Subcommand('info', help='show file metadata')
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ And some fixes:
|
|||
unrecognized type.
|
||||
* :doc:`/plugins/mbcollection`: Detect, log, and skip invalid MusicBrainz IDs
|
||||
(instead of failing with an API error).
|
||||
* :doc:`/plugins/info`: Fail gracefully when used erroneously with a
|
||||
directory.
|
||||
|
||||
.. _Opus: http://www.opus-codec.org/
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue