Foobar2000:Components/foo enhanced playcount

From Hydrogenaudio Knowledgebase
Revision as of 07:06, 12 April 2018 by MordredKLB (talk | contribs) (Initial add of wiki page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

This component records the timestamp of every single play that foobar makes. 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.

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.

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"

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

Official Discussion Thread Changelog