improvements from review #2

This commit is contained in:
MrNuggelz 2019-10-15 21:54:35 +02:00
parent 3d15eaff2e
commit d11e14b1a0
3 changed files with 30 additions and 9 deletions

View file

@ -1,10 +1,31 @@
# -*- coding: utf-8 -*-
# This file is part of beets.
# Copyright 2019, Joris Jensen
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
"""
List all files in the library folder which are not listed in the
beets library database, including art files
"""
from __future__ import absolute_import, division, print_function
import os
from beets import util
from beets.plugins import BeetsPlugin
from beets.ui import Subcommand
from beets.ui import Subcommand, print_
__author__ = 'https://github.com/MrNuggelz'
class Unimported(BeetsPlugin):
@ -19,16 +40,17 @@ class Unimported(BeetsPlugin):
def commands(self):
def print_unimported(lib, opts, args):
exts_to_ignore = self.config['ignore_extensions'].as_str_seq()
ignore_exts = [('.' + x).encode() for x
in self.config['ignore_extensions'].as_str_seq()]
in_folder = set(
(os.path.join(r, file) for r, d, f in os.walk(lib.directory)
for file in f if not any(
[file.endswith(extension.encode()) for extension in
exts_to_ignore])))
[file.endswith(extension) for extension in
ignore_exts])))
in_library = set(x.path for x in lib.items())
art_files = set(x.artpath for x in lib.albums())
for f in in_folder - in_library - art_files:
print(util.displayable_path(f))
print_(util.displayable_path(f))
unimported = Subcommand(
'unimported',

View file

@ -6,7 +6,7 @@ Changelog
New features:
* :doc:`/plugins/unimported`: Added `unimported` plugin.
* :doc:`/plugins/unimported`: lets you find untracked files in your library directory.
* We now fetch information about `works`_ from MusicBrainz.
MusicBrainz matches provide the fields ``work`` (the title), ``mb_workid``
(the MBID), and ``work_disambig`` (the disambiguation string).

View file

@ -1,7 +1,7 @@
Unimported Plugin
=================
The ``unimported`` plugin allows to list all files in the library folder which are not listed in the beets library database.
The ``unimported`` plugin allows to list all files in the library folder which are not listed in the beets library database, including art files.
Command Line Usage
------------------
@ -14,5 +14,4 @@ exclude file extensions using the configuration file::
unimported:
ignore_extensions: jpg png
The default configuration moves all English articles to the end of the string,
but you can override these defaults to make more complex changes.
The default configuration list all unimported files, ignoring no extensions.