Debian Codegraph @

docs/plugins/importsource.rst

raw
1 ImportSource Plugin
2 ===================
3
4 The ``importsource`` plugin adds a ``source_path`` field to every item imported
5 to the library which stores the original media files' paths. Using this plugin
6 makes most sense when the general importing workflow is using ``beet import
7 --copy``. Additionally the plugin interactively suggests deletion of original
8 source files whenever items are removed from the Beets library.
9
10 To enable it, add ``importsource`` to the list of plugins in your configuration
11 (see :ref:`using-plugins`).
12
13 Tracking Source Paths
14 ---------------------
15
16 The primary use case for the plugin is tracking the original location of
17 imported files using the ``source_path`` field. Consider this scenario: you've
18 imported all directories in your current working directory using:
19
20 .. code-block:: bash
21
22 beet import --flat --copy */
23
24 Later, for instance if the import didn't complete successfully, you'll need to
25 rerun the import but don't want Beets to re-process the already successfully
26 imported directories. You can view which files were successfully imported using:
27
28 .. code-block:: bash
29
30 beet ls source_path:$PWD --format='$source_path'
31
32 To extract just the directory names, pipe the output to standard UNIX utilities:
33
34 .. code-block:: bash
35
36 beet ls source_path:$PWD --format='$source_path' | awk -F / '{print $(NF-1)}' | sort -u
37
38 This might help to find out what's left to be imported.
39
40 Removal Suggestion
41 ------------------
42
43 Another feature of the plugin is suggesting removal of original source files
44 when items are deleted from your library. Consider this scenario: you imported
45 an album using:
46
47 .. code-block:: bash
48
49 beet import --copy --flat ~/Desktop/interesting-album-to-check/
50
51 After listening to that album and deciding it wasn't good, you want to delete it
52 from your library as well as from your ``~/Desktop``, so you run:
53
54 .. code-block:: bash
55
56 beet remove --delete source_path:$HOME/Desktop/interesting-album-to-check
57
58 After approving the deletion, the plugin will prompt:
59
60 .. code-block:: text
61
62 The item:
63 <music-library>/Interesting Album/01 Interesting Song.flac
64 is originated from:
65 <HOME>/Desktop/interesting-album-to-check/01-interesting-song.flac
66 What would you like to do?
67 Delete the item's source, Recursively delete the source's directory,
68 do Nothing,
69 do nothing and Stop suggesting to delete items from this album?
70
71 Configuration
72 -------------
73
74 To configure the plugin, make an ``importsource:`` section in your configuration
75 file. There is one option available:
76
77 - **suggest_removal**: By default ``importsource`` suggests to remove the
78 original directories / files from which the items were imported whenever
79 library items (and files) are removed. To disable these prompts set this
80 option to ``no``. Default: ``yes``.