Console applications

Woob console applications have common options, in addition to per-application specific options.

Since they receive result objects, these options help to manipulate and format them.

Formatters

Each console application can format the results using the --formatter option (shortcut: -f).

Formatting results is useful for passing data to other applications by a pipe, or to export data to a file.

Multiline formatter

This is the default formatter.

It displays one field per line, adding an empty line between objects.

Example:

$ woob video search coluche [--formatter=multiline]
Search pattern: coluche
author: None
date: None
duration: 0:07:57
id: 6Cvj6NRpTXo@youtube
nsfw: False
page_url: http://www.youtube.com/watch?v=6Cvj6NRpTXo
rating: 0.0
rating_max: 0.0
thumbnail: http://i.ytimg.com/vi/6Cvj6NRpTXo/2.jpg
title: Coluche - Les Flics
url: None

author: None
date: None
duration: 0:02:37
id: vC5OV57AVgk@youtube
nsfw: False
page_url: http://www.youtube.com/watch?v=vC5OV57AVgk
rating: 0.0
rating_max: 0.0
thumbnail: http://i.ytimg.com/vi/vC5OV57AVgk/2.jpg
title: Coluche - Les Juifs, l'humour et l'humour juif
url: None

etc.

Simple formatter

It displays one object per line, following the key=value pattern. Fields are tab-separated.

Example:

$ woob video search coluche --formatter=simple
Search pattern: coluche
author=None date=None   duration=0:07:57    id=6Cvj6NRpTXo@youtube  nsfw=False  page_url=http://www.youtube.com/watch?v=6Cvj6NRpTXo rating=0.0  rating_max=0.0  thumbnail=http://i.ytimg.com/vi/6Cvj6NRpTXo/2.jpg   title=Coluche - Les Flics   url=None
author=None date=None   duration=0:02:37    id=vC5OV57AVgk@youtube  nsfw=False  page_url=http://www.youtube.com/watch?v=vC5OV57AVgk rating=0.0  rating_max=0.0  thumbnail=http://i.ytimg.com/vi/vC5OV57AVgk/2.jpg   title=Coluche - Les Juifs, l'humour et l'humour juif    url=None
author=None date=None   duration=0:02:03    id=-5MTj_YJLcc@youtube  nsfw=False  page_url=http://www.youtube.com/watch?v=-5MTj_YJLcc rating=0.0  rating_max=0.0  thumbnail=http://i.ytimg.com/vi/-5MTj_YJLcc/2.jpg   title=Coluche l'administration  url=None
author=None date=None   duration=0:03:41    id=LOZRgOx5sM4@youtube  nsfw=False  page_url=http://www.youtube.com/watch?v=LOZRgOx5sM4 rating=0.0  rating_max=0.0  thumbnail=http://i.ytimg.com/vi/LOZRgOx5sM4/2.jpg   title=Coluche - Le viol de Monique  url=None

etc.

Table formatter

ASCII-art table, using the PrettyTable Python package.

Example:

$ woob video search coluche --formatter=table
Search pattern: coluche
+--------+------+----------+---------------------+-------+--------------------------------------------+--------+------------+-----------------------------------------+------------------------------------------------+------+
| author | date | duration |          id         |  nsfw |                  page_url                  | rating | rating_max |                thumbnail                |                     title                      | url  |
+--------+------+----------+---------------------+-------+--------------------------------------------+--------+------------+-----------------------------------------+------------------------------------------------+------+
| None   | None | 0:07:57  | 6Cvj6NRpTXo@youtube | False | http://www.youtube.com/watch?v=6Cvj6NRpTXo | 0.0    | 0.0        | http://i.ytimg.com/vi/6Cvj6NRpTXo/2.jpg | Coluche - Les Flics                            | None |
| None   | None | 0:02:37  | vC5OV57AVgk@youtube | False | http://www.youtube.com/watch?v=vC5OV57AVgk | 0.0    | 0.0        | http://i.ytimg.com/vi/vC5OV57AVgk/2.jpg | Coluche - Les Juifs, l'humour et l'humour juif | None |
| None   | None | 0:02:03  | -5MTj_YJLcc@youtube | False | http://www.youtube.com/watch?v=-5MTj_YJLcc | 0.0    | 0.0        | http://i.ytimg.com/vi/-5MTj_YJLcc/2.jpg | Coluche l'administration                       | None |
| None   | None | 0:03:41  | LOZRgOx5sM4@youtube | False | http://www.youtube.com/watch?v=LOZRgOx5sM4 | 0.0    | 0.0        | http://i.ytimg.com/vi/LOZRgOx5sM4/2.jpg | Coluche - Le viol de Monique                   | None |
| None   | None | 0:03:58  | J-YPkBTuPUU@youtube | False | http://www.youtube.com/watch?v=J-YPkBTuPUU | 0.0    | 0.0        | http://i.ytimg.com/vi/J-YPkBTuPUU/2.jpg | Coluche- la politesse                          | None |
| None   | None | 0:05:30  | XUnaW9tNDwM@youtube | False | http://www.youtube.com/watch?v=XUnaW9tNDwM | 0.0    | 0.0        | http://i.ytimg.com/vi/XUnaW9tNDwM/2.jpg | Coluche - Moi ça va!                           | None |

etc.

HTML Table formatter

HTML formatted table.

Example:

$ woob video search coluche --formatter=htmltable

WebKit formatter

Displays the output of htmltable inside a Webkit GTK widget, using the PyWebkitGtk Python package.

Other formatter options

  • --no-header do not display header
  • --no-keys do not display item keys

These options are useful to pipe data.

Selections

User can select the output fields with the --select option.

By default, a field can be not loaded. Selecting it forces the backend to load it.

Example:

I want to display ID and URL of video objects related to "Coluche". By default video URLs are not filled by video backends, because they require to load the page of each video, but selecting it forces the load.

$ woob video search --select="id,url" coluche
Search pattern: coluche
id: 6Cvj6NRpTXo@youtube
url: http://www.youtube.com/get_video?video_id=6Cvj6NRpTXo&t=vjVQa1PpcFPEm0TE25UY_ttkXtpJATyHgvaZEUxsMtA%3D&fmt=18

id: vC5OV57AVgk@youtube
url: http://www.youtube.com/get_video?video_id=vC5OV57AVgk&t=vjVQa1PpcFPCpxwBvJQm_B9YDAf5R2_-JXWSKi8RTPg%3D&fmt=18

id: -5MTj_YJLcc@youtube
url: http://www.youtube.com/get_video?video_id=-5MTj_YJLcc&t=vjVQa1PpcFOw3naoU7ZlEUuP_UWukT1-srx9tp_qKeg%3D&fmt=18

id: LOZRgOx5sM4@youtube
url: http://www.youtube.com/get_video?video_id=LOZRgOx5sM4&t=vjVQa1PpcFNAoF5IMC2FYT0zkJvNAnst9ukUpH5JE1I%3D&fmt=18

etc...

The '$full' word can be used to load all the fields:

$ woob video search -f multiline --select='$full' coluche --count 1
rating: 0.0
author: Melaaz
url: http://www.youtube.com/get_video?video_id=6Cvj6NRpTXo&t=vjVQa1PpcFOuOMWeC6Ii_KTfDCBLzDKldpQlO_E4SvI%3D&fmt=18
title: Coluche - Les Flics
thumbnail: http://i.ytimg.com/vi/6Cvj6NRpTXo/2.jpg
duration: 0:07:57
nsfw: False
date: None
rating_max: 0.0
id: 6Cvj6NRpTXo@youtube
page_url: http://www.youtube.com/watch?v=6Cvj6NRpTXo

whereas:

$ woob video -f multiline search coluche --count 1
rating: Not loaded
author: Not loaded
url: Not loaded
title: Coluche - Les Flics
thumbnail: http://i.ytimg.com/vi/6Cvj6NRpTXo/2.jpg
duration: 0:07:57
nsfw: False
date: Not loaded
rating_max: Not loaded
id: 6Cvj6NRpTXo@youtube
page_url: http://www.youtube.com/watch?v=6Cvj6NRpTXo

Obviously, the first command is longer than the second one, since it requires more http requests to achieve.

Conditions

User can filter displayed objects with a condition expression.

Example: I display all my bank accounts:

$ woob bank list
balance: XXXX
coming: 0.0
id: XYZ@cragr_cbenz
label: CCHQ
link_id:

balance: XXXX
coming: 0.0
id: XYZ@cragr_cbenz
label: CEL
link_id:

balance: XXXX
coming: 0.0
id: XYZ@cragr_cbenz
label: CODEBIS
link_id:

Now, I only want the CCHQ account to be displayed:

$ woob bank list --condition label=CCHQ
balance: XXX
coming: 0.0
id: XYZ@cragr_cbenz
label: CCHQ
link_id:

Operators

The following operators are supported:

  • = Test if object.field is equal to the value;
  • != Test if object.field is not equal to the value;
  • > Test if object.field is greater than the value. If object.field is a date, return true if value is before that object.field;
  • < Test if object.field is less than the value. If object.field is a date, return true if value is after that object.field;
  • | This operator is available only for string fields. It works like the Unix standard grep command, and returns True if the pattern specified in the value is in object.field.

Combination of expressions

You can make a expression combinations with the keywords " AND " and " OR ".

Example:

$ woob bank history CC-XXX@ing --condition 'label|sncf AND amount>30'

Get transactions containing "sncf" with an amount greater than 30.

Count

User can set a maximum limit of results.

$ woob video search --count=20 coluche

Combining options examples

Say we want to download 20 videos of "Coluche" from Youtube:

$ woob video search --select=url --formatter=simple --no-header --no-keys --count=20 coluche > list
$ wget -i list

Say I want to get the balance of my CCHQ bank account, to feed a panel widget for example:

$ woob bank list -c label=CCHQ -s balance --no-keys
9999.99