Foobar2000:Components 0.9/Cwbowron's Title formating (foo cwb hooks)
From Hydrogenaudio Knowledgebase
| ||||||||||||||||||||
foo_cwb_hooks is an assortment of utilities that adds various functions and variables to global titleformatting; a "stamp current date and time" masstagger action; a new file tagger that runs a user selected script when files are added to the media library; and a uie tagger panel for tagging files.
As of Panels UI 0.13.7, foo_cwb_hooks functions and variables will now work with Panels UI generated panels, even with no track or with playback stopped.
Note: Development of foo_cwb_hooks has ceased as of May 2008.
Contents |
Functions
No different than core foobar2000 functions, foo_cwb_hook functions start with a dollar sign, followed by the function name and the parameter list.
Boolean functions
$cwb_fileexists(filename)
Returns true if the file filename exists, otherwise false.
Example: $cwb_fileexists($replace(%_path%,%_filename_ext%,)folder.jpg)
Date/time functions
$cwb_datediff(d1,d2)
Calculates the number of days between two dates d1 and d2 and returns the value. d1 and d2 must be in the format yyyy-mm-dd or yyyy-mm-dd hh:mm:ss
$cwb_hms(t)
Converts the number of seconds t into hh:mm:ss format, and returns the value.
$cwb_wdhms(t)
Converts the number of seconds t into weeks, days, hours, minutes, seconds, and returns the value.
Example: $cwb_wdhms(6000000) → 9wk 6d 10:40:00
Integer functions
$cwb_splitnum(n,s)
Digit groups integer n and returns the formatted result. An optional second parameter string s can be a delimiter. The default delimiter when no optional parameter is specified is whitespace.
Examples:
$cwb_splitnum(12345678) → 12 345 678
$cwb_splitnum(12345678,',') → 12,345,678
String functions
$cwb_ltrim(s1,s2,sN)
Removes leading strings s2 to sN from from string s1. All strings are evaluated case-insensitive.
Examples where %artist% will contain the value The Beach Boys:
$cwb_ltrim(%artist%,The ) → Beach Boys
$cwb_ltrim(%artist%,The ,A ,La ) → Beach Boys
$cwb_httpclean(s)
Decodes characters in URLs, where string s is the URL.
$cwb_removethe(s)
Returns string s with the prefix "The" or "A" removed from the beginning of the string.
$cwb_urldecode(s)
Decodes characters in URLs, where string s is the URL.
Variables
Also similar to core foobar2000 field references, a foo_cwb_hook variable is enclosed in percent signs.
Date/time
%cwb_systemdate%
Returns the date in the format yyyy-mm-dd
%cwb_systemdatetime%
Returns the date and time in the format yyyy-mm-dd hh:mm:ss
Playlist information
%cwb_activelist%
Returns the active playlist name
%cwb_activelist_count%
Returns the number of items in the active list
%cwb_activelist_duration%
Returns the duration of the playlist in seconds
%cwb_playinglist%
Returns the playing playlist name
%cwb_playinglist_count%
Returns the number of items in the playing list
%cwb_playinglist_duration%
Returns the duration of the playing playlist in seconds
%cwb_playing_index%
Returns a playlist index of the playing item. The first item is at index 1.
%cwb_selection_count%
Returns the number of selected tracks
%cwb_selection_duration%
Returns the duration of selected tracks in seconds
Queue information
%cwb_queueindex%
The queueindex if in the queue, false otherwise
%cwb_queueindexes%
Indices of the item in the queue, false otherwise
%cwb_queuelength%
Returns the length of the queue
%cwb_queue_end_playlist%
Returns the playlist name of the last item in the queue
Playback information
%cwb_playback_order%
Returns the playback order
%cwb_stopaftercurrent%
Returns true if Stop after current is enabled, otherwise false.
%cwb_followcursor%
Returns true if Cursor follows playback is enabled, otherwise false.
%cwb_volume%
Returns the value of the volume
%cwb_playback_state%
Returns a string value of the playback state, stop, play, or pause.
Other information
%cwb_next_title%
Returns the title of the next song in the playlist of the playing item or the next item in the queue
%cwb_next_artist%
Returns the artist of the next song in the playlist of the playing item or the next item in queue
%cwb_next_user1%
Returns a user definable tag for next track (default %album%)
%cwb_next_user2%
Returns a user definable tag for next track (default %path%)
Known Bugs
- Playlist order not available until a song is played
Feature Requests
See here.
Titleformatting examples
Depending on when the currently playing track was last played, %last_played%, the following titleformat script will output Played Today, Played Yesterday, Played n days ago, or No last played info
$if(%last_played%, $puts(diff,$cwb_datediff(%last_played%,%cwb_systemdate%)) Played $ifgreater(1,$get(diff),Today, $ifgreater(2,$get(diff),Yesterday, $get(diff) days ago)), No last played info)

