mirror of
https://github.com/beetbox/beets.git
synced 2025-12-07 00:53:08 +01:00
parent
d932aa4f5c
commit
e848adab04
7 changed files with 40 additions and 0 deletions
|
|
@ -10,6 +10,7 @@ import:
|
||||||
delete: no
|
delete: no
|
||||||
resume: ask
|
resume: ask
|
||||||
incremental: no
|
incremental: no
|
||||||
|
from_scratch: no
|
||||||
quiet_fallback: skip
|
quiet_fallback: skip
|
||||||
none_rec_action: ask
|
none_rec_action: ask
|
||||||
timid: no
|
timid: no
|
||||||
|
|
|
||||||
|
|
@ -534,6 +534,10 @@ class ImportTask(BaseImportTask):
|
||||||
def apply_metadata(self):
|
def apply_metadata(self):
|
||||||
"""Copy metadata from match info to the items.
|
"""Copy metadata from match info to the items.
|
||||||
"""
|
"""
|
||||||
|
if config['import']['from_scratch']:
|
||||||
|
for item in self.match.mapping:
|
||||||
|
item.clear()
|
||||||
|
|
||||||
autotag.apply_metadata(self.match.info, self.match.mapping)
|
autotag.apply_metadata(self.match.info, self.match.mapping)
|
||||||
|
|
||||||
def duplicate_items(self, lib):
|
def duplicate_items(self, lib):
|
||||||
|
|
|
||||||
|
|
@ -561,6 +561,11 @@ class Item(LibModel):
|
||||||
if self.mtime == 0 and 'mtime' in values:
|
if self.mtime == 0 and 'mtime' in values:
|
||||||
self.mtime = values['mtime']
|
self.mtime = values['mtime']
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
"""Set all key/value pairs to None."""
|
||||||
|
for key in self._media_fields:
|
||||||
|
setattr(self, key, None)
|
||||||
|
|
||||||
def get_album(self):
|
def get_album(self):
|
||||||
"""Get the Album object that this item belongs to, if any, or
|
"""Get the Album object that this item belongs to, if any, or
|
||||||
None if the item is a singleton or is not associated with a
|
None if the item is a singleton or is not associated with a
|
||||||
|
|
|
||||||
|
|
@ -1004,6 +1004,10 @@ import_cmd.parser.add_option(
|
||||||
u'-I', u'--noincremental', dest='incremental', action='store_false',
|
u'-I', u'--noincremental', dest='incremental', action='store_false',
|
||||||
help=u'do not skip already-imported directories'
|
help=u'do not skip already-imported directories'
|
||||||
)
|
)
|
||||||
|
import_cmd.parser.add_option(
|
||||||
|
u'--from-scratch', dest='from_scratch', action='store_true',
|
||||||
|
help=u'erase existing metadata before applying new metadata'
|
||||||
|
)
|
||||||
import_cmd.parser.add_option(
|
import_cmd.parser.add_option(
|
||||||
u'--flat', dest='flat', action='store_true',
|
u'--flat', dest='flat', action='store_true',
|
||||||
help=u'import an entire tree as a single album'
|
help=u'import an entire tree as a single album'
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,12 @@ Optional command flags:
|
||||||
time, when no subdirectories will be skipped. So consider enabling the
|
time, when no subdirectories will be skipped. So consider enabling the
|
||||||
``incremental`` configuration option.
|
``incremental`` configuration option.
|
||||||
|
|
||||||
|
* When beets applies metadata to your music, it will retain the value of any
|
||||||
|
existing tags that weren't overwritten, and import them into the database. You
|
||||||
|
may prefer to only use existing metadata for finding matches, and to erase it
|
||||||
|
completely when new metadata is applied. You can enforce this behavior with
|
||||||
|
the ``--from-scratch`` option, or the ``from_scratch`` configuration option.
|
||||||
|
|
||||||
* By default, beets will proceed without asking if it finds a very close
|
* By default, beets will proceed without asking if it finds a very close
|
||||||
metadata match. To disable this and have the importer ask you every time,
|
metadata match. To disable this and have the importer ask you every time,
|
||||||
use the ``-t`` (for *timid*) option.
|
use the ``-t`` (for *timid*) option.
|
||||||
|
|
|
||||||
|
|
@ -475,6 +475,15 @@ Either ``yes`` or ``no``, controlling whether imported directories are
|
||||||
recorded and whether these recorded directories are skipped. This
|
recorded and whether these recorded directories are skipped. This
|
||||||
corresponds to the ``-i`` flag to ``beet import``.
|
corresponds to the ``-i`` flag to ``beet import``.
|
||||||
|
|
||||||
|
.. _from_scratch:
|
||||||
|
|
||||||
|
from_scratch
|
||||||
|
~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Either ``yes`` or ``no`` (default), controlling whether existing metadata is
|
||||||
|
discarded when a match is applied. This corresponds to the ``-from_scratch``
|
||||||
|
flag to ``beet import``.
|
||||||
|
|
||||||
quiet_fallback
|
quiet_fallback
|
||||||
~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -633,6 +633,17 @@ class ImportTest(_common.TestCase, ImportHelper):
|
||||||
self.assert_file_in_lib(
|
self.assert_file_in_lib(
|
||||||
b'Applied Artist', b'Applied Album', b'Applied Title 1.mp3')
|
b'Applied Artist', b'Applied Album', b'Applied Title 1.mp3')
|
||||||
|
|
||||||
|
def test_apply_from_scratch_removes_other_metadata(self):
|
||||||
|
config['import']['from_scratch'] = True
|
||||||
|
|
||||||
|
for mediafile in self.import_media:
|
||||||
|
mediafile.genre = u'Tag Genre'
|
||||||
|
mediafile.save()
|
||||||
|
|
||||||
|
self.importer.add_choice(importer.action.APPLY)
|
||||||
|
self.importer.run()
|
||||||
|
self.assertEqual(self.lib.items().get().genre, u'')
|
||||||
|
|
||||||
def test_apply_with_move_deletes_import(self):
|
def test_apply_with_move_deletes_import(self):
|
||||||
config['import']['move'] = True
|
config['import']['move'] = True
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue