MusicBrainz Picard/Documentation/Scripting: Difference between revisions
From MusicBrainz Wiki
Jump to navigationJump to search
((year) example (Imported from MoinMoin)) |
((Imported from MoinMoin)) |
||
Line 52: | Line 52: | ||
<ul><li style="list-style-type:none">Total tracks on the album |
<ul><li style="list-style-type:none">Total tracks on the album |
||
</ul> |
|||
⚫ | |||
<ul><li style="list-style-type:none">Disc number |
|||
</ul> |
|||
===%totaldiscs%=== |
|||
<ul><li style="list-style-type:none">Total number of discs |
|||
</ul> |
</ul> |
||
Line 78: | Line 88: | ||
===%composer%=== |
===%composer%=== |
||
<ul><li style="list-style-type:none">[[Composer Relationship Type|ComposerRelationshipType]] |
|||
</ul> |
|||
===%conductor%=== |
===%conductor%=== |
||
<ul><li style="list-style-type:none">[[Conductor Relationship Type|ConductorRelationshipType]] |
|||
</ul> |
|||
===%ensemble%=== |
===%ensemble%=== |
||
<ul><li style="list-style-type:none">[[Orchestra Relationship Type|OrchestraRelationshipType]] |
|||
</ul> |
|||
===%arranger%=== |
===%arranger%=== |
||
<ul><li style="list-style-type:none">[[Arranger Relationship Type|ArrangerRelationshipType]], [[Instrumentator Relationship Type|InstrumentatorRelationshipType]], [[Orchestrator Relationship Type|OrchestratorRelationshipType]] |
|||
</ul> |
|||
===%lyricist%=== |
===%lyricist%=== |
||
<ul><li style="list-style-type:none">[[Lyricist Relationship Type|LyricistRelationshipType]] |
|||
</ul> |
|||
===%remixer%=== |
===%remixer%=== |
||
<ul><li style="list-style-type:none">[[Remixer Relationship Type|RemixerRelationshipType]] |
|||
</ul> |
|||
===%producer%=== |
===%producer%=== |
||
<ul><li style="list-style-type:none">[[Producer Relationship Type|ProducerRelationshipType]] |
|||
⚫ | |||
</ul> |
|||
===% |
===%engineer%=== |
||
<ul><li style="list-style-type:none">[[Engineer Relationship Type|EngineerRelationshipType]] |
|||
</ul> |
|||
==Functions== |
==Functions== |
Revision as of 10:34, 18 December 2006
Scripting in Picard
This page describes a simple scripting language implemented in PicardQt.
Syntax
The syntax is derived from Foobar2000's titleformat. There are three base elements: text, variable and function. Variables consist of alpha-numeric characters enclosed in percent signs (e.g. %artist%
). Functions start with a dollar sign and end with an argument list enclosed in parentheses (e.g. $lower(...)
).
Variables
- {i} Not all of these variables are available for all files. Plugins or scripts can also create a new ones.
%title%
- Track title
%artist%
- Artist name
%artist_sortname%
- Artist sortname
%album%
- Album title
%albumartist%
- Album artist name
%albumartist_sortname%
- Album artist sortname
%tracknumber%
- Track number
%totaltracks%
- Total tracks on the album
%discnumber%
- Disc number
%totaldiscs%
- Total number of discs
%date%
- Release date
%musicbrainz_trackid%
%musicbrainz_albumid%
%musicbrainz_artistid%
%musicbrainz_albumartistid%
%compilation%
- 0 for single artist albums, 1 for multiple artist albums
%asin%
- Amazon ASIN
%composer%
%conductor%
%ensemble%
%arranger%
%lyricist%
%remixer%
%producer%
%engineer%
Functions
$if(if,then,else)
- If
if
is not empty, it returnsthen
, otherwise it returnselse
.
$if2(a1,a2,a3,...)
- Returns first non empty argument.
$lower(text)
- Returns
text
in lower case.
$upper(text)
- Returns
text
in upper case.
$left(text,num)
- Returns first
num
characters fromtext
.
$right(text,num)
- Returns last
num
characters fromtext
.
$num(num,len)
- ..
$replace(text,search,replace)
- ..
$rsearch(text,pattern)
- ..
$rreplace(text,pattern,replace)
- ..
$num(text,length)
$unset(context, name)
- Unsets the variable
name
.
$set(context, name, value)
- Sets the variable
name
to
value
.
$get(name)
- Returns the variable
name
(equivalent to
%name%
).
$trim(text[,char])
- Trims all leading and trailing whitespaces from
text
. The optional second parameter specifies the character to trim.
$add(x,y)
- Add
y
to
x
.
$sub(x,y)
- Substracts
y
from
x
.
$div(x,y)
- Divides
x
by
y
.
$mod(x,y)
- Returns the remainder of
x
divided by
y
.
$mul(x,y)
- Multiplies
x
by
y
.
$or(x,y)
- Returns true, if either
x
or
y
not empty.
$and(x,y)
- Returns true, if both
x
and
y
are not empty.
$not(x)
- Returns true, if
x
is empty.
$eq(x,y)
- Returns true, if
x
equals
y
.
$ne(x,y)
- Returns true, if
x
not equals
y
.
$lt(x,y)
- Returns true, if
x
is lower than
y
.
$lte(x,y)
- Returns true, if
x
is lower than or equals
y
.
$gt(x,y)
- Returns true, if
x
is greater than
y
.
$gte(x,y)
- Returns true, if
x
is greater than or equals
y
.
Examples
Use case 1: Disc numbers
$set(discnumber,$rsearch(%album%,\\\(disc \(\\d+\)\\\))) $set(album,$rreplace(%album%,\\s\\\(disc \\d+\\\),))
Use case 2: Artist names
$if($search(%album%,(feat. conductor)), $set(artist,%orchestra%))
- Stupid assumption that all classical albums have "feat. conductor" in the title, but it shows the idea. :)
Use case 3: Live tracks on live albums
$if($and($eq(%albumstatus%,live),$not($search(%title,(\(live\))))),$set(title,%title% (live)))
Lower case filenames with underscores
$lower($replace(%albumartist%/%album%/$num(%tracknumber%,2) %title, ,_))
(Year) only if available
$if(%date%,\($left(%date%,4)\))