Foobar2000:Components/foo enhanced playcount

From Hydrogenaudio Knowledgebase
Jump to: navigation, search
Enhanced Playback Statistics

foo_enhanced playcount
Developer(s) MordredKLB
Repository github
Release information
Initial release
Stable release 5.0.0 (March 23, 2023)
Preview release
foobar2000 compatibility
Architecture {{{foobar2000_architecture}}}
Minimum version 1.4
Maximum version
UI module(s) N/A
Additional information
Use
License
Discussion thread {{{discussion_thread}}}
View all components

foo_enhanced_playcount (Record time of every play, and retrieve Last.fm scrobbles)

This component collects and maintains enhanced statistics for played songs; primarily it records the timestamp of every play of a song, and not just the first and last. It will also query last.fm and record play times of every scrobble for a song.

It provides some additional functionality that foo_playcount does not, but is missing some functionality that foo_playcount has. They work well together, and foo_playcount should NOT be uninstalled when foo_enhanced_playcount is installed.

While you can retrieve playcounts and other information easily, to process some of the played times fields which return arrays you'll need to use one of the javascript panels such as Spider Monkey, JScript, or WSHPanel.

This component locally records the timestamp of every single play that foobar makes (compared to foo_playcount which only records the first and most recent plays). If a username is supplied, and last.fm support is enabled, it can also retrieve the timestamp of every scrobble of a song as well to ensure you have a combined record of all local and scrobbled plays.

While foo_enhanced_playcount can be used in any theme, to get maximum use out of it you'll need to use a panel that supports javascript, like foo_jscript_panel, or foo_wsh_panel.

Note: This component is not a replacement for foo_playcount. This component's functionality is improved by the presence of foo_playcount. Do not uninstall foo_playcount!

New fields provided

  • %played_times% - Date formatted list: ["2012-08-04 15:58:37", "2012-12-10 14:40:46", "2018-01-02 23:38:13"]
  • %played_times_js% - JS timestamp list: [1344117517000, 1355172047000, 1514957893431]
  • %played_times_raw% - raw foobar timestamps: [129885911170000000, 129996456470000000, 131594314930000000] - There's probably no reason to ever use this.
  • %lastfm_played_times% - Date formatted list of scrobbles: ["2012-08-04 15:58:37", "2012-12-10 14:40:46", "2018-01-02 23:38:13"]
  • %lastfm_played_times_js% - JS timestamp list: [1344117517000, 1355172047000, 1514957893000]
  • %lastfm_play_count% - Count of last.fm plays, a la %play_count%: 5
  • %lastfm_added% - Single date: "2012-08-04 15:58:37"
  • %lastfm_first_played% - Always exactly the same as %lastfm_added%. Use whichever one makes most sense logically
  • %lastfm_last_played% - Single date: "2018-04-04 15:58:37"
  • %added_enhanced% - Returns the earliest of %added% (from foo_playcount) or %lastfm_added%. Single date: "2023-02-04 15:16:17"
  • %first_played_enhanced% - Returns the earliest of %first_played% (from foo_playcount) or %lastfm_added%. Single date: "2023-02-04 15:16:17"
  • %last_played_enhanced% - Returns the earliest of %last_played% (from foo_playcount) or %lastfm_last_played%. Single date: "2023-02-04 15:16:17"

Code Samples

To consume the Array's of timestamps, you'll need to parse the response:

   var raw = fb.TitleFormat('[%played_times_js%]').Eval();
   var playedTimes = [];
   try {
   	playedTimes = JSON.parse(raw);	// this is required because the value is a string
   } catch (e) {
   	fb.trace('<<< ERROR parsing JSON >>>');  // you probably don't need this try/catch, but it was helpful in my debugging
   }
   for (i=0; i < playedTimes.length; i++) {
   	var p = new Date(playedTimes[i]);
   	// do something with this value
   }

More code samples in the official thread.

Links