File: limit.rst

package info (click to toggle)
beets 2.2.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,536 kB
  • sloc: python: 45,608; javascript: 7,997; xml: 334; sh: 261; makefile: 119
file content (58 lines) | stat: -rw-r--r-- 1,640 bytes parent folder | download
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
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

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

Last 10 tracks

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

100 mostly recently released tracks

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