From f268aae17fd528c909a5e9e1dfcee4d22540dcc2 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Tue, 26 Feb 2013 20:59:52 -0800 Subject: [PATCH] add --flat option to import command (GC-202) --- beets/config_default.yaml | 1 + beets/importer.py | 9 +++++++++ beets/ui/commands.py | 2 ++ docs/changelog.rst | 3 +++ docs/reference/cli.rst | 6 ++++++ 5 files changed, 21 insertions(+) diff --git a/beets/config_default.yaml b/beets/config_default.yaml index 2bd799612..210d7f1db 100644 --- a/beets/config_default.yaml +++ b/beets/config_default.yaml @@ -18,6 +18,7 @@ import: default_action: apply languages: [] detail: no + flat: no clutter: ["Thumbs.DB", ".DS_Store"] ignore: [".*", "*~", "System Volume Information"] diff --git a/beets/importer.py b/beets/importer.py index a6ff10fbc..10c66f85f 100644 --- a/beets/importer.py +++ b/beets/importer.py @@ -564,6 +564,15 @@ def read_tasks(session): yield ImportTask.item_task(item) continue + # A flat album import merges all items into one album. + if config['import']['flat'] and not config['import']['singletons']: + all_items = [] + for _, items in autotag.albums_in_dir(toppath): + all_items += items + yield ImportTask(toppath, toppath, all_items) + yield ImportTask.done_sentinel(toppath) + continue + # Produce paths under this directory. if _resume(): resume_dir = resume_dirs.get(toppath) diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 53a9505cd..39702a85e 100644 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -713,6 +713,8 @@ import_cmd.parser.add_option('-i', '--incremental', dest='incremental', action='store_true', help='skip already-imported directories') import_cmd.parser.add_option('-I', '--noincremental', dest='incremental', action='store_false', help='do not skip already-imported directories') +import_cmd.parser.add_option('--flat', dest='flat', + action='store_true', help='import an entire tree as a single album') def import_func(lib, opts, args): config['import'].set_args(opts) diff --git a/docs/changelog.rst b/docs/changelog.rst index 6f1379a56..156c30df5 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -12,6 +12,9 @@ New configuration options: Sam Doshi. * :ref:`detail` enables a mode where all tracks are listed in the importer UI, as opposed to only changed tracks. +* The ``--flat`` option to the ``beet import`` command treats an entire + directory tree of music files as a single album. This can help in situations + where a multi-disc album is split across multiple directories. Other stuff: diff --git a/docs/reference/cli.rst b/docs/reference/cli.rst index ca718cea5..2add6aaba 100644 --- a/docs/reference/cli.rst +++ b/docs/reference/cli.rst @@ -93,6 +93,12 @@ right now; this is something we need to work on. Read the instead want to import individual, non-album tracks, use the *singleton* mode by supplying the ``-s`` option. +* If you have an album that's split across several directories under a common + top directory, use the ``--flat`` option. This takes all the music files + under the directory (recursively) and treats them as a single large album + instead of as one album per directory. This can help with your more stubborn + multi-disc albums. + .. only:: html Reimporting