| 1 |
Random Plugin |
| 2 |
============= |
| 3 |
|
| 4 |
The ``random`` plugin provides a command that randomly selects tracks or albums |
| 5 |
from your library. This can be helpful if you need some help deciding what to |
| 6 |
listen to. |
| 7 |
|
| 8 |
First, enable the plugin named ``random`` (see :ref:`using-plugins`). You'll |
| 9 |
then be able to use the ``beet random`` command: |
| 10 |
|
| 11 |
.. code-block:: shell |
| 12 |
|
| 13 |
beet random |
| 14 |
>> Aesop Rock - None Shall Pass - The Harbor Is Yours |
| 15 |
|
| 16 |
Usage |
| 17 |
----- |
| 18 |
|
| 19 |
The basic command selects and displays a single random track. Several options |
| 20 |
allow you to customize the selection: |
| 21 |
|
| 22 |
.. code-block:: shell |
| 23 |
|
| 24 |
Usage: beet random [options] |
| 25 |
|
| 26 |
Options: |
| 27 |
-h, --help show this help message and exit |
| 28 |
-n NUMBER, --number=NUMBER |
| 29 |
number of objects to choose |
| 30 |
-e, --equal-chance each field has the same chance |
| 31 |
-t TIME, --time=TIME total length in minutes of objects to choose |
| 32 |
--field=FIELD field to use for equal chance sampling (default: |
| 33 |
albumartist) |
| 34 |
-a, --album match albums instead of tracks |
| 35 |
-p PATH, --path=PATH print paths for matched items or albums |
| 36 |
-f FORMAT, --format=FORMAT |
| 37 |
print with custom format |
| 38 |
|
| 39 |
Detailed Options |
| 40 |
---------------- |
| 41 |
|
| 42 |
``-n, --number=NUMBER`` |
| 43 |
Select multiple items at once. The default is 1. |
| 44 |
|
| 45 |
``-e, --equal-chance`` |
| 46 |
Give each distinct value of a field an equal chance of being selected. This |
| 47 |
prevents artists with many albums/tracks from dominating the selection. |
| 48 |
|
| 49 |
**Implementation note:** When this option is used, the plugin: |
| 50 |
|
| 51 |
1. Groups items by the specified field |
| 52 |
2. Shuffles items within each group |
| 53 |
3. Randomly selects groups, then items from those groups |
| 54 |
4. Continues until all groups are exhausted |
| 55 |
|
| 56 |
Items without the specified field (``--field``) value are excluded from the |
| 57 |
selection. |
| 58 |
|
| 59 |
``--field=FIELD`` |
| 60 |
Specify which field to use for equal chance sampling. Default is |
| 61 |
``albumartist``. |
| 62 |
|
| 63 |
``-t, --time=TIME`` |
| 64 |
Select items whose total duration (in minutes) is approximately equal to |
| 65 |
TIME. The plugin will continue adding items until the total exceeds the |
| 66 |
requested time. |
| 67 |
|
| 68 |
``-a, --album`` |
| 69 |
Operate on albums instead of tracks. |
| 70 |
|
| 71 |
``-p, --path`` |
| 72 |
Output filesystem paths instead of formatted metadata. |
| 73 |
|
| 74 |
``-f, --format=FORMAT`` |
| 75 |
Use a custom format string for output. See :doc:`/reference/query` for |
| 76 |
format syntax. |
| 77 |
|
| 78 |
Examples |
| 79 |
-------- |
| 80 |
|
| 81 |
Select multiple items: |
| 82 |
|
| 83 |
.. code-block:: shell |
| 84 |
|
| 85 |
# Select 5 random tracks |
| 86 |
beet random -n 5 |
| 87 |
|
| 88 |
# Select 3 random albums |
| 89 |
beet random -a -n 3 |
| 90 |
|
| 91 |
Control selection fairness: |
| 92 |
|
| 93 |
.. code-block:: shell |
| 94 |
|
| 95 |
# Ensure equal chance per artist (default field: albumartist) |
| 96 |
beet random -e |
| 97 |
|
| 98 |
# Ensure equal chance per genre |
| 99 |
beet random -e --field genre |
| 100 |
|
| 101 |
Select by total playtime: |
| 102 |
|
| 103 |
.. code-block:: shell |
| 104 |
|
| 105 |
# Select tracks totaling 60 minutes (1 hour) |
| 106 |
beet random -t 60 |
| 107 |
|
| 108 |
# Select albums totaling 120 minutes (2 hours) |
| 109 |
beet random -a -t 120 |
| 110 |
|
| 111 |
Custom output formats: |
| 112 |
|
| 113 |
.. code-block:: shell |
| 114 |
|
| 115 |
# Print only artist and title |
| 116 |
beet random -f '$artist - $title' |
| 117 |
|
| 118 |
# Print file paths |
| 119 |
beet random -p |
| 120 |
|
| 121 |
# Print album paths |
| 122 |
beet random -a -p |