|
1 | 1 | Export Plugin
|
2 | 2 | =============
|
3 | 3 |
|
4 |
| -The ``export`` plugin lets you get data from the items and export the content to |
5 |
| -a ``json`` file. |
| 4 | +The ``export`` plugin lets you get data from the items and export the content |
| 5 | +as `JSON`_. |
6 | 6 |
|
7 |
| -Configuration |
8 |
| -------------- |
9 |
| -To configure the plugin, make a ``export:`` section in your configuration |
10 |
| -file. The default options are:: |
| 7 | +.. _JSON: http://www.json.org |
11 | 8 |
|
12 |
| - export: |
13 |
| - default_format: json |
14 |
| - json: |
15 |
| - formatting: |
16 |
| - ensure_ascii: False |
17 |
| - indent: 4 |
18 |
| - separators: [',' , ': '] |
19 |
| - sort_keys: true |
| 9 | +Enable the ``export`` plugin (see :ref:`using-plugins` for help). Then, type ``beet export`` followed by a :doc:`query </reference/query>` to get the data from |
| 10 | +your library. For example, run this:: |
20 | 11 |
|
21 |
| -- **default_format**: Choose the format of the exported content. |
22 |
| - Supports json only for now. |
| 12 | + $ beet export beatles |
23 | 13 |
|
24 |
| -Each format have their own options. |
| 14 | +to print a JSON file containing information about your Beatles tracks. |
25 | 15 |
|
26 |
| -The ``json`` formatting uses the `json`_ standard library options. |
27 |
| -Using custom options overwrites all options at the same level. |
28 |
| -The default options used here are: |
| 16 | +Command-Line Options |
| 17 | +-------------------- |
29 | 18 |
|
30 |
| -- **ensure_ascii**: All non-ASCII characters are escaped with `\uXXXX`, if true. |
| 19 | +The ``export`` command has these command-line options: |
31 | 20 |
|
32 |
| -- **indent**: The number of spaces for indentation. |
| 21 | +* ``--include-keys`` or ``-i``: Choose the properties to include in the output |
| 22 | + data. The argument is a comma-separated list of simple glob patterns where |
| 23 | + ``*`` matches any string. For example:: |
33 | 24 |
|
34 |
| -- **separators**: A ``(item_separator, dict_separator)`` tuple |
| 25 | + $ beet export -i 'title,mb*' beatles |
35 | 26 |
|
36 |
| -- **sort_keys**: Sorts the keys of the json |
| 27 | + will include the ``title`` property and all properties starting with |
| 28 | + ``mb``. You can add the ``-i`` option multiple times to the command |
| 29 | + line. |
37 | 30 |
|
38 |
| -.. _json: https://docs.python.org/2/library/json.html#basic-usage |
| 31 | +* ``--library`` or ``-l``: Show data from the library database instead of the |
| 32 | + files' tags. |
39 | 33 |
|
40 |
| -Using |
41 |
| ------ |
| 34 | +* ``--output`` or ``-o``: Path for an output file. If not informed, will print |
| 35 | + the data in the console. |
42 | 36 |
|
43 |
| -Enable the ``export`` plugin (see :ref:`using-plugins` for help) and then add a |
44 |
| -``export`` section to your :doc:`configuration file </reference/config>` |
| 37 | +* ``--append``: Appends the data to the file instead of writing. |
45 | 38 |
|
46 |
| -To use, you can enter a :doc:`query </reference/query>` to get the data from |
47 |
| -your library:: |
| 39 | +Configuration |
| 40 | +------------- |
48 | 41 |
|
49 |
| - $ beet export beatles |
| 42 | +To configure the plugin, make a ``export:`` section in your configuration |
| 43 | +file. Under the ``json`` key, these options are available: |
50 | 44 |
|
51 |
| -If you just want to see specific properties you can use the |
52 |
| -``--include-keys`` option to filter them. The argument is a |
53 |
| -comma-separated list of simple glob patterns where ``*`` matches any |
54 |
| -string. For example:: |
| 45 | +- **ensure_ascii**: Escape non-ASCII characters with `\uXXXX` entities. |
55 | 46 |
|
56 |
| - $ beet export -i 'title,mb*' beatles |
| 47 | +- **indent**: The number of spaces for indentation. |
57 | 48 |
|
58 |
| -Will only show the ``title`` property and all properties starting with |
59 |
| -``mb``. You can add the ``-i`` option multiple times to the command |
60 |
| -line. |
| 49 | +- **separators**: A ``[item_separator, dict_separator]`` tuple. |
61 | 50 |
|
62 |
| -Additional command-line options include: |
| 51 | +- **sort_keys**: Sorts the keys in JSON dictionaries. |
63 | 52 |
|
64 |
| -* ``--library`` or ``-l``: Show data from the library database instead of the |
65 |
| - files' tags. |
| 53 | +These options match the options from the `Python json module`_. |
66 | 54 |
|
67 |
| -* ``--output`` or ``-o``: Path for an output file. If not informed, will print |
68 |
| - the data in the console. |
| 55 | +.. _Python json module: https://docs.python.org/2/library/json.html#basic-usage |
69 | 56 |
|
70 |
| -* ``--append``: Appends the data to the file instead of writing. |
| 57 | +The default options look like this:: |
| 58 | + |
| 59 | + export: |
| 60 | + json: |
| 61 | + formatting: |
| 62 | + ensure_ascii: False |
| 63 | + indent: 4 |
| 64 | + separators: [',' , ': '] |
| 65 | + sort_keys: true |
0 commit comments