mirror of
https://github.com/beetbox/beets.git
synced 2025-12-09 18:12:19 +01:00
Plugin rename importmtimes -> importadded.
This includes some minor changes to the documentation.
This commit is contained in:
parent
34c256925e
commit
e800c9cc62
3 changed files with 19 additions and 19 deletions
|
|
@ -14,17 +14,17 @@ from beets.plugins import BeetsPlugin
|
||||||
log = logging.getLogger('beets')
|
log = logging.getLogger('beets')
|
||||||
|
|
||||||
|
|
||||||
class ImportMtimesPlugin(BeetsPlugin):
|
class ImportAddedPlugin(BeetsPlugin):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(ImportMtimesPlugin, self).__init__()
|
super(ImportAddedPlugin, self).__init__()
|
||||||
self.config.add({
|
self.config.add({
|
||||||
'preserve_mtimes': False,
|
'preserve_mtimes': False,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@ImportMtimesPlugin.listen('import_task_start')
|
@ImportAddedPlugin.listen('import_task_start')
|
||||||
def check_config(task, session):
|
def check_config(task, session):
|
||||||
config['importmtimes']['preserve_mtimes'].get(bool)
|
config['importadded']['preserve_mtimes'].get(bool)
|
||||||
|
|
||||||
|
|
||||||
def write_file_mtime(path, mtime):
|
def write_file_mtime(path, mtime):
|
||||||
|
|
@ -53,8 +53,8 @@ def write_item_mtime(item, mtime):
|
||||||
item.mtime = mtime
|
item.mtime = mtime
|
||||||
|
|
||||||
|
|
||||||
@ImportMtimesPlugin.listen('before_item_moved')
|
@ImportAddedPlugin.listen('before_item_moved')
|
||||||
@ImportMtimesPlugin.listen('item_copied')
|
@ImportAddedPlugin.listen('item_copied')
|
||||||
def record_import_mtime(item, source, destination):
|
def record_import_mtime(item, source, destination):
|
||||||
"""Record the file mtime of an item's path before import.
|
"""Record the file mtime of an item's path before import.
|
||||||
"""
|
"""
|
||||||
|
|
@ -70,14 +70,14 @@ def record_import_mtime(item, source, destination):
|
||||||
util.displayable_path(source))
|
util.displayable_path(source))
|
||||||
|
|
||||||
|
|
||||||
@ImportMtimesPlugin.listen('album_imported')
|
@ImportAddedPlugin.listen('album_imported')
|
||||||
def update_album_times(lib, album):
|
def update_album_times(lib, album):
|
||||||
album_mtimes = []
|
album_mtimes = []
|
||||||
for item in album.items():
|
for item in album.items():
|
||||||
mtime = item_mtime[item.path]
|
mtime = item_mtime[item.path]
|
||||||
if mtime is not None:
|
if mtime is not None:
|
||||||
album_mtimes.append(mtime)
|
album_mtimes.append(mtime)
|
||||||
if config['importmtimes']['preserve_mtimes'].get(bool):
|
if config['importadded']['preserve_mtimes'].get(bool):
|
||||||
write_item_mtime(item, mtime)
|
write_item_mtime(item, mtime)
|
||||||
item.store()
|
item.store()
|
||||||
del item_mtime[item.path]
|
del item_mtime[item.path]
|
||||||
|
|
@ -86,12 +86,12 @@ def update_album_times(lib, album):
|
||||||
album.store()
|
album.store()
|
||||||
|
|
||||||
|
|
||||||
@ImportMtimesPlugin.listen('item_imported')
|
@ImportAddedPlugin.listen('item_imported')
|
||||||
def update_item_times(lib, item):
|
def update_item_times(lib, item):
|
||||||
mtime = item_mtime[item.path]
|
mtime = item_mtime[item.path]
|
||||||
if mtime is not None:
|
if mtime is not None:
|
||||||
item.added = mtime
|
item.added = mtime
|
||||||
if config['importmtimes']['preserve_mtimes'].get(bool):
|
if config['importadded']['preserve_mtimes'].get(bool):
|
||||||
write_item_mtime(item, mtime)
|
write_item_mtime(item, mtime)
|
||||||
item.store()
|
item.store()
|
||||||
del item_mtime[item.path]
|
del item_mtime[item.path]
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
ImportMtimes Plugin
|
ImportAdded Plugin
|
||||||
===================
|
==================
|
||||||
|
|
||||||
The ``importmtimes`` plugin is useful when an existing collection is imported
|
The ``importadded`` plugin is useful when an existing collection is imported
|
||||||
and the time when albums and items were added should be preserved.
|
and the time when albums and items were added should be preserved.
|
||||||
|
|
||||||
The :abbr:`mtime (modification time)` of files that are imported into the
|
The :abbr:`mtime (modification time)` of files that are imported into the
|
||||||
|
|
@ -18,7 +18,7 @@ The ``item.added`` field is populated as follows:
|
||||||
|
|
||||||
This plugin can optionally be configured to also preserve mtimes::
|
This plugin can optionally be configured to also preserve mtimes::
|
||||||
|
|
||||||
importmtimes:
|
importadded:
|
||||||
preserve_mtimes: yes # default: no
|
preserve_mtimes: yes # default: no
|
||||||
|
|
||||||
File modification times are preserved as follows:
|
File modification times are preserved as follows:
|
||||||
|
|
@ -29,5 +29,5 @@ File modification times are preserved as follows:
|
||||||
from which the item is imported from.
|
from which the item is imported from.
|
||||||
* The mtime of the file ``item.path`` is set to ``item.mtime``.
|
* The mtime of the file ``item.path`` is set to ``item.mtime``.
|
||||||
|
|
||||||
Note that albums doesn't have an mtime field. The mtime of album
|
Note that there is no ``album.mtime`` field in the database and that the mtime
|
||||||
directories are not preserved.
|
of album directories on disk aren't preserved.
|
||||||
|
|
@ -59,7 +59,7 @@ by typing ``beet version``.
|
||||||
ftintitle
|
ftintitle
|
||||||
keyfinder
|
keyfinder
|
||||||
bucket
|
bucket
|
||||||
importmtimes
|
importadded
|
||||||
|
|
||||||
Autotagger Extensions
|
Autotagger Extensions
|
||||||
---------------------
|
---------------------
|
||||||
|
|
@ -92,8 +92,8 @@ Metadata
|
||||||
statistics (last_played, play_count, skip_count, rating).
|
statistics (last_played, play_count, skip_count, rating).
|
||||||
* :doc:`keyfinder`: Use the `KeyFinder`_ program to detect the musical
|
* :doc:`keyfinder`: Use the `KeyFinder`_ program to detect the musical
|
||||||
key from the audio.
|
key from the audio.
|
||||||
* :doc:`importmtimes`: Preserve file modification times and use them as values
|
* :doc:`importadded`: Use file modification times for guessing the value for
|
||||||
for the `added` and `mtime` fields in the database.
|
the `added` field in the database.
|
||||||
|
|
||||||
.. _Acoustic Attributes: http://developer.echonest.com/acoustic-attributes.html
|
.. _Acoustic Attributes: http://developer.echonest.com/acoustic-attributes.html
|
||||||
.. _the Echo Nest: http://www.echonest.com
|
.. _the Echo Nest: http://www.echonest.com
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue