File: limit.rst

package info (click to toggle)
beets 2.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 7,988 kB
  • sloc: python: 46,429; javascript: 8,018; xml: 334; sh: 261; makefile: 125
file content (63 lines) | stat: -rw-r--r-- 1,689 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
Limit Query Plugin
==================

``limit`` is a plugin to limit a query to the first or last set of results. We
also provide a query prefix ``'<n'`` to inline the same behavior in the ``list``
command. They are analogous to piping results:

    $ beet [list|ls] [QUERY] | [head|tail] -n n

There are two provided interfaces:

1. ``beet lslimit [--head n | --tail n] [QUERY]`` returns the head or tail of a
query

2. ``beet [list|ls] [QUERY] '<n'`` returns the head of a query

There are two differences in behavior:

1. The query prefix does not support tail.

2. The query prefix could appear anywhere in the query but will only have the
same behavior as the ``lslimit`` command and piping to ``head`` when it appears
last.

Performance for the query previx is much worse due to the current
singleton-based implementation.

So why does the query prefix exist? Because it composes with any other
query-based API or plugin (see :doc:`/reference/query`). For example, you can
use the query prefix in ``smartplaylist`` (see :doc:`/plugins/smartplaylist`) to
limit the number of tracks in a smart playlist for applications like most played
and recently added.

Configuration
-------------

Enable the ``limit`` plugin in your configuration (see :ref:`using-plugins`).

Examples
--------

First 10 tracks

.. code-block:: sh

    $ beet ls | head -n 10
    $ beet lslimit --head 10
    $ beet ls '<10'

Last 10 tracks

.. code-block:: sh

    $ beet ls | tail -n 10
    $ beet lslimit --tail 10

100 mostly recently released tracks

.. code-block:: sh

    $ beet lslimit --head 100 year- month- day-
    $ beet ls year- month- day- '<100'
    $ beet lslimit --tail 100 year+ month+ day+