HydrogenAudio

Hosted Forums => foobar2000 => 3rd Party Plugins - (fb2k) => Topic started by: marc2003 on 2009-12-07 13:47:18

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-07 13:47:18
this isn't a proper component but a script which utilises 2 other components (WSH panel mod & foo_customdb) to do the following:

-it can import the playcount/loved tracks from your entire last.fm library into foobar. it uses foo_customdb so your files are not touched.
-after doing the library import it will automatically update in the background as you listen.
-it can love/unlove tracks on last.fm via a button.
-it can automatically love tracks when they are played based on title formatting (for example, it can be set to automatically love tracks with a RATING of 5)
-you can display/filter the data in any custom columns, library viewers, display panels, etc using these simple tags:

Code: [Select]
%LASTFM_PLAYCOUNT_DB%
%LASTFM_LOVED_DB% //has a value of 1 for loved tracks


full instructions can be found here: https://dl.dropboxusercontent.com/u/2280132...ount%20sync.zip (https://dl.dropboxusercontent.com/u/22801321/wsh/playcount%20sync.zip)
changelog: https://dl.dropboxusercontent.com/u/2280132...e/changelog.txt (https://dl.dropboxusercontent.com/u/22801321/wsh/playcount%20sync%20readme/changelog.txt)

updated 30/04/13: no longer requires foo_softplaylists meaning artist field remapping is supported for loving tracks and background updates.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: bob12 on 2009-12-07 15:01:44
This is amazing.  Thank you.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: dreadroach on 2009-12-07 15:13:03
Works like a charm, thank you.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: dreadroach on 2009-12-07 16:07:49
I can't sync some tracks. Instead of number of plays and love status i get just "..." (Both should be displayed because i generated my loved track playlist with foo_softplaylist).

This problem occures really often (every 2nd track i guess), but my tags are fine so that's not the problem..

Am i doing something wrong?

And one more question: Is it posible to sync the whole playlist at the same time?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-07 16:32:00
my script parses 2 values found in the xml response from lastfm named "userplaycount" and "userloved". look for the bits in bold. my script just writes them to the tags. if they don't exist, it just skips it.

Code: [Select]
[16:20:51] <?xml version="1.0" encoding="utf-8"?>
<lfm status="ok">
<track>
    <id>1036798</id>
    <name>Get Me Off</name>
    <mbid></mbid>
    <url>http://www.last.fm/music/Basement+Jaxx/_/Get+Me+Off</url>
    <duration>288000</duration>
    <streamable fulltrack="0">0</streamable>   
        <listeners>41414</listeners>
    <playcount>150455</playcount>
      [b] <userplaycount>7</userplaycount>    <userloved>0</userloved>[/b]
        <artist>
        <name>Basement Jaxx</name>
        <mbid>28cbf94d-0700-4095-a188-37e373b069a7</mbid>
        <url>http://www.last.fm/music/Basement+Jaxx</url>
    </artist>
        <album position="8">
        <artist>Basement Jaxx</artist>
        <title>Rooty</title>
        <mbid>b821473e-4959-40e4-9b40-48b95ecaf36b</mbid>
        <url>http://www.last.fm/music/Basement+Jaxx/Rooty</url>       
        <image size="small">http://userserve-ak.last.fm/serve/64s/5454246.jpg</image>
        <image size="medium">http://userserve-ak.last.fm/serve/126/5454246.jpg</image>
        <image size="large">http://userserve-ak.last.fm/serve/174s/5454246.jpg</image>
        <image size="extralarge">http://userserve-ak.last.fm/serve/300x300/5454246.jpg</image>
    </album>
        <toptags>
        <tag>
  <name>dance</name>
  <url>http://www.last.fm/tag/dance</url>
</tag>
        <tag>
  <name>electronic</name>
  <url>http://www.last.fm/tag/electronic</url>
</tag>
        <tag>
  <name>house</name>
  <url>http://www.last.fm/tag/house</url>
</tag>
        <tag>
  <name>electronica</name>
  <url>http://www.last.fm/tag/electronica</url>
</tag>
        <tag>
  <name>techno</name>
  <url>http://www.last.fm/tag/techno</url>
</tag>
      </toptags>
    </track></lfm>

as i mentioned in the readme, you can check the values that are being written in the console.

maybe the problem is with the feed? you can get your script to output this full response. find this line of code...

Code: [Select]
fb.trace("Status: " + xmlhttp.statustext);

add this as the next line directly after it.

Code: [Select]
fb.trace(xmlhttp.responsetext);

i've been using it for several days now and had no probems at all.

and WSH panel mod can only act on one track at a time. anyway, that's a good limitation because last.fm have a TOS with regards to how often you can query their service. 5 times a second is quite generous but i fear you'd break that unless you had some sort of delaying mechanism.

the quickest way to update your files using this would be stop playback. highlight a track, right click button, "sync now". repeat until bored.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-08 09:54:03
new version uploaded. same link as first post.

changes:
-now automatically updates when the playback time hits 10 seconds instead of requiring 60 seconds of continuous playback.
-as WSH panel mod is unable to tag external cue sheets, i've put a message in the console to alert people of this.

it's just the text in code.txt that has been updated. take care not to overwrite your own settings when updating.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: dreadroach on 2009-12-08 10:47:20
Thanks for new version.  Anyway, i fixed my "error", everything works perfect now..it was so stupid that i don't even want to mention it 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-08 11:33:46
glad you sorted it.

also, i've just found out my latest update is bad practice in wsh panel mod. i've had no problems at all, but the author says it may cause it to crash. however, a new version of WSH panel mod has been uploaded which can work around it. just to be clear, it wasn't a problem in WSH panel mod. the new version is to protect idiots like me who didn't read the documentation correctly.

latest version: http://code.google.com/p/foo-wsh-panel-mod/downloads/list (http://code.google.com/p/foo-wsh-panel-mod/downloads/list)

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: carmenm on 2009-12-08 13:43:28
Now i found a pretty big bug, you MUST prevent your script from doing anything when it is a streamed track like lastfm radio for example. Here the consequence is that when you try to write a tag to a currently playing streamed track, the song gets skipped.
Consequently i only have 10 sec of each song when using you script :s
and i am not sure how to correct it :s
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-08 14:00:04
ah yes my mistake. as i don't use streams very often i just put in a check to skip files with an unknown length. this works for live streams but not for last.fm radio. i'll update ASAP.

edit: hopefully fixed. try re-downloading again from the link in the first post.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: carmenm on 2009-12-08 14:27:47
Still happens. I dont see the difference in the script, could you just post the change in the script here?

By The way in you screenshot i see tracks with a "love" number above 1, how do you do that?
Here clicking several times doesnt do the trick
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-08 14:38:41
maybe your browser was caching the file?? i did actually test this on the last.fm radio component before uploading.

anyway, i've made a couple more changes so try downloading the file again.

as for my screenshots, the loved status is a heart displayed if the value is 1. i did put the titleformatting in the readme. and the number is my playcount.

edit: changes were in this function. just replace yours with this.

Code: [Select]
function on_metadb_changed() {
if(!g_metadb) return;
length = fb.TitleFormat("%length_seconds%").EvalWithMetadb(g_metadb);
ok = false;
switch(true) {
case (username.length == 0):
case (api_key.length != 32):
n = image_path + "exclamation.png";
h = image_path + "exclamation_h.png";
tooltip = "Click to set your Last.fm username / api key.";
func = function() {window.ShowConfigure();}
break;
case (length == "?"):
case (length < 30):
case (length > 10800):
case (g_metadb.RawPath.indexOf("FOO_LASTFM_RADIO") == 0):
case (g_metadb.RawPath.indexOf("mms://") == 0):
case (g_metadb.RawPath.indexOf("http://") == 0):
n = image_path + "exclamation.png";
h = n;
tooltip = "Unsupported track length or stream.";
func = null;
break;
default:
ok = true;
n = image_path + "love.png";
h = image_path + "love_h.png";
tooltip = fb.TitleFormat("Last.fm Love ''%title%'' by ''%artist%''").EvalWithMetadb(g_metadb);
func = function() {love_track(tooltip);}
}
Buttons = {
but: new Button(0,0,bw,bh, {normal: n, hover: h}, func, tooltip)
};
window.Repaint();
}
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: T.P Wang on 2009-12-08 14:55:25
@marc2003:
I think it's better to use something like this:
Code: [Select]
...
// or %_path_raw%
case (g_metadb.RawPath.indexOf("mms://") == 0):
...

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-08 15:07:42
thanks. post above edited to reflect changes.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: carmenm on 2009-12-08 15:32:49
Thanks a lot, works perfectly now!

Just thought of a great addition. Right now your panel doesnt do a thing with radio tracks which is a shame. What it should do:
- still allow to love a track! (easily implemented, i did it here)
- write the tag as a temp tag just like biography_view(that i dont know how to do)

what do you think?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-08 19:24:53
i need to play around a bit and see what is possible. i want this to support whatever the website does. if that means loving streams then i'll add it back in.

as for your 2nd point, i highly doubt that is possible. remember, this is just script running on top of WSH panel mod. plus my skills are weak. 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-08 21:48:12
i did some experimenting and it seems there is only one rule for "loving" tracks: there are no rules. even tracks you can't scrobble can be loved. go figure. so i've uploaded a new version.

Quote
changes:

o   Removed “sync now” context menu item. Not needed now that auto updates run after just 10 seconds.
o   Fixed issues with the “loving” of streamed content.  All artificial restrictions have been removed. You can attempt to "love" anything. The response will depend entirely on last.fm.
o   Enforced stricter checks on files that can be tagged.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Fractal_Mortality on 2009-12-08 23:19:19
edit: nevermind, the default works 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Fractal_Mortality on 2009-12-08 23:46:48
New question: How can we forced the script to look up times played counts for items in the default ui? I don't see a context menu anywhere, and I'm assuming it's because the component isn't compatible with the default ui...?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-08 23:53:49
see my changelog 2 posts above. the context menu item to force a sync has been removed. the only reason it was there originally is because it was compulsory to listen to a track for a whole minute before it automatically updated. now it's just 10 seconds, i see no need for it. (maybe i should make the readme a bit more clear. it's not actually 10 seconds playback - it's when the elapsed time hits 10 seconds)

look at your console and see if it's automatically running. it should always give a message whether it tags your files or not.

edit: just re-tested my latest version in dockable panels and it's working exactly as expected.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Fractal_Mortality on 2009-12-09 00:20:12
I see. So is there a way to update an entire library with last.fm playcount data then? Obviously this would be more quickly/efficiently done in one foul swoop than individually playing through each track.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-09 00:45:39
not possible. i already explained this earlier in the thread.

Quote
and WSH panel mod can only act on one track at a time.


i think i'll edit the readme to explain the limitations a little more clearly.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Fractal_Mortality on 2009-12-09 01:04:05
Hm, that's ashame... Although it seems like using this method in as a tagging script seems fairly feasible. If I had the time/more developing expertise, I might take my hand at trying to make a component or script that could do it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-09 01:24:11
there is also the last.fm TOS to consider. i've just added this information to the readme as well.

Quote
You will not make more than 5 requests per originating IP address per second, averaged over a 5 minute period, without prior written consent.


it hasn't really needed to be mentioned before because there's absolutely no chance of breaking it with this script.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Fractal_Mortality on 2009-12-09 03:28:00
there is also the last.fm TOS to consider. i've just added this information to the readme as well.

Quote
You will not make more than 5 requests per originating IP address per second, averaged over a 5 minute period, without prior written consent.


it hasn't really needed to be mentioned before because there's absolutely no chance of breaking it with this script.


Hm I see... Well an automated script could still be used, correct? It would just take awhile (and 5 requests per second isn't too bad).
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: carmenm on 2009-12-09 08:48:58
Last version works very well.
I have 2 question:
- can we create temporally tag with WSH Jscript? WOuld love to see if i loved a track when playing lastfm
- why wait 10sec before sync? why not half a second or even 1s?

Thanks
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-09 10:31:57
as for the 10 second rule, you're more than welcome to modify your own script. mine is staying as it is.

Code: [Select]
function on_playback_time(time) {
    if(t.eval() == 10) sync();
}


i suppose to show if a track is loved without writing tags, you could modify the button so it's "grey" when a track is unloved. then update it so it's red when a track is loved.

also new version of WSH panel mod is out. i strongly suggest everyone upgrades.

http://code.google.com/p/foo-wsh-panel-mod/downloads/list (http://code.google.com/p/foo-wsh-panel-mod/downloads/list)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: carmenm on 2009-12-09 10:39:15
I am ok with you 10sec, i am just trying to understand it

For the greyed thing you are right that might the solution. i ll try that thanks.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-09 14:12:39
one of the reasons i set 10 seconds is because i quite often start tracks then immediately change my mind and switch to something else. no need to spam the last.fm services for no reason. also, there are several last.fm components one might have installed at the same time. remember, they're probably all requesting data on playback start too. i'd just thought i'd leave a little breathing space.

as for the "grey" button idea, i might have a go at implementing this myself. then i'll disable the button if a track is already loved. after all, there is nothing else that can be done. you have to use the website to unlove a track.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: carmenm on 2009-12-09 14:21:14
one of the reasons i set 10 seconds is because i quite often start tracks then immediately change my mind and switch to something else. no need to spam the last.fm services for no reason. also, there are several last.fm components one might have installed at the same time. remember, they're probably all requesting data on playback start too. i'd just thought i'd leave a little breathing space.

as for the "grey" button idea, i might have a go at implementing this myself. then i'll disable the button if a track is already loved. after all, there is nothing else that can be done. you have to use the website to unlove a track.

You are right about other lastfm components, that s one of the reason why i really think it would be great to merge all lastfm components.
Now for th grey button i implemented it. Works like a charm.
Code: [Select]
// ==PREPROCESSOR==

// @import "%fb2k_path%scriptstooltip_buttons.js"

// ==/PREPROCESSOR==



var username = "";

var api_key = "";



var sync_playcount = 1;

var playcount_tag_name = "LASTFM_PLAYCOUNT";

var sync_loved = 1;

var loved_tag_name = "LASTFM_LOVED";



var bw = 24;

var bh = 20;

var image_path = fb.FoobarPath + "images";



window.MinWidth = bw;

window.MinHeight = bh;



var g_metadb = fb.GetFocusItem();

var WshShell = new ActiveXObject("WScript.Shell");

var ok,length,n,h,func,tooltip;

var t = fb.TitleFormat("%playback_time_seconds%");

var lastfm_loved = 0;



on_metadb_changed();



function on_item_focus_change() {



if (g_metadb) window.UnwatchMetadb();

g_metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();

if (g_metadb) {

on_metadb_changed();

window.WatchMetadb(g_metadb);

}

}



function on_metadb_changed() {

if(!g_metadb) return;

length = fb.TitleFormat("%length_seconds%").EvalWithMetadb(g_metadb);

ok = false;

switch(true) {

case (username.length == 0):

case (api_key.length != 32):

n = image_path + "exclamation.png";

h = image_path + "exclamation_h.png";

tooltip = "Click to set your Last.fm username / api key.";

func = function() {window.ShowConfigure();}

break;

case (g_metadb.RawPath.indexOf("file://") == 0 && length > 30 && length < 10800 && g_metadb.Path.substring(g_metadb.Path.length - 3) != "cue"):

ok = true;

default:

  if (lastfm_loved  == 1)  {

  n = image_path + "love.png";

h = image_path + "love_h.png";

  }

  else {

  n = image_path + "unlove.png";

h = image_path + "unlove_h.png";

}



tooltip = fb.TitleFormat("Last.fm Love ''%title%'' by ''%artist%''").EvalWithMetadb(g_metadb);

func = function() {love_track(tooltip);}

}

Buttons = {

but: new Button(0,0,bw,bh, {normal: n, hover: h}, func, tooltip)

};

window.Repaint();

}



function on_playback_new_track() {

lastfm_loved = 0;

on_item_focus_change();

}



function on_playback_time(time) {

if(t.eval() == 1) sync();

}



function love_track(command) {

fb.RunContextCommandWithMetadb("Legacy commands (unsorted)/" + command,g_metadb);

sync();

}



function sync() {

if(sync_playcount == 0 && sync_loved == 0) return;

if(!ok){

fb.trace("Playcount sync: Cannot write tags to this file. Possible reasons- too long; too short; it's a stream; it references an external cue sheet.");

return;

}

var artist = fb.TitleFormat("%artist%").EvalWithMetadb(g_metadb);

var track = fb.TitleFormat("%title%").EvalWithMetadb(g_metadb);

var url = "http://ws.audioscrobbler.com/2.0/?method=track.getinfo&api_key=" + api_key + "&username=" + username + "&artist=" + encodeURIComponent(artist) + "&track=" + encodeURIComponent(track);

fb.trace("Playcount sync: Contacting Last.fm....");

xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

xmlhttp.open("GET", url + "&s=" + Math.random(), true);

xmlhttp.setRequestHeader('User-Agent','foo_lastfm_playcount_sync');

xmlhttp.send();

xmlhttp.onreadystatechange = function() {

if (xmlhttp.readyState == 4) {

fb.trace("Status: " + xmlhttp.statustext);

if (xmlhttp.status == 200) {

//fb.trace(xmlhttp.responsetext);

var xmlDoc = xmlhttp.responseXML;

var y = xmlDoc.getElementsByTagName("userplaycount");

if(y.length == 1 && sync_playcount == 1) {

var lastfm_playcount = xmlDoc.getElementsByTagName("userplaycount")[0].childNodes[0].nodeValue;

var old_lastfm_playcount = fb.TitleFormat("%" + playcount_tag_name + "%").EvalWithMetadb(g_metadb);

if(lastfm_playcount != old_lastfm_playcount) {

fb.trace("Updating " + playcount_tag_name + " " + old_lastfm_playcount + " -> " + lastfm_playcount);

g_metadb.UpdateFileInfoSimple(playcount_tag_name, lastfm_playcount);

} else {

fb.trace(playcount_tag_name + " not updated. No changes found.");

}

}

var z = xmlDoc.getElementsByTagName("userloved");

if(z.length == 1 && sync_loved == 1) {

lastfm_loved = xmlDoc.getElementsByTagName("userloved")[0].childNodes[0].nodeValue;

if (lastfm_loved == 1) {

n = image_path + "love.png";

h = image_path + "love_h.png";

tooltip = fb.TitleFormat("Last.fm Love ''%title%'' by ''%artist%''").EvalWithMetadb(g_metadb);

func = function() {love_track(tooltip);}

Buttons = {

but: new Button(0,0,bw,bh, {normal: n, hover: h}, func, tooltip)

};

window.Repaint();

}

var old_lastfm_loved = fb.TitleFormat("%" + loved_tag_name + "%").EvalWithMetadb(g_metadb);

if((lastfm_loved == 1 && old_lastfm_loved == "?") || (lastfm_loved == 0 && old_lastfm_loved ==1)) {

fb.trace("Updating " + loved_tag_name + " " + old_lastfm_loved + " -> " + lastfm_loved);

g_metadb.UpdateFileInfoSimple(loved_tag_name, (lastfm_loved == 1) ? 1 : '');

} else {

fb.trace(loved_tag_name + " not updated. No changes found.");

}

}

} else {

fb.trace(xmlhttp.responsetext);

}

}

}

on_metadb_changed();

}



function on_mouse_rbtn_up(x, y) {

if(!g_metadb) return;

var MF_SEPARATOR = 0x00000800;

var MF_STRING = 0x00000000;

var MF_GRAYED = 0x00000001;



var _menu = window.CreatePopupMenu();

var idx;



_menu.AppendMenuItem(username.length > 0 ? MF_STRING : MF_GRAYED, 1, "Visit your Last.fm user profile page");

_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);

_menu.AppendMenuItem(MF_STRING, 2, "Configure...");



idx = _menu.TrackPopupMenu(x, y);



if (idx == 0) return;



switch(idx) {

case 1:

WshShell.run("http://www.last.fm/user/" + encodeURIComponent(username));

break;



case 2:

window.ShowConfigure();

}

return true;

}
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: T.P Wang on 2009-12-09 14:21:32
Just curious: Why not use on_item_played() callback ?

@carmenm:
Please remove your private data, and use:
Code: [Select]
[codebox][/codebox]
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-09 14:39:08
on_item_played doesn't work for tracks less than 60 seconds in length. instead it fires when the next track begins playback (and then again when that reaches 60 seconds as well. ). i've mentioned that twice in your thread now but no response so that's why i put in this workaround.

last.fm has a minimum length requirement of 30 seconds for scrobbling so it should be possible to update these these files.

@carmenm, i fail to see how that script works on streams. it's not possible. you haven't made the required changes.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-09 16:15:24
i'm too late to edit my last post, so carmenm, do you want to try this test version?

http://cid-649d3bfeaf541fbb.skydrive.live..../guide/test.zip (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/test.zip)

new features-

-shows "loved" status of local files immediately by reading tags.
-disables love track feature when a track is already loved
-now checks lasfm for the loved status of streams and the changes the icon if it is
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: carmenm on 2009-12-09 16:29:36
i'm too late to edit my last post, so carmenm, do you want to try this test version?

http://cid-649d3bfeaf541fbb.skydrive.live..../guide/test.zip (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/test.zip)

new features-

-shows "loved" status of local files immediately by reading tags.
-disables love track feature when a track is already loved
-now checks lasfm for the loved status of streams and the changes the icon if it is
ok so your version works fine but personally i made a version with some code cleanup so that for example the code to update the button is only at one place
here it is if you want it. I am not sure why but still sometimes the button comes back toi grey. It seems that lastfm_loved goes back to 0. Not sure why yet
Code: [Select]
// ==PREPROCESSOR==
// @import "%fb2k_path%scripts\tooltip_buttons.js"
// ==/PREPROCESSOR==

var username = "";
var api_key = "";

var sync_playcount = 1;
var playcount_tag_name = "LASTFM_PLAYCOUNT";
var sync_loved = 1;
var loved_tag_name = "LASTFM_LOVED";

var bw = 24;
var bh = 20;
var image_path = fb.FoobarPath + "images\\";

window.MinWidth = bw;
window.MinHeight = bh;

var g_metadb = fb.GetFocusItem();
var WshShell = new ActiveXObject("WScript.Shell");
var ok,length,n,h,func,tooltip;
var t = fb.TitleFormat("%playback_time_seconds%");
var lastfm_loved = 0;
var cansync = 0;

on_metadb_changed();

function on_item_focus_change() {

if (g_metadb) window.UnwatchMetadb();
g_metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
if (g_metadb) {
on_metadb_changed();
window.WatchMetadb(g_metadb);
}
}

function update_love_button(error) {
if (error == true) {
n = image_path + "exclamation.png";
h = image_path + "exclamation_h.png";
tooltip = "Click to set your Last.fm username / api key.";
func = function() {window.ShowConfigure();}
}
else
{
if (lastfm_loved  == 1)  {
n = image_path + "love.png";
h = image_path + "love_h.png";
tooltip = fb.TitleFormat("Last.fm  ''%title%'' by ''%artist%'' already loved!").EvalWithMetadb(g_metadb);
func = null;
}
else {
n = image_path + "unlove.png";
h = image_path + "unlove_h.png";
tooltip = fb.TitleFormat("Last.fm Love ''%title%'' by ''%artist%''").EvalWithMetadb(g_metadb);
func = function() {love_track(tooltip);}
}
}
}

function on_metadb_changed() {
if(!g_metadb) return;
length = fb.TitleFormat("%length_seconds%").EvalWithMetadb(g_metadb);
switch(true) {
case (username.length == 0):
case (api_key.length != 32):
udate_love_button(true);
break;
case (g_metadb.RawPath.indexOf("file://") == 0 && length > 30 && length < 10800 && g_metadb.Path.substring(g_metadb.Path.length - 3) != "cue"):
ok = true;
default:
update_love_button(false);
break;
}
Buttons = {
but: new Button(0,0,bw,bh, {normal: n, hover: h}, func, tooltip)
};
window.Repaint();
}

function on_playback_new_track() {
lastfm_loved = 0;
ok = false;
on_item_focus_change();
}

function on_playback_time(time) {
if(t.eval() == 10) sync();
}

function love_track(command) {
fb.RunContextCommandWithMetadb("Legacy commands (unsorted)/" + command,g_metadb);
sync();
}

function sync() {
if(sync_playcount == 0 && sync_loved == 0) return;
var artist = fb.TitleFormat("%artist%").EvalWithMetadb(g_metadb);
var track = fb.TitleFormat("%title%").EvalWithMetadb(g_metadb);
var url = "http://ws.audioscrobbler.com/2.0/?method=track.getinfo&api_key=" + api_key + "&username=" + username + "&artist=" + encodeURIComponent(artist) + "&track=" + encodeURIComponent(track);
fb.trace("Playcount sync: Contacting Last.fm....");
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("GET", url + "&s=" + Math.random(), true);
xmlhttp.setRequestHeader('User-Agent','foo_lastfm_playcount_sync');
xmlhttp.send();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
fb.trace("Status: " + xmlhttp.statustext);
if (xmlhttp.status == 200) {
//fb.trace(xmlhttp.responsetext);
var xmlDoc = xmlhttp.responseXML;
var y = xmlDoc.getElementsByTagName("userplaycount");
if(ok == true && y.length == 1 && sync_playcount == 1) {
var lastfm_playcount = xmlDoc.getElementsByTagName("userplaycount")[0].childNodes[0].nodeValue;
var old_lastfm_playcount = fb.TitleFormat("%" + playcount_tag_name + "%").EvalWithMetadb(g_metadb);
if(lastfm_playcount != old_lastfm_playcount) {
fb.trace("Updating " + playcount_tag_name + " " + old_lastfm_playcount + " -> " + lastfm_playcount);
g_metadb.UpdateFileInfoSimple(playcount_tag_name, lastfm_playcount);
} else {
fb.trace(playcount_tag_name + " not updated. No changes found.");
}
}
var z = xmlDoc.getElementsByTagName("userloved");
if(z.length == 1 && sync_loved == 1) {
lastfm_loved = xmlDoc.getElementsByTagName("userloved")[0].childNodes[0].nodeValue;
var old_lastfm_loved = fb.TitleFormat("%" + loved_tag_name + "%").EvalWithMetadb(g_metadb);
if(ok ==true && ((lastfm_loved == 1 && old_lastfm_loved == "?") || (lastfm_loved == 0 && old_lastfm_loved ==1))) {
fb.trace("Updating " + loved_tag_name + " " + old_lastfm_loved + " -> " + lastfm_loved);
g_metadb.UpdateFileInfoSimple(loved_tag_name, (lastfm_loved == 1) ? 1 : '');
}
}
} else {
fb.trace(xmlhttp.responsetext);
}
}
}
on_metadb_changed();
}

function on_mouse_rbtn_up(x, y) {
if(!g_metadb) return;
var MF_SEPARATOR = 0x00000800;
var MF_STRING = 0x00000000;
var MF_GRAYED = 0x00000001;

var _menu = window.CreatePopupMenu();
var idx;

_menu.AppendMenuItem(username.length > 0 ? MF_STRING : MF_GRAYED, 1, "Visit your Last.fm user profile page");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING, 2, "Configure...");

idx = _menu.TrackPopupMenu(x, y);

if (idx == 0) return;

switch(idx) {
case 1:
WshShell.run("http://www.last.fm/user/" + encodeURIComponent(username));
break;

case 2:
window.ShowConfigure();
}
return true;
}

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-09 16:39:00
oh i know mine is an absolute mess with zillions of "IF" statements in it. that's why i put it up as a test version. i just wanted to make sure it worked first. i'll tidy it up later.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: carmenm on 2009-12-09 17:13:31
Ok fine with me
by the way one question about global variables, what happens if the script is reloaded? I think that s my problem.
If i set a global var to 1, will it still be 1 after the script reloads?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-09 18:05:25
using the editor dialog will reset any variable that are set during runtime (like loved status for a stream). under normal usage, this won't be an issue.

also, you're using on_metab_changed incorrectly. it gets called automatically when files are modified - so you're calling it twice with your sync function. and then for streams, it shouldn't be called at all because nothing has changed. you should just be updating the button.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-09 18:46:11
yet another new version uploaded. added features from earlier tests.

Quote
09/12/2009
-   Button now shows the “loved” status of tracks and streams.
-   If a track is “loved”, the button is disabled.


link (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/playcount%20sync.zip)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: TsukasaX on 2009-12-09 22:00:16
Any good way to put the information collected into a database instead of writing tags? I'm playing music from my NAS and tag writing is usually slow (interrupts playback) and takes two updates to actually update.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-09 22:25:18
i did experiment with a component called foo_customdb. this uses an sqlite database and i did manage to use WSH panel mod to update it via a command line tool. unfortunately, the command window flicker drove me round the bend. i couldn't live with it so i gave up.

another user (http://www.hydrogenaudio.org/forums/index.php?showuser=75626) has been trying to tackle this by editing the database directly from javascript and an sqlite dll but he's getting random database locked errors. also the files he's using isn't compatible with windows 7 64bit so i couldn't try it. you might want to skim through the last page of this thread.

http://www.hydrogenaudio.org/forums/index....0363&st=425 (http://www.hydrogenaudio.org/forums/index.php?showtopic=70363&st=425)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-10 10:20:10
right, here's my latest experiment -  a new version which DOES NOT write file tags. instead it uses text files to store the data. however, this does require the usage of ELplaylist to display it. i've included a sample .elp file that can be imported. but if you already use ELPlaylist, i've included instructions on how to use it in your own config.

screenshot:


it can now store playcount/loved status for absolutely anything -streams/cue files included.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: TsukasaX on 2009-12-10 15:49:47
Unfortunately I use NG Playlist instead of  ELplaylist; I'll have to see if it takes much to switch.

Judging by your post on the sqlite, that sounds a little excessive for this project unfortunately.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-10 17:26:10
new experimental ELplaylist version uploaded. this only writes one file per track instead of 2. in the unlikely event anyone tried my earlier version, it's now to safe to delete all the .txt files in your "lastfm_stats" folder. (should free up some valuable space.  )

click me (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/ELP%20playcount%20sync.zip)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Fractal_Mortality on 2009-12-10 20:11:19
marc, How would I edit your script in order for it to check/update the track... let's say.... 10 seconds before the song is ended (in addition to 10 seconds after it starts)? In a lot of cases, I'll love a track during playback, not beforehand... Also, this way it would typically update tracks according to that you've actually just played through them?

Is it even possible to have two points of checking in a given song?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-10 20:26:37
Code: [Select]
In a lot of cases, I'll love a track during playback, not beforehand...


well of course. from the readme.... 

Quote
Usage scenarios:

-   A track starts playing and you do nothing. It will automatically contact last.fm to fetch your playback statistics/loved track status when the playback time hits 10 seconds. Depending on the result and file type, your file will then be tagged with the response.

-   You click the “love” button. This will run foo_softplaylists and then automatically contact last.fm as above. This should now show the loved status immediately in your file. If the “love” action fails at the server end, your file will not be tagged by this script. Tags are only updated based on data retrieved from last.fm.


there's no point in checking near the end because a scrobble isn't counted until playback stops.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Fractal_Mortality on 2009-12-10 23:17:25
Code: [Select]
In a lot of cases, I'll love a track during playback, not beforehand...


well of course. from the readme.... 

Quote
Usage scenarios:

-   A track starts playing and you do nothing. It will automatically contact last.fm to fetch your playback statistics/loved track status when the playback time hits 10 seconds. Depending on the result and file type, your file will then be tagged with the response.

-   You click the “love” button. This will run foo_softplaylists and then automatically contact last.fm as above. This should now show the loved status immediately in your file. If the “love” action fails at the server end, your file will not be tagged by this script. Tags are only updated based on data retrieved from last.fm.


there's no point in checking near the end because a scrobble isn't counted until playback stops.


Ah... Right on on boths points.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-11 00:32:56
new experimental ELplaylist version uploaded. this only writes one file per track instead of 2.


anybody who tried this should revert to v1. download (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/ELP%20playcount%20sync.zip) (existing stats will stay and work fine)

it's fine now but slows down with the more records you have. i tested 10,000 dummy files and found there was a second or so delay. and i even tried 100,000. and that resulted in a 2-3 second delay when switching tracks. totally unacceptable.

v1 is fine however.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: carmenm on 2009-12-11 09:58:10
Hi marc, i have a question, could you share your CUI config?, i love your toolbar at the top and the bottom and would love to do something like that.

Thanks
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-11 15:32:56
here you go. just import.fcl and play around. i can't be bothered to write any instructions.

http://cid-649d3bfeaf541fbb.skydrive.live....ide/Archive.zip (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/Archive.zip)

experimental ELplaylist version removed as i'm working on a new version which isn't backwards compatible with it.

new main version uploaded (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/playcount%20sync.zip)

Quote
Added auto-love feature. Turned off by default but you can enable it to automatically love tracks as they are played based on your own custom title formatting. eg $ifequal(%rating%,5,1,0)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: carmenm on 2009-12-11 15:43:18
here you go. just import.fcl and play around. i can't be bothered to write any instructions.

http://cid-649d3bfeaf541fbb.skydrive.live....ide/Archive.zip (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/Archive.zip)

experimental ELplaylist version removed as i'm working on a new version which isn't backwards compatible with it.

new main version uploaded (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/playcount%20sync.zip)

Quote
Added auto-love feature. Turned off by default but you can enable it to automatically love tracks as they are played based on your own custom title formatting. eg $ifequal(%rating%,5,1,0)



The only thing that comes to my mind "WOW"!

Thanks
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: carmenm on 2009-12-11 17:22:27
I tested your last script, i like a lot. 2 things though:
- you dont update the button when syncing a track where you can write the tag. You only do it in the else.
- i dont really like the auto_love, i really choose carefully which song i love! But on the contrary if i love a song i want to put it 5 stars. I added for personal use. May be some others would be interested ...

Great job!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-11 17:29:14
- you dont update the button when syncing a track where you can write the tag. You only do it in the else.


doh! thanks for spotting.

edit: fixed version uploaded.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-12 06:39:05
a new version has been uploaded which supports foo_customdb. this requires foobar v1 because i've had to include my heavily customised .cfg file for foo_customdb.

new link...

http://cid-649d3bfeaf541fbb.skydrive.live....ount%20sync.zip (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/new%20playcount%20sync.zip)

(this version supports either file tagging or foo_customdb. the option can be changed in the script)

there is one "issue" which i've gone into a little detail about on page2 of the readme. it doesn't affect me. that's not to say it won't be an issue for others.

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: loft on 2009-12-12 22:26:25
How about making this script a true component or integrate it in the scrobbler? Is there someone with the skills and will to do this? These functionalities depend too much on too many components and scripts. It would be a lot more elegant.
Please, please, pretty please!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Hitchhiker427 on 2009-12-12 23:31:28
I really hope the developer considers making this a standalone plugin.  I'd love this functionality, but I use the DUI.  Although the dockable panels workaround is technically possible, it is very far from ideal.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: jimbothigpen on 2009-12-14 16:11:57
I tested your last script, i like a lot. 2 things though:
- you dont update the button when syncing a track where you can write the tag. You only do it in the else.
- i dont really like the auto_love, i really choose carefully which song i love! But on the contrary if i love a song i want to put it 5 stars. I added for personal use. May be some others would be interested ...

Great job!



@carmenm -- I'd like to see what you've done to sync from loved to 5-stars.  I'd like mine to sync both directions, i.e. 5-stars -> love and love -> 5-stars.

Thanks!
jimbothigpen
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: carmenm on 2009-12-14 16:53:12
I tested your last script, i like a lot. 2 things though:
- you dont update the button when syncing a track where you can write the tag. You only do it in the else.
- i dont really like the auto_love, i really choose carefully which song i love! But on the contrary if i love a song i want to put it 5 stars. I added for personal use. May be some others would be interested ...

Great job!



@carmenm -- I'd like to see what you've done to sync from loved to 5-stars.  I'd like mine to sync both directions, i.e. 5-stars -> love and love -> 5-stars.

Thanks!
jimbothigpen

in the code look for
Code: [Select]
} else if (ok) {
                        fb.trace(loved_tag_name + " not updated. No changes found.");
                    }

then add that below
Code: [Select]
if (auto_rating == 1 && lastfm_loved == 1 && ok)  {
                                g_metadb.UpdateFileInfoSimple("RATING","5");
                    }


Then dont forget to add the global variable
var auto_rating = 1;
at the top of your script.

It should be fine
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-14 17:48:07
@ loft & Hitchhiker427, i couldn't agree more. it would be far nicer as a proper component that didn't have all these silly limitations. but sadly i just don't have the skills. programming is whole other world compared to hacking this little script together.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: jimbothigpen on 2009-12-14 19:16:58
Quote
in the code look for
Code: [Select]
} else if (ok) {
                        fb.trace(loved_tag_name + " not updated. No changes found.");
                    }

then add that below
Code: [Select]
if (auto_rating == 1 && lastfm_loved == 1 && ok)  {
                                g_metadb.UpdateFileInfoSimple("RATING","5");
                    }


Then dont forget to add the global variable
var auto_rating = 1;
at the top of your script.

It should be fine


@carmenm -- I think I see that you want to update the RATING tag in the file here, right?  I use the Playback Statistics db, as I prefer not to write "non-universal" tags to my muzak as the library is shared among my family.  Being a Windows scripting dummy, I've been unable to figure out how I should change that.  Looked at the code for another wsh panel I use -- the one found at http://www.hydrogenaudio.org/forums/index....st&p=625796 (http://www.hydrogenaudio.org/forums/index.php?s=&showtopic=70363&view=findpost&p=625796) -- but nothing jumped out at me.

Don't go out of your way, but if the solution's obvious to you, please point it out to me!

Thanks!
jimbothigpen
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-14 19:21:42
replace

Code: [Select]
g_metadb.UpdateFileInfoSimple("RATING","5");


with

Code: [Select]
fb.RunContextCommandWithMetadb("Rating/5",g_metadb);


Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: jimbothigpen on 2009-12-14 21:53:46
OK... I use what I think is the most recent version of the code, with foo_customdb.  When I use this code:

Code: [Select]
if (auto_rating == 1 && lastfm_loved_db == 1)  {
fb.RunContextCommandWithMetadb("Rating/5",g_metadb);
}


...in the update_file function, as initially recommended, I get no results.  Nothing I can see, anyway.

When I move that code to the end of the update_customdb function, I get the following:

Error: WSH Panel Mod (GUID: 5493B479-5B82-4C88-A49E-F2545BDB0EC4): Microsoft JScript runtime error:
'lastfm_loved_db' is undefined

If this is just not workable, I can let it go...  Not a big deal.

--jimbothigpen
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-14 22:29:31
as you're using the customdb version, undo any changes you've made. now replace this line of code...

Code: [Select]
userloved == 1 ? update_button(2) : update_button(3);


with

Code: [Select]
if(userloved ==1) {
  fb.RunContextCommandWithMetadb("Rating/5",g_metadb);
  update_button(2);
} else {
  update_button(3);
}

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: jimbothigpen on 2009-12-14 22:57:16
thanks so much to both marc2003 and carmenm!
--jimbothigpen
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: carmenm on 2009-12-15 08:08:09
Thanks for helping marc2003.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: スラッシュ on 2009-12-15 09:46:33
This is great! I've been looking for this for so long, I can't tell you how happy I am that someone's actually gone and wrote this!

One small thing that may be my own oversight: it seems that if the song is not entered in my last.fm database already (ie. it's the first play of it), the script doesn't write a LASTFM_PLAYCOUNT tag. Is that supposed to work like that? I made an autoplaylist with all the songs that haven't had their data updated to LASTFM_PLAYCOUNT with the intention of playing that until the playlist is empty, but it doesn't remove stuff that I simply never played/entered into last.fm yet. (To be honest, i changed LASTFM_PLAYCOUNT to PLAY_COUNTER, which I already had on a couple files... but i don't think that should matter?).

Anyway thanks again for this awesome script!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-15 12:32:38
the sync is a one way thing. if there is nothing from last.fm to write, your files aren't touched. and as a track isn't scrobbled until playback stops, the stats are always going to be 1 play behind.

however, you could add this extra function to take care of it (this runs after the song has played continuously for 60 seconds).

Code: [Select]
function on_item_played() {
  if(fb.TitleFormat("%" + playcount_tag_name + "%").EvalWithMetadb(g_metadb) == "?") {
    g_metadb.UpdateFileInfoSimple(playcount_tag_name, 1);
  }
}


(just add it anywhere between the other functions)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: スラッシュ on 2009-12-15 12:41:46
Brilliant, works a charm. Thanks again!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-15 19:35:55
the link for the customdb version is now dead. this is because it's all been merged into the main version found in the link from the opening post.

click me (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/playcount%20sync.zip)

by default it writes tags to the files just like the original script. i've included instructions on how to enable customdb support.

there are many changes from the original script so if anybody wants any help, they must use this newer version. just copy over the text from "code.txt" making sure you preserve your existing settings.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: i like sleeping on 2009-12-17 01:14:38
Thanks for this! I wondered a while ago if something like this was possible.
The only thing I don't like about it is that it doesn't see any difference between the same track title on a different album. Like with a live album.
I don't think there's anything that can actually be done about it though, short of tagging all your live tracks as "Title (live)" or something.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-17 02:27:44
well i'm just using artist/title to query the last.fm webservices.

but looking at the documentation, it's possible to query the service using the musicbrainz track id instead. obviously this requires all your music is tagged with this information and assumes that last.fm really do handle it properly their end. i notice the audioscrobbler component has an option to scrobble this so it should be possible in theory. if your music is tagged in this way and you do have examples of different track ids with the same artist/title information i can check out, then maybe i could add support for that.

EDIT: i can't see this working at all. i've been checking the raw feeds for lots of random tracks from my collection and none contain the track id, just the artist.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: スラッシュ on 2009-12-17 06:01:23
One more suggestion, although I'm not sure if last.fm lets you do this! If it's possible though, it'd be really great if this script could also get fill in the correct value for <FIRST_PLAYED> to be the first time it was added to last.fm. last.fm does keep that statistic (like here for example (http://www.last.fm/user/surasshu/library/music/The+Back+Horn/_/%E9%8F%A1)), but I don't know if you can actually get to this value... But it'd be really great cause then the values would all be correct, and that would help for stuff like hotness algorithms! (And just general accuracy I guess)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-17 06:41:58
it would seem that is exclusive to their own web pages. they don't publish that info in the web services.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: スラッシュ on 2009-12-17 06:54:24
Yeah, I was afraid of that. It's a shame they keep a lot of info to themselves. Thanks for checking
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: rafib on 2009-12-20 10:24:38
Thank you so much for this plugin! I've been looking for it since 2007  !
I had to add this line:

Code: [Select]
function sync() {
    if (g_metadb.RawPath.indexOf("file://") != 0) return;


This will prevent anything else but a physical file to get synchronized with last.fm (prevent mms, http, etc)

Attached is my foobar2k

(http://img197.imageshack.us/img197/9738/20091220121901.png)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2009-12-20 16:19:48
I had to add this line:


you didn't have to. i've already got checks in place to stop it trying to tag non-local files. the difference is that i do the check after contacting last.fm. this is because you can still see the loved status of a stream because the button will turn red if it is.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Keesface on 2010-01-04 09:24:34
How can i prevent this script from trying to submit information from streams?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-01-04 10:14:29
the reasons it still runs for streams are...

-you can store loved status/playcounts if using customdb mode
-even if not using custom db, you can still love streams and get a graphical representation of that because the button turns red if it is. also, it doesn't try and tag streams because there are checks in place to prevent this....

i suppose it's possible to prevent it checking but it's hardly worth the effort. one little web request per listened to track/stream really shouldn't really matter???

edit: if you really want to stop it, find and replace this function in the script...

Code: [Select]
function on_playback_time(time) {
    if(t.eval() == 10 && file_is_valid) {
        if(old_userloved != 1 && auto_love == 1 && auto_love_condition.eval() == 1) {
            fb.trace("Playcount sync: Auto-love is on. Triggering soft_playlists....");
            fb.RunContextCommand(love_command);
        }
        sync();
    }
}
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: u-neeks on 2010-01-11 21:48:43
hi,

please, how i can set the tracks with any rating(0,1,2,3,4,5) to be loved ?

was thinking about make a playlist with all songs I want to be loved.

thanks for share the script
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-01-11 22:34:11
Quote
rating(0,1,2,3,4,5)


you want it to automatically love ALL tracks as they are played? 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: u-neeks on 2010-01-12 00:58:40
Quote
rating(0,1,2,3,4,5)


you want it to automatically love ALL tracks as they are played? 


yes, then... I dont need to always click to love a track who does have rating loewr than 5 or doesn't have any rating.

plus I could just throw to the playlist the tracks that I want to be loved (without have to rate them).

for just play any playlist normally, I can always turn the auto love off.

I use Quick Tagger for rating, and hit properties and set the rating one by one for diferent rating is a bit annoying.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-01-12 01:16:43
well it is already documented what you need to do...

Code: [Select]
//automatically love tracks based on titleformatting below. turned off by default. set to 1 to enable.
var auto_love = 0;
//basic example of title formatting to use. this will automatically "love" all tracks with a rating of 5
//of course you can use anything you like. result must be 1 in conjunction with the above option
//being set for it to trigger
var auto_love_condition = fb.TitleFormat("$ifequal(%rating%,5,1,0)");


but in your case you can remove the "fb.TitleFormat" bit altogether.

Code: [Select]
var auto_love_condition = 1;
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: u-neeks on 2010-01-12 04:06:33
working fine now, thanks!   

i needed to change this line too:
Code: [Select]
if(old_userloved != 1 && auto_love == 1 && auto_love_condition.eval() == 1) {

to:
Code: [Select]
if(old_userloved != 1 && auto_love == 1 ) {

because of that error:

[00:49:43] Error: WSH Panel Mod (GUID: 78F958F8-3A87-4511-AEB9-3066E3C6136E): Microsoft JScript runtime error:
Object doesn't support this property or method
Ln: 104, Col: 3
<no source text available>
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-01-12 09:35:27
sorry about that. at least you figured it out. 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-01-12 15:39:35
T.P Wang has made a new version of WSH panel mod that runs natively in DUI without dockable panels. check it out.

http://code.google.com/p/foo-wsh-panel-mod/downloads/list (http://code.google.com/p/foo-wsh-panel-mod/downloads/list)

huge thanks to T.P for that.

(could a passing mod edit the first post to reflect this. thanks.)

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: スラッシュ on 2010-01-14 23:09:09
Hi marc,

Again I come with a suggestion that may not be possible--but here goes anyway: could the system check for auto-adjusted names? In most cases this points to a bad tag, but for example I have albums of "MOSAIC.WAV", and that name doesn't scrobble properly due to a bug in last.fm's code (that has been there for YEARS). As a workaround, the tag on my files is "MOSAIC. WAV", but now the tag updater doesn't work properly, since it's an auto-adjusted name.

In other cases it might be due to romanised name (for example I had files with Koji Kondo as tag, instead of 近藤浩治 which is harder to search for...).

So if it's at all possible, I'd really like this option!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-01-14 23:58:04
i'm kind of lost for words.....what exactly can i do about that? 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Andreasvb on 2010-01-15 00:19:58
I had some problem updating to the new WSH Panel Mod.

It works now, not sure if it's a bug.

The paths for the scripts are wrong, there's no \ char.

Original:
Code: [Select]
$(dir.component)jscript.api;$(dir.component)interface.api

Edited:
Code: [Select]
$(dir.component)\jscript.api;$(dir.component)\interface.api
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: スラッシュ on 2010-01-15 00:28:28
i'm kind of lost for words.....what exactly can i do about that? 

Ah I guess I didn't explain that part... I was thinking, maybe you could check if last.fm did its "changed your tags for you" thing, and then get the playcount from the resulting tag instead? I dunno if you actually can do that though.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-01-15 00:38:54
i take the artist and title and try and directly access a file on the last.fm servers. it either exists or it doesn't. that is all. there is no response saying "aw... did you mean this? "

it sucks that last.fm don't tag all music as it should be, but there's very little you can do about it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-01-15 00:44:39
I had some problem updating to the new WSH Panel Mod.


there's nothing wrong with how it was. those files are to provide auto-complete in the editor and it works fine without the changes you've made.

the latest change in WSH panel mod that does affect this script is that "safe mode" is enabled by default. anybody upgrading will need to disable it. for anybody who doesn't know, this is set under the main foobar preferences>tools>WSH panel mod.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: スラッシュ on 2010-01-15 00:45:30
Yeah... I kinda expected that, but I figured there was no harm in asking. Since the actual website does say "did you mean this?" there was a small chance their web interface does too...

It's kind of an annoying bug since I hate not having the correct tag, the fact that a major artist is simply not supported by their scrobbler (but it IS supported in last.fm, since there's a page for it), it is a bit crazy. At least submitting with "incorrect" tags allows me to actually scrobble my plays (of course I discovered this after I played the mosaic.wav tracks dozens of times already...). Anyway, thanks for explaining
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Hitchhiker427 on 2010-01-15 00:45:40
I had the same problem as スラッシュ with the renaming of some tracks.  If you go into your Last.fm's preferences you can disable the renaming option.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Andreasvb on 2010-01-15 00:51:12
I had some problem updating to the new WSH Panel Mod.


there's nothing wrong with how it was. those files are to provide auto-complete in the editor and it works fine without the changes you've made.

the latest change in WSH panel mod that does affect this script is that "safe mode" is enabled by default. anybody upgrading will need to disable it. for anybody who doesn't know, this is set under the main foobar preferences>tools>WSH panel mod.

I tried disable it first, maybe had to restart foobar2000 or the playback.

It works either way, thanks.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Sparanoid on 2010-01-16 03:43:40
I got an error when updated to wsh panel mod beta 4:

Code: [Select]
Scripting Engine Initialization Failed (GUID: 5C5DECD1-A7FA-4977-87D2-EA1863009B43, CODE: 0x80020101)
Check the console for more detailed information (Always caused by unexcepted script error).


console:

Code: [Select]
WSH Panel Mod (GUID: 5C5DECD1-A7FA-4977-87D2-EA1863009B43): Parsing file "D:\Program Files (x86)\foobar2000\scripts\tooltip_buttons.js": Failed to load
Error: WSH Panel Mod (GUID: 5C5DECD1-A7FA-4977-87D2-EA1863009B43): Microsoft JScript runtime error:
Automation server can't create object
Ln: 38, Col: 1
<no source text available>
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-01-16 09:23:13
the latest change in WSH panel mod that does affect this script is that "safe mode" is enabled by default. anybody upgrading will need to disable it. for anybody who doesn't know, this is set under the main foobar preferences>tools>WSH panel mod.

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Sparanoid on 2010-01-19 22:13:48
Thanks a lot I get it works, now I'm working on integrating this script to my new theme, things getting on well but have a problem: I'm trying to display the playcount %LFM_TH%%LFM_H%%LFM_T%%LFM_U% with customdb enabled but got playcount like these: ???3, ??23, ?876.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-01-19 22:17:18
if you check the readme file again, you'll see they have [] around them to prevent that.

Code: [Select]
[%LFM_TH%][%LFM_H%][%LFM_T%][%LFM_U%]
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Sparanoid on 2010-01-19 22:29:33
Oh, that works! I'm not very good at coding  , Thanks!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Sparanoid on 2010-01-19 23:51:36
Well this may be a bug: when I enable Spelling Correction on last.fm website this script can't get the playcount.

Such as: When the japanese pop singer Itou Kanako automatically corrected to いとうかなこ, the script didn't work
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-01-20 00:30:22
if last.fm is wrong, you can turn off spelling correction in the options.

http://www.last.fm/settings/website (http://www.last.fm/settings/website)

there's nothing my script can do about this. from just a few posts up.....

i take the artist and title and try and directly access a file on the last.fm servers. it either exists or it doesn't. that is all.



EDIT:
could a kind moderator please make the following changes to the opening post.

-file tagging is no longer compulsory. it works with foo_customdb which means you can store stats for anything without touching your files.
-in the 2nd list item, change the time period from 60 to 10 seconds.
-remove the 3rd list item altogether

thanks. 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Sparanoid on 2010-01-20 09:07:45
Happy to say that I just integrated this script to my lastest foobar2000 skin, I hope you like it:

http://junior-spirit.deviantart.com/art/Mo...st-fm-151086022 (http://junior-spirit.deviantart.com/art/MonoLite-Plus-0-4-x-Last-fm-151086022)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: carmenm on 2010-01-20 10:17:50
Happy to say that I just integrated this script to my lastest foobar2000 skin, I hope you like it:

http://junior-spirit.deviantart.com/art/Mo...st-fm-151086022 (http://junior-spirit.deviantart.com/art/MonoLite-Plus-0-4-x-Last-fm-151086022)

Very very nice. How do you get a window without titlebar?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Sparanoid on 2010-01-20 10:37:38
Very very nice. How do you get a window without titlebar?

Oh not really, I just crop it in my Photoshop...
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: carmenm on 2010-01-20 10:45:54
Very very nice. How do you get a window without titlebar?

Oh not really, I just crop it in my Photoshop...

Ok

I really like your config. If you dont mind i might still a few ideas
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: MB. on 2010-01-20 14:32:42
Awesome! I cant say how much i like this!
thanks so much for developing this!

i have a request: could you guys make it that after i play a track for the first time, the lastfm playcount gets +1 after i stopped listening to this?
what happens now is that i listen to a track for the first time and then the next track starts but the playcount does not get updated.

i.e.

i listen to a track (playcount on last.fm is 0)
script syncs lastfm playcount after 10 secs -> gets 0 because i never listened to that track so tag in custom db stays empty
opening next track artist - track 2
[it would be nice if you let the script take lastfm_playcount and add 1 to it here]

that way i can see which music i listened and which i did not listen!
would be so awesome!

i cant code javascript and i'm busy but i dont think its that hard to make if you made such a brilliant script
thanks again to the developers!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: carmenm on 2010-01-20 14:42:13
Awesome! I cant say how much i like this!
thanks so much for developing this!

i have a request: could you guys make it that after i play a track for the first time, the lastfm playcount gets +1 after i stopped listening to this?
what happens now is that i listen to a track for the first time and then the next track starts but the playcount does not get updated.

i.e.

i listen to a track (playcount on last.fm is 0)
script syncs lastfm playcount after 10 secs -> gets 0 because i never listened to that track so tag in custom db stays empty
opening next track artist - track 2
[it would be nice if you let the script take lastfm_playcount and add 1 to it here]

that way i can see which music i listened and which i did not listen!
would be so awesome!

i cant code javascript and i'm busy but i dont think its that hard to make if you made such a brilliant script
thanks again to the developers!


I dont that would be the solution. And i am thinking about something. WE use lastfm playcount, but maybe that s not the real playcount. Maybe the playcount should be the max of the lastfm playcount and the statistics component playcount. I think i will go with something like that
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-01-20 14:59:55
i'll add an option for auto correction (add 1 to last.fm repsonse).

i really need to update this for use with DUI such as setting background colours and whatnot.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: MB. on 2010-01-20 15:02:42
Quote
I dont that would be the solution. And i am thinking about something. WE use lastfm playcount, but maybe that s not the real playcount. Maybe the playcount should be the max of the lastfm playcount and the statistics component playcount. I think i will go with something like that


hm i was hoping that i could remove the playcount statistics component.

hah i think i actually managed to do it
i'll test it hang on if it works i'll post it here in a sec!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: MB. on 2010-01-20 15:04:34
here they are my first lines of JS

i just added after the custom db == 1 because i use it, but i think adding it before its being added to your tags should do the trick!

Code: [Select]
var newplaycount = (userplaycount * 1)+1; 
var userplaycount = newplaycount.toString();
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: carmenm on 2010-01-20 15:12:56
here they are my first lines of JS

i just added after the custom db == 1 because i use it, but i think adding it before its being added to your tags should do the trick!

Code: [Select]
var newplaycount = (userplaycount * 1)+1; 
var userplaycount = newplaycount.toString();

that s a solution or maybe we should modify the statistics playcount if lastfm count is superior!
I ll look into it
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: MB. on 2010-01-20 15:17:19
Awesome! I cant say how much i like this!
thanks so much for developing this!

i have a request: could you guys make it that after i play a track for the first time, the lastfm playcount gets +1 after i stopped listening to this?
what happens now is that i listen to a track for the first time and then the next track starts but the playcount does not get updated.

i.e.

i listen to a track (playcount on last.fm is 0)
script syncs lastfm playcount after 10 secs -> gets 0 because i never listened to that track so tag in custom db stays empty
opening next track artist - track 2
[it would be nice if you let the script take lastfm_playcount and add 1 to it here]

that way i can see which music i listened and which i did not listen!
would be so awesome!

i cant code javascript and i'm busy but i dont think its that hard to make if you made such a brilliant script
thanks again to the developers!


I dont that would be the solution. And i am thinking about something. WE use lastfm playcount, but maybe that s not the real playcount. Maybe the playcount should be the max of the lastfm playcount and the statistics component playcount. I think i will go with something like that



here they are my first lines of JS

i just added after the custom db == 1 because i use it, but i think adding it before its being added to your tags should do the trick!

Code: [Select]
var newplaycount = (userplaycount * 1)+1; 
var userplaycount = newplaycount.toString();

that s a solution or maybe we should modify the statistics playcount if lastfm count is superior!
I ll look into it


i think i dont need playcount statistics anymore
i always used that db so now i can use the custom db with last fm playcount stats!

time to build a new DUI theme
WSH panel + foobar 1 gave sooo much new cool options!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: carmenm on 2010-01-20 15:19:05
here they are my first lines of JS

i just added after the custom db == 1 because i use it, but i think adding it before its being added to your tags should do the trick!

Code: [Select]
var newplaycount = (userplaycount * 1)+1; 
var userplaycount = newplaycount.toString();

that s a solution or maybe we should modify the statistics playcount if lastfm count is superior!
I ll look into it


i think i dont need playcount statistics anymore
i always used that db so now i can use the custom db with last fm playcount stats!

time to build a new DUI theme
WSH panel + foobar 1 gave sooo much new cool options!

But what if you play music while not having the net. You have lost playcounts. I dont want that
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: MB. on 2010-01-20 15:29:16
foo_audioscrobbler saves them in your cache, next time you play a track it'll be updated.

but then we need a function that syncs playcount stats with tracks that were played when disconnected


too bad last fm doesnt allow us to download all stats at once
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: HiRsch on 2010-01-20 15:44:49
hi,
i'm usin foobar 1.0 and DUI, but can't manage to get the WSH panel into the toolbar, as seen on your screenshot. can anyone help?
very sweet tool btw!
cheers bro
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: MB. on 2010-01-20 15:57:01
hm i have another question:
my foobar hangs after 10 seconds of playtime (its checking/syncing with last.fm)
but it takes around ~40 seconds! is that normal?

maybe its because i have a very big library or a big number of scrobbled tracks? (it cant be my pc)
ow  add me to last.fm if you like: http://www.last.fm/user/silk-nl (http://www.last.fm/user/silk-nl)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: MB. on 2010-01-20 16:03:34
hi,
i'm usin foobar 1.0 and DUI, but can't manage to get the WSH panel into the toolbar, as seen on your screenshot. can anyone help?
very sweet tool btw!
cheers bro


enable layout editing mode>right click your buttons and choose customize>add a new button with the function to love last.fm track (foo_softplaylists)
that should work!

edit: problem with this method is that your track will be loved the next time you play it, not directly!
maybe someone has a better idea
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: carmenm on 2010-01-20 16:08:38
hm i have another question:
my foobar hangs after 10 seconds of playtime (its checking/syncing with last.fm)
but it takes around ~40 seconds! is that normal?

maybe its because i have a very big library or a big number of scrobbled tracks? (it cant be my pc)
ow  add me to last.fm if you like: http://www.last.fm/user/silk-nl (http://www.last.fm/user/silk-nl)

It has nothing to do with the number of tracks in your library (or it would take ages here ). I would say it s problem with your internet connection. You should see logs of lastfm in the console. What is the last one you see when it starts hanging?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: MB. on 2010-01-20 16:12:38
Playcount sync: Contacting Last.fm....
[HANG for 40 secs]
Status: OK

my library is around 750GB
and i have over 45k scrobbles.

maybe it is my internet its not that fast :S
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: carmenm on 2010-01-20 16:24:24
Playcount sync: Contacting Last.fm....
[HANG for 40 secs]
Status: OK

my library is around 750GB
and i have over 45k scrobbles.

maybe it is my internet its not that fast :S

As i said it has nothing to do with your library, whatever the size or scrobbled score.
From what you tell me it takes you a really long time to contact lastfm.
can you tell me if it takes overtime to open that page
http://ws.audioscrobbler.com/2.0/?method=a...ac220b7b2e0a026 (http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=lovemakers&api_key=b25b959554ed76058ac220b7b2e0a026)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: MB. on 2010-01-20 16:37:02
Playcount sync: Contacting Last.fm....
[HANG for 40 secs]
Status: OK

my library is around 750GB
and i have over 45k scrobbles.

maybe it is my internet its not that fast :S

As i said it has nothing to do with your library, whatever the size or scrobbled score.
From what you tell me it takes you a really long time to contact lastfm.
can you tell me if it takes overtime to open that page
http://ws.audioscrobbler.com/2.0/?method=a...ac220b7b2e0a026 (http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=lovemakers&api_key=b25b959554ed76058ac220b7b2e0a026)


that page is loaded in a sec so nope thats not it...
i'm on 4mbit/.5mbit
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: carmenm on 2010-01-20 16:59:55
Playcount sync: Contacting Last.fm....
[HANG for 40 secs]
Status: OK

my library is around 750GB
and i have over 45k scrobbles.

maybe it is my internet its not that fast :S

As i said it has nothing to do with your library, whatever the size or scrobbled score.
From what you tell me it takes you a really long time to contact lastfm.
can you tell me if it takes overtime to open that page
http://ws.audioscrobbler.com/2.0/?method=a...ac220b7b2e0a026 (http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=lovemakers&api_key=b25b959554ed76058ac220b7b2e0a026)


that page is loaded in a sec so nope thats not it...
i'm on 4mbit/.5mbit

strange
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-01-20 23:36:40
New version uploaded (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/playcount%20sync.zip)

changes:

bundled required components into zip
defaults to using foo_customdb
requires foobar v1 as it uses latest WSH panel mod (now with native DUI support)
context menu for setting panel background colour
Quote
“None” is for CUI users who have the “Pseudo transparent” option enabled.
“Default” follows the DUI/CUI background colours. The panel will update itself if you change scheme.
“Splitter” does what it says on the tin.
“Custom” is an RGB value you can set in the script.


Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Hitchhiker427 on 2010-01-21 05:49:48
Thanks for the update, it's running well.

One thing, though.  The following line is present in the on_paint() function:

Code: [Select]
if(dui) gr.DrawRect(0,0, ww, wh, 1.0, RGB(160,160,160));


It adds a faux-border effect to the button.  Wouldn't it be better to control the edge style using the WSH Panel Mod editor instead of a hard-coded command?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-01-21 06:04:31
you're right. i thought last time i checked, it didn't look right. but the "grey" effect looks exactly the same now. i'll remove that line.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: puserp on 2010-01-22 10:25:44
First of all I want to thank marc2003, for this script. It is very helpful to me.
Second of all I think there is a problem that i can not solve.
1. foo_customdb.dll.cfg config has a mistake in action "Set value" for "CustomdbTH 9". It should be 9, but now it is "CustomdbTH 9".
2. for playcount i use string from readme.pdf

Code: [Select]
$max([%LFM_TH%][%LFM_H%][%LFM_T%][%LFM_U%],[%play_count_cd%])


For some strange reason it shows 355 instead of 35. All other number(so far ?) are shown correctly.
Any explanations of this behavior ?

update:

LFT_T shows 3
LFM_U shows 55

last.fm website shows stats correctly

Is error in parsing part of the script ?

update2: I don't know if it is important, but track with playcount value 355 have rating value 5. Now i am trying to see if 355 playcount will appear on track without rating tag.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-01-22 11:16:48
1) thanks for spotting. i'll get a corrected version uploaded. but only people with over 9000 plays for a track will have been affected so far.

and i don't see how your LFM_U can show 55. the action for the "Customdb U" should be set to 5. if there was a typo, it would have been spotted long before now. try playing the song for 10 seconds so it updates again and see what happens.

EDIT: updated version uploaded. all foo_customdb users should overwrite their foo_customdb.dll.cfg file with the new one in this upload.

http://cid-649d3bfeaf541fbb.skydrive.live....ount%20sync.zip (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/playcount%20sync.zip)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: puserp on 2010-01-22 11:28:56
1) thanks for spotting. i'll get a corrected version uploaded. but only people with over 9000 plays for a track will have been affected so far.

and i don't see how your LFM_U can show 55. the action for the "Customdb U" should be set to 5. if there was a typo, it would have been spotted long before now. try playing the song for 10 seconds so it updates again and see what happens.


"never underestimate the stupidity"

I was able to spot your mistake in foo_customdb config, but made one myself. There was value 55 for CustomdbU 5 action. Shame on me
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-01-22 11:44:20
currently, this script only supports play counts upto 9999 when using foo_customdb - i'm just wondering, is there anybody on here who is likely to run into this limitation any time soon? 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Jack Schmaltz on 2010-01-22 14:30:11
iv had my eye on this for a while but didnt fancy it due to it originally updating files.
now that its in customdb iv give it a whirl & i must say im very impressed.
managed to fit it into my cui very easily & even make a few mods through customdb.

thanks for your efforts marc2003, greatly appreciated
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-01-26 01:08:18
minor update of config.

http://cid-649d3bfeaf541fbb.skydrive.live....ount%20sync.zip (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/playcount%20sync.zip)

-nothing new except the user credentials are now set in an external file. this means i can make future last.fm related panels but the end user only has to set their username in one place.
-contains some other sample WSH scripts
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Fractal_Mortality on 2010-01-26 06:52:06
Hey Marc, this is a really nitpicky thing, but is there any way to add padding to the top of the love "heart button" in order for it to line up with other buttons better?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-01-26 06:57:34
sure, just find this line in the panel (it's near the top)

Code: [Select]
top_margin = dui ? 2 : 0;


2 is the default top margin for DUI, 0 is the default for CUI. modify these however you like.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Fractal_Mortality on 2010-01-26 08:37:59
Sorry, one more question... How do I set the newer version to use file tagging instead of custom_db?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-01-26 10:43:19
you need to edit the file \scripts\marc2003\lastfm.js

it's the first option after entering your username/api key. i don't see how you can miss it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Fractal_Mortality on 2010-01-26 16:07:07
Sorry, I'm a slow one, lol.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Fractal_Mortality on 2010-01-28 04:33:28
Hey Marc, in which part of which script do we set custom colors? Thanks.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-01-28 05:25:35
you need to edit the file \scripts\marc2003\lastfm.js


again...  admittedly it's further on down the page but it's all commented. use the context menu to switch to it once you've set it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Fractal_Mortality on 2010-01-28 05:45:56
you need to edit the file \scripts\marc2003\lastfm.js


again...  admittedly it's further on down the page but it's all commented. use the context menu to switch to it once you've set it.


Dawgoneit! I kept looking through fonts_colours_flags.js, lol
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-01 13:09:24
New version (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/playcount%20sync.zip)

Quote
Updated 01/02/2010

This new version has some major changes from the previous version. It uses foo_customdb exclusively – no more file tagging support. If you require this, you can get the old version here (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/old%5E_playcount%20sync.zip).

New version features:

-   No more script editing. Everything is set via the context menu.
-   Removal of superfluous options. See above link if you want “auto love” and “add one” features from previous versions.
-   Storage of settings is now completely independent of the script so any future script updates means you can simply overwrite the files without having to backup/restore your settings manually.


no real reason for existing users to upgrade. i've just been playing around making it easier to use for new users.

(http://k5sbdw.blu.livefilestore.com/y1p95GL2h1rZcufd436ME1plKI36CLY3CeEXcbvMOk1d9yUWu5NyZb5UBZFrnXmSFmLZO_sFC9aUxIHRhoOfoAwpF71HH-cSEJ3/easy1.png)

(http://k5sbdw.blu.livefilestore.com/y1p2BpYgnhqUicc794x_5qzLSaxXU6u4L17ZnxyPlE8EsyjgFFIpt6C4F6q1uLVcgmuQq_uGUrystSvezJVZhHEO145pt_6OG-h/easy2.png)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: MB. on 2010-02-01 18:25:43
marc2003 you are a hero !
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: unclean on 2010-02-02 05:05:50
Has anyone else not able been to get the autoplaylist method working with the standard installation on Vista or 7?

I have everything set up properly in my config, and copied foo_customdb.dll.cfg to %appdata%\foobar2000\configuration, but [%LFM_TH%][%LFM_H%][%LFM_T%][%LFM_U%] returns nothing. The console isn't showing errors, and other customdb actions like %PLAY_COUNT_CD% work.

Yet the exact same setup on a portable installation works perfectly. I have no idea what is happening.

marc2003 you are a hero !


!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-02 05:19:36
if you copied over the file while foobar was running, closing it probably over wrote it with the default settings? close foobar and copy over the file again. other than that, i have no idea. i've tested this on standard and portable installs.

look in the foo_customdb preferences at the "fields" and "action" tabs. that should tell you if my file is installed properly or not.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Sparanoid on 2010-02-05 04:14:13
hi marc2003, somebody got error message while using my skin MonoLite Plus, I don't know why, I try to translate the messege to English:

when he try to enter his last.fm account via context menu, he got input.wsf error:

char: 1
error: VBScript
code: 8007007E
source: Windows Script Host
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-05 05:57:31
i have no idea but a quick google suggests trying this - start>search/run

regsvr32 scrrun.dll

also make sure windows is up to date.

i've tested my script on XP SP3 and windows 7 x64 with administrator and limited accounts and it all works fine.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Kuraj on 2010-02-06 22:37:35
This isn't working well for me. Although the panel does show whether my track is loved or not, it doesn't show up on NG Playlist. Additionally, i get an error upon leaving the application:

Code: [Select]
Microsoft Visual C++ Runtime Library

Runtime Error!

Program C:\Program Files (x86)\foobar2000\foobar2000.exe

R6025
- pure virtual function call


I'm running Windows 7 Ultimate x64.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Kuraj on 2010-02-06 23:52:45
Also, I tried the old version of plugin, with tag mode - which partially solved the problem since i was able to see the playcounts and love status - but I still get the mentioned error. Even disabling the foo_softplaylists and foo_customdb plugins didn't solve the issue, so I take it's foo_uie_wsh_panel_mod's fault.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: maximillan on 2010-02-07 00:10:34
sorry foobar noob here, how make this work with DUI ?, i cant figure out how to add wsh panel. for clarification dui = default ui?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-07 00:41:14
Also, I tried the old version of plugin, with tag mode - which partially solved the problem since i was able to see the playcounts and love status - but I still get the mentioned error. Even disabling the foo_softplaylists and foo_customdb plugins didn't solve the issue, so I take it's foo_uie_wsh_panel_mod's fault.


no. i assume you're using one of those mono lite mod themes on DA? i've seen that error mentioned as a known issue and it has nothing to with this script or the components it uses. WSH panel mod,soft playlists and foo_customdb have been rock solid for me. and no one else has mentioned that error in the 2 months since i put this together.

sorry foobar noob here, how make this work with DUI ?, i cant figure out how to add wsh panel. for clarification dui = default ui?


you have to use layout editing mode found on the view menu to add a panel to your layout.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Kuraj on 2010-02-07 02:03:01
no. i assume you're using one of those mono lite mod themes on DA? i've seen that error mentioned as a known issue and it has nothing to with this script or the components it uses. WSH panel mod,soft playlists and foo_customdb have been rock solid for me. and no one else has mentioned that error in the 2 months since i put this together.


No, I'm not using any more off DA; here's my list of components:
Code: [Select]
Core (2010-01-09 12:47:00)
    foobar2000 core 1.0
foo_albumlist.dll (2010-01-09 12:44:46)
    Album List 4.4
foo_audioscrobbler.dll (2010-02-06 21:14:04)
    Audioscrobbler 1.4.5
foo_cdda.dll (2010-01-09 12:44:42)
    CD Audio Decoder 3.0
foo_converter.dll (2010-01-09 12:44:32)
    Converter 1.4
foo_dsp_std.dll (2010-01-09 12:44:48)
    Standard DSP Array 1.0
foo_input_std.dll (2010-01-09 12:44:24)
    Standard Input Array 1.0
foo_mlt.dll (2007-10-27 21:35:30)
    Miranda ListeningTo foobar2000 Plugin 1.0
foo_musicbrainz.dll (2009-04-10 21:27:28)
    MusicBrainz Tagger 0.2
foo_rgscan.dll (2010-01-09 12:44:24)
    ReplayGain Scanner 2.0.9
foo_ui_columns.dll (2010-01-09 15:40:28)
    Columns UI 0.3.8.3
foo_ui_std.dll (2010-01-09 12:44:52)
    Default User Interface 0.9.5
foo_uie_albumlist.dll (2009-06-13 23:49:19)
    Album list panel 0.3.5
foo_uie_lyrics2.dll (2010-02-03 00:35:08)
    Lyric Show Panel 2 0.4.6.12
foo_w7shell.dll (2010-01-17 04:09:20)
    Windows 7 integration 0.2.9.1


Now that I think about it, it might be one of those; I'll play with them tomorrow, and see if it works.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-07 03:08:19
could be lyrics. that's pretty unstable by all accounts.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Sparanoid on 2010-02-07 07:14:41
Also, I tried the old version of plugin, with tag mode - which partially solved the problem since i was able to see the playcounts and love status - but I still get the mentioned error. Even disabling the foo_softplaylists and foo_customdb plugins didn't solve the issue, so I take it's foo_uie_wsh_panel_mod's fault.


lyrics2 component sometimes may freeze your window when the track change, I've still no idea about crashing on closing foobaar2000

http://www.hydrogenaudio.org/forums/index....6968&st=400 (http://www.hydrogenaudio.org/forums/index.php?showtopic=76968&st=400)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-07 07:20:35
I've still no idea about crashing on closing foobaar2000


so haven't you tried eliminating components one by one? does it still crash on close when lyrics is removed? maybe try removing wsh panel mod? maybe it is the issue - i just thought it was unlikely as i've never seen anyone report it here.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: nikolai4ik on 2010-02-07 09:39:14
Hey, I've been looking for such a script and I've finally found it  Just a couple of questions. Is it possible to write directly to the file ID3 tags without custom db? And is it possible to also retrieve the first played date? Cheers
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-07 09:50:01
here's the old version with file tagging support (the link in the new readme should be clickable and take you here as well)

http://cid-649d3bfeaf541fbb.skydrive.live....ount%20sync.zip (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/old%5E_playcount%20sync.zip)

sorry but your other request isn't possible. last.fm don't expose that information for us to use.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Quarck on 2010-02-07 12:24:11
Hurray!!! Finally, I waited it so long. Thank you very, very much. I hope someday it will grow up to real plugin such as songbird's vandelay (http://addons.songbirdnest.com/addon/1458).
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-07 13:23:31
and maybe one day songbird will grow up into something just about usable.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Kuraj on 2010-02-07 15:37:47
I stripped my active plugins to this:
Code: [Select]
Core (2010-01-09 12:47:00)
    foobar2000 core 1.0
foo_audioscrobbler.dll (2010-02-07 15:16:48)
    Audioscrobbler 1.4.6
foo_input_std.dll (2010-01-09 12:44:24)
    Standard Input Array 1.0
foo_musicbrainz.dll (2009-04-10 21:27:28)
    MusicBrainz Tagger 0.2
foo_ui_columns.dll (2010-01-09 15:40:28)
    Columns UI 0.3.8.3
foo_ui_std.dll (2010-01-09 12:44:52)
    Default User Interface 0.9.5
foo_uie_albumlist.dll (2009-06-13 23:49:19)
    Album list panel 0.3.5
foo_uie_wsh_panel_mod.dll (2010-01-28 05:51:58)
    WSH Panel Mod 1.3.1


and I still get the same error. I even tried deleting the entire configuration folder and recreating my settings from scratch, didn't help. If the fault happens to be on one of those plugins' side, then I'm forced to give it up :/
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-07 16:21:58
maybe there is some kind of conflict going on with some people's systems and WSH panel mod then? is there anything at all in the windows event log about the errors? anything you could post in the WSH panel mod thread to help the developer at all? i just bodge scripts together. i have no idea about how to troubleshoot problems with proper components.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Kuraj on 2010-02-07 16:42:14
All I can do is to post the event logs in the WSH Panel Mod development thread. I'm going to do this now.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: nikolai4ik on 2010-02-07 20:12:23
here's the old version with file tagging support (the link in the new readme should be clickable and take you here as well)

http://cid-649d3bfeaf541fbb.skydrive.live....ount%20sync.zip (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/old%5E_playcount%20sync.zip)

sorry but your other request isn't possible. last.fm don't expose that information for us to use.

thank you
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: MB. on 2010-02-08 10:15:28
for some reason i cant get it work anymore.
it gets the data from last.fm but it doesnt write it to my db.

i installed it more than once, then it works for a few tracks but then it stops working again?!
anyone can help?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: thedevilisinthedetails on 2010-02-08 10:46:42
I'm the biggest noob ever, but I cant seem to figure out where I would be able to view the play count.. I edited in my columns in playlist view with this as the display code [%LFM_TH%][%LFM_H%][%LFM_T%][%LFM_U%] and I get nothing... I'm sure I'm either overlooking something or I'm more of a noob than I thought I was,.. Any help would be appreciated. Thanks
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-08 12:00:18
what you've entered is correct. but as i said in the readme file, you won't see the playcount for a track until you've played it (for 10 seconds).

if you've played the track but can't see any update, then check the console on the "view" menu and that might give some clue. all this is explained in the aforementioned readme file.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: dalover on 2010-02-08 12:27:38
Thanks for your effort

Is it possible to change your "simple biography.txt"-script to get different Language bios?

In my case I hear German, English and Japanese music.
It would be nice if I could specify a search order eg, at first in German and if there's notthing found then in English and Japanese.

greetz dalover
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-08 12:56:23
sorry but i won't be adding those as options.

however, you can modify the script yourself to use another language. find the "get_bio()" function and you can change this....

Code: [Select]
lastfm("&method=artist.getinfo&artist=" + encodeURIComponent(artist), "foo_wsh_lastfm_bio", function() {save_file();});


into

Code: [Select]
lastfm("&lang=de&method=artist.getinfo&artist=" + encodeURIComponent(artist), "foo_wsh_lastfm_bio", function() {save_file();});


or

Code: [Select]
lastfm("&lang=jp&method=artist.getinfo&artist=" + encodeURIComponent(artist), "foo_wsh_lastfm_bio", function() {save_file();});
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: dalover on 2010-02-08 13:06:27
thanks - I've changed it
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-08 13:17:37
i'll add a context menu to make switching languages easier. i'll post an update here


actually i won't bother. people can just use ssenna's proper biography component if they need these features.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: thedevilisinthedetails on 2010-02-08 14:03:01
ahh ok, So I did read the readme file. And I did wait 10 seconds, I waited till the whole song finished. I even checked the console and this is what i get:

Audioscrobbler: Submitting track...
Audioscrobbler: Submission succeeded.
Opening track for playback: "I:\Music\Boards Of Canada\(1998) Music Has The Right To Children\Boards Of Canada - Music Has The Right To Children - 13 - Olson.mp3"
Playcount sync: Contacting Last.fm....
Playcount sync: Last.fm responded "OK"
TouchRemote: items modified in library: 1

It doesnt update anything in my "played" field. just stays empty.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: dalover on 2010-02-08 14:03:21
Quote
i'll add a context menu to make switching languages easier. i'll post an update here

Too bad that you changed your mind. I use currently ssenna's plugin and your script.
But still many thanks for the script and the work inside it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-08 14:10:55
It doesnt update anything in my "played" field. just stays empty.


goto the properties of the track and then the properties tab. have you got anything listed under "Custom Database"?

is the foo_customdb.dll.cfg i supplied in the correct location? right click a track and check the "legacy commands (unsorted)" submenu - it should be full of customdb entries.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: thedevilisinthedetails on 2010-02-08 14:27:12
It doesnt update anything in my "played" field. just stays empty.


goto the properties of the track and then the properties tab. have you got anything listed under "Custom Database"?

is the foo_customdb.dll.cfg i supplied in the correct location? right click a track and check the "legacy commands (unsorted)" submenu - it should be full of customdb entries.



Yes it shows first played, last played, rating and play counter. under properties in custom database. I put foo_customdb.dll.cfg in my \AppData\Roaming\foobar2000 (I believe this is the correct folder). In legacy commands unsorted I do get much more than what I had previously. Did I do something wrong?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-08 14:32:50
ah, your file isn't inside the "configuration" folder. close foobar and put it in there.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: MB. on 2010-02-08 14:34:24
for some reason i cant get it work anymore.
it gets the data from last.fm but it doesnt write it to my db.

i installed it more than once, then it works for a few tracks but then it stops working again?!
anyone can help?


nevermind fixed it
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-08 14:35:47
sorry i missed your post earlier. at least you've sorted it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: thedevilisinthedetails on 2010-02-08 14:39:13
ah, your file isn't inside the "configuration" folder. close foobar and put it in there.


I guess I had one in the config folder already... I was hoping this was the problem. Still getting the same results..Sorry of being of an annoyance but I'd really like to get this working
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-08 14:40:21
you need to overwrite the existing one in that folder with the one i included in the zip. make sure foobar isn't running when you do this.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: thedevilisinthedetails on 2010-02-08 14:44:07
you need to overwrite the existing one in that folder with the one i included in the zip. make sure foobar isn't running when you do this.



Thanks so much! That was the problem. Such a noob. Thank you once again!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: MB. on 2010-02-08 18:22:29
ok here's a cool thing
if you wanna sync your whole library i suggest to add the following lines of code

Code: [Select]
function on_playback_time(time) {
    if(time == 5) sync();
// add the following line to sync un-synced tracks quickly;)
        if(time == 10) fb.Next();
}

remember to turn of auto add 1 if you have that
now create a playlist of your unsynced tracks and start playing.
after 5 secs a track gets synced and 5 secs later it'll skip to the next track, going trough your whole playlist.
after that make sure you quote this line of code out!

+ here's a my way to show your playcount + (love)
Code: [Select]
$ifequal(%LASTFM_LOVED_DB%,1,♥,)$ifequal($len2([%LFM_TH%][%LFM_H%][%LFM_T%][%LFM_U%]),0,0,)$ifequal($len2([%LFM_TH%][%LFM_H%][%LFM_T%][%LFM_U%]),1,'      ',)$ifequal($len2([%LFM_TH%][%LFM_H%][%LFM_T%][%LFM_U%]),2,'    ',)$ifequal($len2([%LFM_TH%][%LFM_H%][%LFM_T%][%LFM_U%]),3,'  ',)[%LFM_TH%][%LFM_H%][%LFM_T%][%LFM_U%]
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: dalover on 2010-02-08 19:05:17
ok here's a cool thing
if you wanna sync your whole library i suggest to add the following lines of code

Code: [Select]
function on_playback_time(time) {
    if(time == 5) sync();
// add the following line to sync un-synced tracks quickly;)
        if(time == 10) fb.Next();
}
...
+ here's a my way to show your playcount + (love)
$ifequal(%LASTFM_LOVED_DB%,1,?,)$ifequal($len2([%LFM_TH%][%LFM_H%][%LFM_T%][%LFM_U%]),0,0,)$ifequal($len2([%LFM_TH%][%LFM_H%][%LFM_T%][%LFM_U%]),1,'      ',)$ifequal($len2([%LFM_TH%][%LFM_H%][%LFM_T%][%LFM_U%]),2,'    ',)$ifequal($len2([%LFM_TH%][%LFM_H%][%LFM_T%][%LFM_U%]),3,'  ',)[%LFM_TH%][%LFM_H%][%LFM_T%][%LFM_U%]



Here is my playcount:
Code: [Select]
$ifequal(%LASTFM_LOVED_DB%,1,?,)$num([%LFM_TH%][%LFM_H%][%LFM_T%][%LFM_U%],)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: thedevilisinthedetails on 2010-02-10 09:02:15
ok here's a cool thing
if you wanna sync your whole library i suggest to add the following lines of code

Code: [Select]
function on_playback_time(time) {
    if(time == 5) sync();
// add the following line to sync un-synced tracks quickly;)
        if(time == 10) fb.Next();
}

remember to turn of auto add 1 if you have that
now create a playlist of your unsynced tracks and start playing.
after 5 secs a track gets synced and 5 secs later it'll skip to the next track, going trough your whole playlist.
after that make sure you quote this line of code out!

+ here's a my way to show your playcount + (love)
Code: [Select]
$ifequal(%LASTFM_LOVED_DB%,1,?,)$ifequal($len2([%LFM_TH%][%LFM_H%][%LFM_T%][%LFM_U%]),0,0,)$ifequal($len2([%LFM_TH%][%LFM_H%][%LFM_T%][%LFM_U%]),1,'      ',)$ifequal($len2([%LFM_TH%]


[%LFM_H%][%LFM_T%][%LFM_U%]),2,'    ',)$ifequal($len2([%LFM_TH%][%LFM_H%][%LFM_T%][%LFM_U%]),3,'  ',)[%LFM_TH%][%LFM_H%][%LFM_T%][%LFM_U%]




nevermind figured out what i did wrong
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: foolver on 2010-02-11 23:21:28
this is indeed amazing, but there two things that are bugging me:

is it possible to make that little heart invisible or can we put it next to play, stop commands in the menu? because, this way i always need a small peace of the screen devoted to that little heart, and it looks bad (even though that heart icon is extremely cute)

here's what i'm talking about: http://i46.tinypic.com/2j1v4aq.jpg (http://i46.tinypic.com/2j1v4aq.jpg)
that double splitter next to the album art is actually a space reserved to the wsh panel, shrank to the minimum. if i could have the heart somewhere like that drawn heart next to the play, stop buttons, it would be awesome.


also, is it possible to get playcounts based on albums, not overall playcounts? for example (also visible in that picture) i have a live album, but the tracks represent the playcount i have played in all instances, not in that particular live album. possible to implement it differently?


thanks for the plugin, keep up the awesome work!


edit: also, is it possible for the plugin to write 0 as a playcount, when a track isn't found?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: kopf on 2010-02-12 01:42:42
Hi, could you tell me how your script deals with numerous versions of the same song (e.g. EP, Album, and 20 live versions of the same song)?

Below, I can see that there's an "album" tag:

Code: [Select]
[16:20:51] <?xml version="1.0" encoding="utf-8"?>
<lfm status="ok">
<track>
    <id>1036798</id>
    <name>Get Me Off</name>
    <mbid></mbid>
    <url>http://www.last.fm/music/Basement+Jaxx/_/Get+Me+Off</url>
    <duration>288000</duration>
    <streamable fulltrack="0">0</streamable>   
        <listeners>41414</listeners>
    <playcount>150455</playcount>
      [b] <userplaycount>7</userplaycount>    <userloved>0</userloved>[/b]
        <artist>
        <name>Basement Jaxx</name>
        <mbid>28cbf94d-0700-4095-a188-37e373b069a7</mbid>
        <url>http://www.last.fm/music/Basement+Jaxx</url>
    </artist>
        <album position="8">
        <artist>Basement Jaxx</artist>
        <title>Rooty</title>
        <mbid>b821473e-4959-40e4-9b40-48b95ecaf36b</mbid>
        <url>http://www.last.fm/music/Basement+Jaxx/Rooty</url>       
        <image size="small">http://userserve-ak.last.fm/serve/64s/5454246.jpg</image>
        <image size="medium">http://userserve-ak.last.fm/serve/126/5454246.jpg</image>
        <image size="large">http://userserve-ak.last.fm/serve/174s/5454246.jpg</image>
        <image size="extralarge">http://userserve-ak.last.fm/serve/300x300/5454246.jpg</image>
    </album>
        <toptags>
        <tag>
  <name>dance</name>
  <url>http://www.last.fm/tag/dance</url>
</tag>
        <tag>
  <name>electronic</name>
  <url>http://www.last.fm/tag/electronic</url>
</tag>
        <tag>
  <name>house</name>
  <url>http://www.last.fm/tag/house</url>
</tag>
        <tag>
  <name>electronica</name>
  <url>http://www.last.fm/tag/electronica</url>
</tag>
        <tag>
  <name>techno</name>
  <url>http://www.last.fm/tag/techno</url>
</tag>
      </toptags>
    </track></lfm>

However, doesn't that just mean the album which the song "officially" resides on, and not necessarily that the user has played that certain version of the track X times?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-12 02:02:19
@foolver

1) you can't put a WSH panel in a toolbar header in DUI. so you need to make room for it somewhere. i've done it by using WSH panel mod for other buttons and making my own "toolbars". then it doesn't stick out so much. example..

http://k5sbdw.blu.livefilestore.com/y1pcS7...10110%20dui.png (http://k5sbdw.blu.livefilestore.com/y1pcS7-zFoYgay_AkX_Oi7s8OVGVVK1y1b5e_Y6-rx8pfouNO_r9Nrb2Iy1eU3Qj4UJdvg_CshLvBiEJ11AgGJe3HrLNBmJQtMX/lastfm%20forum%20310110%20dui.png)

there are 3 WSH panels in that screenshot and you barely see the splitter that separates them.

2) when i query lastfm for playback statistics, i can only use artist and title. there is no way for me to differentiate which album they come from. even though you scrobble the album when listening, if you browse your charts on the last.fm site, you'll see all playcounts are counted together and they all use "artist" and "title" only. there is nothing i can do about that.

EDIT: you can see for yourself by looking here. this is the API the script uses....

http://www.last.fm/api/show?service=356 (http://www.last.fm/api/show?service=356)

3) it's not really possible to do anything when a track isn't found due to the way i've made the script. if you're really keen i can tell you how to hack your own script.

@kopf, see point 2 above.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: kopf on 2010-02-12 02:40:36
Yep. thought so. Thanks anyway.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-12 11:11:52
New version uploaded (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/playcount%20sync.zip)

i've now made it easier to display the playcount. instead of using....

Code: [Select]
[%LFM_TH%][%LFM_H%][%LFM_T%][%LFM_U%]


you can now use

Code: [Select]
[%LASTFM_PLAYCOUNT_DB%]


for upgraders, there are a few steps to take to migrate the old display across....

-make sure foobar is closed and then overwrite foo_customdb.dll.cfg in your configuration folder with the new one in this download.
-now start foobar and import the new playcount sync.txt into your WSH panel.
-edit your playlist column to show %LASTFM_PLAYCOUNT_DB%
-obviously this field doesn't exist yet so use media library search to find all tracks with playcount data already %LFM_U% PRESENT - now right click, legacy commands (unsorted), Calculate Total.
-that's it. the script will update this new field as it goes.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: MB. on 2010-02-12 13:13:52
good update!
any other changes?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-12 14:05:39
no 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Steve Forte Rio on 2010-02-12 16:04:08
Fantastic! It really works (on DUI also)! Thank you so much!

And is it posible to remove track from "loved" (last fm db)?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-12 16:18:36
you can only "unlove" a track via the last.fm website. the script will notice this next time you play the track and the record will be removed locally.

you can browse your loved tracks here...

http://www.last.fm/user/USERNAME/library/loved (http://www.last.fm/user/USERNAME/library/loved)

hover over the tracks and you'll see a drop down arrow which you can click to "unlove".
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: foolver on 2010-02-12 17:02:50
@foolver

1) you can't put a WSH panel in a toolbar header in DUI. so you need to make room for it somewhere. i've done it by using WSH panel mod for other buttons and making my own "toolbars". then it doesn't stick out so much. example..

http://k5sbdw.blu.livefilestore.com/y1pcS7...10110%20dui.png (http://k5sbdw.blu.livefilestore.com/y1pcS7-zFoYgay_AkX_Oi7s8OVGVVK1y1b5e_Y6-rx8pfouNO_r9Nrb2Iy1eU3Qj4UJdvg_CshLvBiEJ11AgGJe3HrLNBmJQtMX/lastfm%20forum%20310110%20dui.png)

there are 3 WSH panels in that screenshot and you barely see the splitter that separates them.

2) when i query lastfm for playback statistics, i can only use artist and title. there is no way for me to differentiate which album they come from. even though you scrobble the album when listening, if you browse your charts on the last.fm site, you'll see all playcounts are counted together and they all use "artist" and "title" only. there is nothing i can do about that.

EDIT: you can see for yourself by looking here. this is the API the script uses....

http://www.last.fm/api/show?service=356 (http://www.last.fm/api/show?service=356)

3) it's not really possible to do anything when a track isn't found due to the way i've made the script. if you're really keen i can tell you how to hack your own script.
nah, it's ok, i was just wondering. i guess leave all like this way, since i really have no room to put it, other than next to the album art. i found the background -> splitter option to be rather cool. so it doesn't look that bad at all now
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: n0obie4life on 2010-02-12 17:52:21
Nice work on this.
I've found a problem that appears at times (pretty random for me) when trying to determine the playcount and the loved status. I found the problem to be that xmlhttp.responseXML isn't being set at times (for some odd reason).

So I changed it to use xmlhttp.responseText...with regexp to pick out the playcount and loved status. It all works fine now

The modified code below for anyone who's interested.

Code: [Select]
    xmlDoc = xmlhttp.responseText;
    try {
        var re = new RegExp("<userplaycount>([0-9]+)</userplaycount>");
        var m = re.exec(xmlDoc);
        userplaycount = m[1];
    } catch(e) { userplaycount = 0; }

    try {
        var re = new RegExp("<userloved>([0-9]+)</userloved>");
        var m = re.exec(xmlDoc);
        userloved = m[1];
    } catch(e) { userloved = 0; }
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: acmodeu on 2010-02-13 10:29:32
Thank you marc2003 for this plugin & for your personal help with wsh scripts.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: acmodeu on 2010-02-13 16:33:45
Though I did everything as was written in the manual and get "Playcount sync: Contacting Last.fm....
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Steve Forte Rio on 2010-02-13 18:04:54
Looks like internet connection problem.
Check your firewall settings
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: acmodeu on 2010-02-13 18:14:18
Though I did everything as was written in the manual and get "Playcount sync: Contacting Last.fm....

My bad, I wanted to write:
Though I did everything as was written in the manual and get "Playcount sync: Contacting Last.fm....  Playcount sync: Last.fm responded 'OK'" customdb_sqlite.db remains its initial size (4096kb) and %LASTFM_PLAYCOUNT_DB% returns nothing. And I can't get to "love"  anything
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Hitchhiker427 on 2010-02-13 20:35:26
Hey marc2003, I have a little problem with the script, but I don't know if it's fixable.  Essentially, utilizing the customdb induces a slight UI freeze (typically about 2 seconds or so) during the syncing process.  I know that it's a customdb problem because it didn't occur when originally using file tags, it doesn't occur when commenting out the customdb commands in the script, the pause is present but significantly smaller if I comment out some but not all of the customdb commands in the script, and it occurs when using the customdb commands via the context menu.

Now the obvious solution to this problem is to use file tagging, but I'd really prefer the customdb implementation for obvious reasons.  Additionally, the new %LASTFM_PLAYCOUNT_DB% field is much more convenient than individual fields for each digit, however makes the pause slightly worse.

I've combed through the script and can't think of any way to reduce this nuisance, but you're much more experienced, so maybe you have an idea that I haven't considered.  So, any ideas on how to reduce/eliminate this freeze without using file tags?  Thanks.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Steve Forte Rio on 2010-02-13 21:12:30
Though I did everything as was written in the manual and get "Playcount sync: Contacting Last.fm....

My bad, I wanted to write:
Though I did everything as was written in the manual and get "Playcount sync: Contacting Last.fm....  Playcount sync: Last.fm responded 'OK'" customdb_sqlite.db remains its initial size (4096kb) and %LASTFM_PLAYCOUNT_DB% returns nothing. And I can't get to "love"  anything


Maybe you removed some/all customdb context menu commands?

Also try this "bugfix" for script:

Nice work on this.
I've found a problem that appears at times (pretty random for me) when trying to determine the playcount and the loved status. I found the problem to be that xmlhttp.responseXML isn't being set at times (for some odd reason).

So I changed it to use xmlhttp.responseText...with regexp to pick out the playcount and loved status. It all works fine now

The modified code below for anyone who's interested.

Code: [Select]
    xmlDoc = xmlhttp.responseText;
    try {
        var re = new RegExp("<userplaycount>([0-9]+)</userplaycount>");
        var m = re.exec(xmlDoc);
        userplaycount = m[1];
    } catch(e) { userplaycount = 0; }

    try {
        var re = new RegExp("<userloved>([0-9]+)</userloved>");
        var m = re.exec(xmlDoc);
        userloved = m[1];
    } catch(e) { userloved = 0; }

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-13 21:35:13
@acmodeu, does your "legacy commands (unsorted)" context menu look like this?

screenshot (http://public.blu.livefilestore.com/y1p6fSUF-yxzwsTRSCsdgqk83BfEX17wP4ADl7bqWqykK0XVcAU9Q4mrggB7eGrvuwskxGSl26Izf3bIoM-2-S1uQ/context%20menu%20and%20properties.png)

if it doesn't, you haven't followed the instructions properly.

also check the "properties" tab of the the file's properties to see if there are any customdb entries (also illustrated in the above screenshot).

@Hitchhiker427, i've seen visualisations stutter for a split second but 2 whole seconds???? that's not good.    perhaps you should feed those hamsters powering your pc. 

as you might have guessed, i need to run one context menu action per digit in the play count. i suppose my script is inefficient in that it always runs 6 context commands no matter what. you can try this optimised version. but remember for each digit, it has no choice but to run....

replace your process() function with this...

Code: [Select]
function process() {
    fb.trace("Playcount sync: Last.fm responded 'OK'");
    xmlDoc = xmlhttp.responseXML;
    try { userplaycount = xmlDoc.getElementsByTagName("userplaycount")[0].childNodes[0].nodeValue; } catch(e) { userplaycount = 0;}
    try { userloved = xmlDoc.getElementsByTagName("userloved")[0].childNodes[0].nodeValue; } catch(e) { userloved = 0; }
    if(old_userloved != userloved) fb.RunContextCommandWithMetadb("Customdb Love " + userloved, g_metadb);
    if(userplaycount > 0) fb.RunContextCommandWithMetadb("CustomdbU " + userplaycount.substring(userplaycount.length - 1), g_metadb);
    if(userplaycount > 9) fb.RunContextCommandWithMetadb("CustomdbT " + userplaycount.substring(userplaycount.length - 2, userplaycount.length -1), g_metadb);
    if(userplaycount > 99) fb.RunContextCommandWithMetadb("CustomdbH " + userplaycount.substring(userplaycount.length - 3, userplaycount.length - 2), g_metadb);
    if(userplaycount > 999) fb.RunContextCommandWithMetadb("CustomdbTH " + userplaycount.substring(userplaycount.length - 4, userplaycount.length - 3), g_metadb);
    if(userplaycount > 0) fb.RunContextCommandWithMetadb("Calculate Total", g_metadb);
}
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Hitchhiker427 on 2010-02-13 21:55:20
I doubt it's hardware related.  I mean, my primary machine (that freezes for maybe 2 seconds) is an overclocked i7 with 3GB of RAM.  My laptop (Core 2 Duo) pauses for an even longer amount of time.

Yeah, I understand the context menu issue.  I wish there was an easy way to just write a number to a customdb tag, but I guess that's impossible for the time being.

I'm also working on my own "personal" fix.  Since my entire library already has the playcounts calculated, this should work:

- First off, I'm adding 1 to the last.fm playcount. 
- Then I'm both syncing the playcount/loved status and dividing the total playback time into 7 chunks in on_playback_new_track(). 
- Now, in on_playback_time() I'm running one customdb command after the first 6 chunks of time (loved status, thousands, hundreds, tens, units, calculate).  So, after 6/7 of the track has played, the playcount displayed in my playlist column updates by 1. 

Since each update involves a singular customdb command, the freeze is almost imperceptible.  I don't think this implementation is for everyone, but if I can get it working it'll satisfy me.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-13 22:29:22
when you say freeze, how bad is it? does it affect windows as a whole when foobar is minimised? like i said before, if i stare at a visualisation, i'll notice it stutter but it doesn't cause the UI to freeze and certainly isn't noticeable under normal conditions. i only have a lowly pentium dual core and i'm guessing most other people don't have hardware as powerful as yours. i think you're the first person to report any such issues???
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: acmodeu on 2010-02-13 22:34:14
@acmodeu, does your "legacy commands (unsorted)" context menu look like this?

screenshot (http://public.blu.livefilestore.com/y1p6fSUF-yxzwsTRSCsdgqk83BfEX17wP4ADl7bqWqykK0XVcAU9Q4mrggB7eGrvuwskxGSl26Izf3bIoM-2-S1uQ/context%20menu%20and%20properties.png)

if it doesn't, you haven't followed the instructions properly.

also check the "properties" tab of the the file's properties to see if there are any customdb entries (also illustrated in the above screenshot).

Yep, my context menu looks the same, but I've turned it off in the context menu. Shouldn't I? My properties doesn't have such fields. Should I do smth with library?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: acmodeu on 2010-02-13 22:44:47
Seems like I've finally made it work.  Is it right that the thing does not work with legacy commands hidden? And is there a chance for this stuff to work without wsh panel present in the interface because I have to hide them in 1x1 pixel?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Hitchhiker427 on 2010-02-13 23:28:14
when you say freeze, how bad is it? does it affect windows as a whole when foobar is minimised? like i said before, if i stare at a visualisation, i'll notice it stutter but it doesn't cause the UI to freeze and certainly isn't noticeable under normal conditions. i only have a lowly pentium dual core and i'm guessing most other people don't have hardware as powerful as yours. i think you're the first person to report any such issues???


It doesn't affect Windows as a whole, but it does affect the foobar2000 UI.  So yes, visualizations stutter, the progress bar stutters, the playback time freezes, I can't click on anything, and I can't input text.  Additionally, the audio output is completely unaffected, it's just the UI that has problems.

My laptop (Core 2 Duo) will freeze when the playback time is at 0:10, and resumes at 0:14.  My desktop, as I mentioned earlier, freezes for about 2 seconds.

So far, my personal modification is working for the most part, and the stutter is less than a second per update.  It really seems like this is a customdb problem, but that doesn't seem to be updated often.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Hitchhiker427 on 2010-02-13 23:30:21
Seems like I've finally made it work.  Is it right that the thing does not work with legacy commands hidden? And is there a chance for this stuff to work without wsh panel present in the interface because I have to hide them in 1x1 pixel?


WSH Panel Mod can only run non-hidden context menu items.  I've requested that this be fixed, so hopefully if T.P Wang has time he'll get to it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: acmodeu on 2010-02-13 23:42:09
WSH Panel Mod can only run non-hidden context menu items.
Oh, so that was the reason of troubles.  Yeah, that definitely should be fixed.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-14 00:02:28
i have a new test version that i need guinea pigs to try. this has just 4 entries on the context menu. 

http://cid-649d3bfeaf541fbb.skydrive.live....sync%20beta.zip (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/playcount%20sync%20beta.zip)

please only try this if you already have the previous version working already.

instructions.

extract sqlite3.exe into your foobar program directory
make sure foobar is closed and overwrite foo_customdb.dll.cfg in your configuration folder with this new one.
import the new .txt into your WSH panel

now you need migrate all your old playcounts across (library search> %LFM_U% PRESENT ). right click all files and select Migrate Lastfm Playcounts on the legacy commands (unsorted) context menu

finally update your playlist column to show %LASTFM_PLAYCOUNT_DB2% - this is where the playcounts are now going to be stored.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: unclean on 2010-02-14 00:52:49
I had to comment out line 179 to get it working, but other than that and win7 barfing up a security prompt for the sql database it's great so far, thanks!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-14 01:03:30
new beta uploaded - old version only worked on portable installs. it should now work on standard installs as well. same link as above.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Hitchhiker427 on 2010-02-14 01:12:38
Marc, you're my hero.  This fixed up my issue quite well and so far works fine.  I had to change the path to the customdb_sqlite.db file because it's stored in my profile folder rather than the program folder, but other than that I'm happy. Is this change I mentioned all that was fixed in the latest beta (portable vs. standard install), or is there any other reason I should upgrade?  Thanks again.

I'll let you know if I encounter any new problems.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-14 01:19:35
yes that was the exact issue. this is the change i made (line 106)

Code: [Select]
WshShell.Run("sqlite3.exe \"" + fb.ProfilePath + "\\\"customdb_sqlite.db " + query1, 0, true);


edit: only just noticed this..

I had to comment out line 179 to get it working, but other than that and win7 barfing up a security prompt for the sql database it's great so far, thanks!


line 179? that just draws the background?? i'll have to investigate the security prompt thing. i use windows 7 and don't see it - maybe it's because i'm using an admin account. i'll do some more testing.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: dalover on 2010-02-14 01:35:29
Quote
I had to comment out line 179 to get it working, but other than that and win7 barfing up a security prompt for the sql database it's great so far, thanks!


For me the same
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-14 01:39:01
you having problems with line 179 as well? or just the security warning?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: dalover on 2010-02-14 01:41:51
you having problems with line 179 as well? or just the security warning?


Sorry for the missing detail - i have only line 179

Code: [Select]
[02:41:55] Error: WSH Panel Mod (GUID: E7B1F570-46AE-4C3D-A37D-6E7368F38B6F): Laufzeitfehler in Microsoft JScript:
Objekt erwartet
Ln: 179, Col: 2
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Hitchhiker427 on 2010-02-14 01:43:40
I can't speak for/against the line 179 issue because I removed it (and changed a few other parts to suit my theme) before even trying the new version.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-14 01:45:24
i'm thinking perhaps you guys don't have the latest version of my scripts. download the full package from the opening post in this thread and extract just the scripts folder into your foobar program directory. over write any files if you're prompted. restart foobar if it's running.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: dalover on 2010-02-14 01:54:36
U are right  I updated the script folder and the error has disappeared
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-14 03:07:02
another beta uploaded - click me (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/playcount%20sync%20beta.zip)

existing beta users can just import the new .txt file

@Hitchhiker427, you won't like this update because there is a possibility of the script running 3 context menu commands at the same time. it's the only way i can reliably update the playcount for tracks that are already loved. i have to remove existing records for both playcount and loved status otherwise i sometimes get database locked errors.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Hitchhiker427 on 2010-02-14 03:59:27
Hmm... I see.  So, what disadvantages does the previous version have that this latest version addresses? 

Additionally, is it possible to use the sqlite3.exe to delete values in the customdb_sqlite.db and change the loved status?  In fact, it would be perfect (not sure if it's possible) to modify the .db file using ONLY the sqlite3.exe and not ever having to use the context menu controls.  That would both speed things up and clean out the context menu.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: n0obie4life on 2010-02-14 06:22:16
Another piece of code to contribute here


I have a few artists whom I tagged as say "Beyonce", however last.fm aliases "Beyonce" to "Beyoncé".
The current script calls the API to look for "Beyonce" and last.fm does not take into account this alias on the API's side; hence via the API, the script does not detect any playcounts properly.
The API at this point of time does not provide any form indication what artist it's aliased to.

I threw up a fix that detects if the "+noredirect" string is in the URL, then look for similar artists and assumes that the first result is the "correct" artist. This works most of the time - of course there are exceptional cases, but I think this is the furthest we can go, can't possibly be searching through every single result there   


Code modification done is as follows:

In the process() function:
Add right at the top of the function
Code: [Select]
    try {
        var re = new RegExp("\\+noredirect");
        if ( re.test(xmlDoc) ) {
            similar();
            return;
        }
    } catch(e) { }


Add a new function called similar()

Code: [Select]
function similar() {
    fb.trace("Playcount sync: Finding similiar artists...");
    lastfm("&method=artist.getsimilar&limit=1&artist=" + encodeURIComponent(artist), "foo_playcount_sync", function() {
        xmlDoc = xmlhttp.responseText;
        var re = new RegExp("<name>(.*)</name>");
        var m = re.exec(xmlDoc);
        artist = m[1];
        sync();
    });
}



Cheers
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-14 10:47:43
@Hitchhiker427, i already explained in my post why i have to use the context menu commands. if i don't, sqlite fails. it's as simple as that. and given that nobody else has reported issues with the original script that runs 6 commands at once, i'm not too bothered about this version running up to 3.

if a track isn't loved, it runs just 1 command to delete the playcount and then sqlite runs to update the new one
if you've just loved a track for the first time, then it runs 2 commands (1 to delete the playcount, sqlite runs and then 1 to update the loved status)
if you're just playing a track that is already loved, then it runs 3 commands, 1 to delete playcount, 1 to delete the loved status and then another to set the loved status again after sqlite has run.

no way around it i'm afraid. i've messed around using sqlite syntax such as DELETE FROM and INSERT OR REPLACE and it always fails with "database locked" errors when records exist.

@noobie4life, i turn off spelling correction in the website options (http://www.last.fm/settings/website). so that means i get +noredirect in many of my reponses because i refuse to change my tags when i know they are correct and last.fm are wrong. this way, my results always match my scrobbles.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-14 11:57:28
new main version uploaded (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/playcount%20sync.zip)

-the rather large change is the liberation of the legacy commands (unsorted) context menu for existing foo_customdb users. it now contains just 4 entries for my script. there is a separate pdf file included explaining what has to be done to use this new script.
-new users should read the full readme.pdf included.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: n0obie4life on 2010-02-14 15:38:17
@noobie4life, i turn off spelling correction in the website options (http://www.last.fm/settings/website). so that means i get +noredirect in many of my reponses because i refuse to change my tags when i know they are correct and last.fm are wrong. this way, my results always match my scrobbles.


Oh, I didn't know LFM takes into account your settings when it uses the API...it doesn't make sense to me anyhow.

Anyhow, if there are any users who listen to chinese songs and use this plugin, they may well be affected - traditional and simplified chinese are both correct, however lfm takes only the traditional chinese version. So the additional code could prove to be useful

---

May I ask though, why the need for this code in the latest version?
Code: [Select]
if(fb.IsPlaying) { fb.Pause(); fb.Play(); }
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Hitchhiker427 on 2010-02-14 18:18:36
@marc2003, Ok, I understand.  I just tried out the newest main version, and the problem is almost unnoticeable anyhow.  Thanks for all of your hard work.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-14 22:06:23
May I ask though, why the need for this code in the latest version?
Code: [Select]
if(fb.IsPlaying) { fb.Pause(); fb.Play(); }


it's a filthy hack to force the playlist to update instantly. because i'm updating foo_customdb externally, foobar doesn't always recognise that changes have been made so i have to give it a little nudge. the main thing is, it's totally invisible/inaudible to the end user.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: n0obie4life on 2010-02-15 17:33:55
May I ask though, why the need for this code in the latest version?
Code: [Select]
if(fb.IsPlaying) { fb.Pause(); fb.Play(); }


it's a filthy hack to force the playlist to update instantly. because i'm updating foo_customdb externally, foobar doesn't always recognise that changes have been made so i have to give it a little nudge. the main thing is, it's totally invisible/inaudible to the end user.


Ah right okay, thanks.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Hitchhiker427 on 2010-02-16 04:58:37
@marc20003, I think I figured out the problem with the freezing when running the context menu items.  It has to do with the size of my music collection and thus the number of entries in the database.  Before, according to the customdb preferences page, there were well over 40000 entries in the database, and the file size was relatively large as well.  I tried all three of the options under the "tools" header (remove entries, vacuum), to little/no avail.  After upgrading to the latest version, deleting the now legacy %LFM_TH%, %LFM_H%, etc. fields, and re-running the tools, the number of items in my database is about 9500.  Now, when the database is updating, I notice little/no pause on my laptop, which typically froze for ~4 seconds.  Thanks for all of your help.

@n0obie4life, thanks for the code you posted earlier with the similar() function.  I managed to integrate this into my last.fm love/playcount sync script, and now everything works fine.  It was additionally helpful to dissect this and integrate it into my personal bio / artist art / similar artists scripts, which would typically produce poor results with some songs.  My personal library is tagged pretty well, but it's quite common for streaming radio to use poorly formatted (even misspelled) artist tags.  Thanks for discovering and sharing a good solution to this issue.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-16 07:42:40
Quote
After upgrading to the latest version, deleting the now legacy %LFM_TH%, %LFM_H%, etc. fields, and re-running the tools, the number of items in my database is about 9500.


good idea. i'll add that to the "notes for upgraders" readme.

edit: version with updated documentation uploaded (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/playcount%20sync.zip). but to save any existing sqlite users downloading it, this is what i added...

Quote
When you are satisfied that all your old playcounts have been transferred successfully, you can clean up the database by deleting the old values. Goto File>Preferences>Tools>Custom Database. Remove the following fields.

LFM_U
LFM_T
LFM_H
LFM_TH


On the Action tab, you can remove the Migrate Lastfm Playcounts entry. Restart foobar and then come back to the Custom Database preferences. On the Database tab, tick all 3 boxes under the Tool section and click Run.



Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-16 20:36:58
has anybody had any issues with the very latest version sometimes leaving the playcount blank after an update? it's happened 3 times in the last hour after running perfectly for the last couple of days. most confusing.

if anybody has had this issue, they can update the script in their WSH panel with this....

http://pastebin.com/f2cb8a7c7 (http://pastebin.com/f2cb8a7c7)

i've modified it to retry updating the playcount upto a maximum of 3 times. the most i've seen it take is 2 attempts. i've set it to output how many tries it takes to the foobar console.

Quote
Playcount sync: Contacting Last.fm....
Playcount sync: Last.fm responded 'OK'
1
2


edit: pastebin link updated.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Hitchhiker427 on 2010-02-16 20:59:44
I've seen this.  I fixed it by having the script check if the entry is blank every 5 seconds after the first update.

Code: [Select]
if (time > 15 && time % 5 == 0 && fb.TitleFormat("%LASTFM_PLAYCOUNT_DB2%").Eval() == "?") sync();

I've seen it take more than 3 tries.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Cabalist on 2010-02-16 21:00:21
Never had this issue, updated the script anyway.

Btw, is there any chance that you might include the "add_one" feature again? Right now I edit it in myself, but am wondering why you removed it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-16 21:28:39
@Hitchhiker427, perhaps you should try my update. there's no need to fetch the data from last.fm repeatedly.  mine retries instantly. you can always modify how many attempts it takes if 3 isn't enough. (line 108)

@Cabalist, i was too lazy to implement that option when i switched everything over to be set via the context menu instead of having people edit the scripts. i might put it back in at some point.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Hitchhiker427 on 2010-02-16 22:03:51
Ok, I'll give it a shot.  Yeah, fetching the data every retry is pretty inefficient.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-16 22:21:04
i'd be interested to see the maximum number of retries attempts needed. during my testing i've only needed a 2nd attempt. just check your console every now and then.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: dalover on 2010-02-16 22:44:04
The highest number I've seen so far, was a one.
I will continue to look at the console.

thanks
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-16 22:47:35
just to clarify, the number in the console is the number of attempts, not retries. it should always show 1 when it's working as normal. sorry for the confusion.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Cabalist on 2010-02-17 11:57:30
Quote
i'd be interested to see the maximum number of retries  attempts needed.

Played music for nearly 8 hours after updating your script, never needed more than 1 attempt to update the playcount according to the console output.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-02-17 13:59:18
thanks.... but you did say you never had the problem originally...

anyway

new main version uploaded (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/playcount%20sync.zip)

-hopefully fix the issue of playcounts not being updated in the previous version. (just the new "playcount sync.txt" needs to be imported)
-updated documentation so people who use foo_customdb for other purposes can manually update their database to work with this script. this was impractical with earlier versions because i had over 40 entries. now there are just 5.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: manaox2 on 2010-02-25 02:19:38
Thanks for this, I'm just so happy to not rely last.fm app any longer. It works great!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Sparanoid on 2010-03-06 10:29:13
http://blog.99ravens.net/index.php?e=283 (http://blog.99ravens.net/index.php?e=283)

Custom Database 0.1.0 beta1 (foo_customdb.dll) for new sdk is released. 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-03-06 15:15:41
yep, noticed that yesterday (thanks to Yirkha's update component). i've already bundled it into the download.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: スラッシュ on 2010-03-07 14:16:03
I am here to ask for help again

I'm a fool and updated playcount sync despite it working perfectly for me already--and of course, in updating, everything broke. Duh... Lesson learned: never update something unless your current version is buggy or missing features that you need.

Anyway, I managed to restore almost everything using the playcount sync old.zip file that you graciously provided (thank you for that! I was an even bigger idiot and overwrote the old script I had), but I still have one minor thing that is really driving me up the wall:

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-03-07 14:44:12
well it's not the script because even if you clear it, the panel still won't resize as small as it used to. 

edit: a possible workaround is to hide the toolbars and then create your own horizontal splitter with the columns UI toolbars in. that way, you can resize the WSH panel.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: スラッシュ on 2010-03-07 14:57:48
That's a good workaround, thanks!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: unclean on 2010-03-10 02:53:13
I made a couple small changes.

lines 142-3, 147-48
Code: [Select]
          
            if (api_key != null) {
                on_metadb_changed();
                window.NotifyOthers("lastfm_update", 1);
            }


Otherwise it throws a script error if you hit the cancel button with an empty input box.

in on_metadb_changed():

Code: [Select]
        case (fb.TitleFormat("$strcmp($left(%path%,7),'http://')").EvalWithMetadb(g_metadb) != 0):
            n = "love.png";
            h = "exclamation_h.png";
            tooltip = "Unable to love!";
            func = null;
            break;


Disable on radio streams since softplaylists doesn't seem to work with dynamic metadata. Not the best way to do it probably but it works.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-03-10 03:10:30
Otherwise it throws a script error if you hit the cancel button with an empty input box.


i can't re-produce that. cancelling the input boxes even when empty doesn't cause any problems here. can you elaborate? i assume the script was un-modified before you noticed this?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: unclean on 2010-03-11 23:12:20
I can't reproduce it anymore either, but oddly enough it happened every time on the RC of Windows 7. I didn't bother to try it on the release version because I had no idea that it would make a difference, sorry about that.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: revenant on 2010-03-23 09:37:52
Does this script use foobar2000 proxy setting?
I can't fetch anything being behind proxy.
No related messages in console, no errors.
All other internet-related components work fine.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-03-23 09:49:06
as it's using ActiveX objects, i'd assume that it uses Internet Explorer's proxy settings.

i honestly don't know for sure though. maybe someone more knowledgeable will read your post and be able to answer that for you.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: revenant on 2010-03-25 10:48:08
According to last.fm I have 1,025 Loved Tracks, but I got only 432 in playlist.
Is there some limitation in last.fm or soft playlists component?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Xengrid on 2010-03-30 15:44:54
Nice plugin, I like it very much.

However, there is a small annoyance that happens in my case at least. Every time when you listen to track you have scrobbled at least once and when the plugin syncronizes stats with Last.fm (while music is playing), there is a very small pause -  taskbar icon even shows message "unpaused" when this happens. Is there any way to get rid of this, since it cuts music during this duration and is clearly audible?

My foobar version is 1.0 and the plugin components are those that are currently in the first post's zip-file.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-03-30 15:59:06
my script does actually pause playback and then restarts it. see here for explanation:

http://www.hydrogenaudio.org/forums/index....st&p=687768 (http://www.hydrogenaudio.org/forums/index.php?showtopic=76772&view=findpost&p=687768)

it *should* be totally inaudible. it is to me and no one else has mentioned it but i guess it really is a problem for you.

that code in the quote above should be on line 104. you can comment it out but your playlist may not update as you listen.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Xengrid on 2010-03-30 16:21:41
Ok, thanks. This "fixed" it.

I also found out that this very small pause is only audible when I use WASAPI-output (sounds like a small pop error on recording etc.) - with DS there is no *audible* pause at all.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: phunkydizco on 2010-04-01 08:16:20
Is it possible to get the playcount stats form Last.fm for a whole album without listening to it?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-04-01 11:26:24
no. well not using this script anyway.

from the readme file:
Quote
What it doesn’t do:

If you’re looking for something to update albums/playlists/libraries/multiple files all in one go, this is not the tool for you. The component I use to fetch Last.fm data (WSH panel mod) can only work with one file at a time. It automatically updates the stats of the currently playing file only. You just “set it and forget it” and it will slowly update your collection as you play it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: phunkydizco on 2010-04-01 11:38:24
so it is not possible to modify the script because WSH panel mod doesn't has access to all selected tracks in the playlist view? perhaps there is another way to do that?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-04-01 11:51:21
correct, not at all possible using this script.

having said that someone did post earlier about leaving foobar playing your whole library and modifying the script so it skipped to the next track when the playcount for the current track had been fetched. this could take awhile depending on the size of your collection.

also, someone else mentioned songbird + some extension could pull playcounts for your whole library. i haven't tried it myself though.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: phunkydizco on 2010-04-01 12:06:25
That would be a funny workaround. But I don't like Songbird, foobar is the best player, exceptionally with your script.

One thing I am missing is that the DB value LASTFM_PLAYCOUNT_DB2 doesn't update when a track was completely played and scrobbled with foo_audioscrobbler (http://www.hydrogenaudio.org/forums/index.php?showtopic=44320). Is it possible to update the DB value when a track was scrobbled? Could you code this?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-04-01 12:17:39
foo_audioscrobbler doesn't actually submit until the track has stopped. and as it no longer has focus and i can't do anything with it.

again, some people have worked around this by simply adding 1 to the playcount fetched from last.fm when the stats are usually updated after 10 seconds playback.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: phunkydizco on 2010-04-01 12:34:09
You could remember the last track and when the current track is updated after 10 seconds you could update the last track as well. When the last track was scrobbled the playcount should be right. When the script inside the WSH panel stays inside memory this should be very easy with two variables.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-04-01 13:16:00
the track has to be playing or selected. you can't just "remember" the last one.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: phunkydizco on 2010-04-01 13:34:52
That is not right what you are saying. I have modified the script with a few variables and functions and I could "remember" the previous track and update the playcount for it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-04-01 13:36:28
you carry on then. what are you asking me for?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: phunkydizco on 2010-04-01 14:00:18
Sorry man. I wanted to have a look by myself. Is it possible to debug the script inside the WSH panel? It is not so easy to code this as I thought.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-04-01 15:22:43
you can use fb.trace to output stuff to the foobar console.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: phunkydizco on 2010-04-03 12:04:40
I have modified your script, that the playcount is increased in the db at the end of the track. Sorry that I annoyed you with that.

Where did you get the nice icons for youtube, myspace and last.fm from? I need some in the same style for wikipedia and discogs.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-04-03 20:45:22
i got the images from komodomedia.com - there are no wiki/discogs icons. it's all this new fangled social networking nonsense

http://www.komodomedia.com/blog/2009/06/so...work-icon-pack/ (http://www.komodomedia.com/blog/2009/06/social-network-icon-pack/)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: rafib on 2010-04-10 13:25:52
Hey @marc2003,
a little off-topic, but how do you make the thin separator lines disappear ?

Attached is a picture
(http://atraxia.com/rafi_fb2k.png)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Gapkiller on 2010-04-10 13:30:11
Hey @marc2003,
a little off-topic, but how do you make the thin separator lines disappear ?


I'm pretty sure that he used panel stack splitter to do that.

http://foo2k.chottu.net/ (http://foo2k.chottu.net/)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: muzack on 2010-04-23 10:48:51
hello,
maybe this is a stupid question, but if the script is able to get the lfm playcount on play a track, would it be possible to start looping through the whole lib slowly (because of request limitation), to add the playcount automaticly?

Anyway, thanks for that extension!
cheers
marcus
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-04-23 13:25:10
i'm currently working on a script that will pull all your stats from lastfm at once. it'll be a few days as there are a few things i don't how to do yet.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Fractal_Mortality on 2010-04-23 16:09:13
Yay!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-04-23 16:44:39
i have a test version i'd like people to try. this fetches playback stats for the whole last.fm library. there is no way for me to check if the track exists in your foobar library - a record will get created in foo_customdb regardless.

you should use a clean portable install as the database isn't compatible with the old version. components not included - you'll need foo_customdb and wsh panel mod....

http://cid-649d3bfeaf541fbb.skydrive.live....ount%20test.zip (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/playcount%20test.zip)

-extract the scripts folder into the main foobar directory
-place the file foo_customdb.dll.cfg in the configuration folder
-import the file lib sync.txt into a WSH panel
-you need to set your username and api_key in the script itself
-you'll need the playlist configured with a custom column the same as before [%LASTFM_PLAYCOUNT_DB2%]

it's just a blank panel - you trigger it via the context menu. you can watch it's progress in the console - it takes awhile. the only way to cancel it is to open the WSH panel dialog and then close it again.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: muzack on 2010-04-23 17:02:45
wow, thanks.
could you please explain why using a portable install?
that's a bit unclear to me right now.
can't I use my current customdb_sqlite.db?
or should I copied it to the portable location?

thanks marcus
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-04-23 17:06:40
the reason i suggested using a portable install is for existing users to test it and check the playcounts returned matched the playcounts displayed by the old version.

you can use this with a normal install if you like - the only difference is that the configuration folder is inside

%appdata%\foobar2000

once it's (hopefully) confirmed as working for a few people i'll merge it into the old version so it can continue updating in the background/fetched loved status etc.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: muzack on 2010-04-23 17:34:00
ok, I used the fresh new portable install with wsh panel mod + custom db + your custom db cfg
setup a new lib and import the script into wsh panel

after hitting ok I get an error and console say:

Code: [Select]
WSH Panel Mod (GUID: DDBCD92F-7C1A-4ADF-9C71-C2F849AA9E19): Parsing file "C:\Users\mo\Desktop\foobar2000\scripts\marc2003\v2\common.js"
Error: WSH Panel Mod (GUID: DDBCD92F-7C1A-4ADF-9C71-C2F849AA9E19): Laufzeitfehler in Microsoft JScript: (Runtimeerror in Microsoft JScript)
Automatisierungsserver kann Objekt nicht erstellen.
Ln: 237, Col: 1
<source text only available in compile time>


hope I did everything right or did I miss something?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-04-23 17:42:35
you need to disable WSH panel mod safe mode.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: muzack on 2010-04-23 17:49:57
oh, thanks.
now I stuck on this

Code: [Select]
477 pages found 
Processing page 1
Error: WSH Panel Mod (GUID: DDBCD92F-7C1A-4ADF-9C71-C2F849AA9E19): (null):
(null)
Ln: 37, Col: 4
<source text only available in compile time>


I am running foobar as admin in win7

EDIT: sorry, sqlite3.exe was not present in foobar folder.... no errors right now - processing pages
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-04-23 17:56:05
oops, yet something else i forgot to mention.

right now, i'm having major problems with ESPlaylist. the database isn't getting updated for some reason. i've had no problems with the DUI playlist view or ELplayist in columns UI.

EDIT: test version removed. i'll try and make it update the database in one query rather than once per track. it's too slow. 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: muzack on 2010-04-23 18:25:10
I played a bit with the script.
On first run it fills the DB then it stopped to fill the db but run without errors.
I traced the data and query1 var.

It looks like this:

Code: [Select]
Akron/Family,Of All the Things,28 
"INSERT OR REPLACE INTO quicktag(url,subsong,fieldname,value) VALUES(\"\",\"-1\",\"LASTFM_PLAYCOUNT_DB2\",\"28\")";
Port O'Brien,Valdez,28
"INSERT OR REPLACE INTO quicktag(url,subsong,fieldname,value) VALUES(\"\",\"-1\",\"LASTFM_PLAYCOUNT_DB2\",\"28\")";
Akron/Family,Love, Love, Love (everyone),28
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-04-23 18:30:27
foobar has to be playing for it to work. i've already removed the download as it's too problematic at the moment.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: muzack on 2010-04-23 18:37:28
ah ok - now it's working here.
for now it's a smart start for me, to find out more about scripting
fb.trace("hello world") haha
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: muzack on 2010-04-23 19:17:13
I've modify your script a bit and collect the querys to bulk write them at end of every page loop.
maybe it's quick and dirty but it seem to work and it's not so slow like write it for each record.
Could it be possible that the script stop if track is changing?
Anyway it still takes time ^^.
I just let it run right know...
cheers m.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-04-23 23:06:26
EDIT: OH FFS. ran into another problems i can't fix. i suck 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: muzack on 2010-04-24 12:05:00
Hey, I wasted some time yesterday and played with your script, as far as I understand it.
I synced my lib to 80% the rest I try to sync with your track by track sync script.
I mean this is a one time task to sync a library with lfm.

I understand, that syncing the whole lib may not very easy.
For example:
I had too loop through 477 pages.
The script always stopped at Page 188 and I had to modify the startnumber in Script to 189.
I don't know why - maybe because of faulty data...
I run the script twice and everytime new tracks were added to database which are not added on first run.
So for unknown reason, tracks were skipped.
Sometimes the script just stopped working. Don't know why.

Second thing is, looping through lfm to fill the db may fill a lot of titles that not in my mp3 lib anymore.
Other way around would be better.

I think about using the custom db internal playcount, after filling the db with lfm data.

Anyway - thanks for your work so far ;-) I've learned a bit.
I just need to find out how to add more buttons/functions to use that youtube stuff and so on. can I paste the scripts in one wsh panel and just need to adjust the buttons? or do I need x wsh panels for each script?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-04-24 12:28:58
my new version runs while foobar is closed so you shouldn't have any more skipped records. it parses all the results pages from last.fm first and then saves the query to an external file which is then triggered.

unfortunately there is no way for me to only find tracks that are in foobar's library - i have to write the whole last.fm library into the database.

although i've got it working now, i'm having serious performance issues in windows 7. even with my tiny collection of 1600 odd tracks it's taking over 2minutes. in XP SP3 it takes 18 seconds.

if anybody with a huge collection can share their last.fm username, i'll test to see if the script can handle it all in one go.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-04-24 13:09:15
The script always stopped at Page 188 and I had to modify the startnumber in Script to 189.

that was a problem with malformed XML on the last.fm site - but it's my fault for not handling it properly. that's now fixed and i can pull the data for all pages without a problem. unfortunately, you do do lose the 50 records for every page it can't read. my external SQL file was created fine so now i'm about to test how long it takes to import.

EDIT: with the help of another forum, i've been benchmarking sqlite performance and it's seriously fubared on windows 7 x64.

EDIT2: no it's not a problem with sqlite. it's my non existant knowledge that is the problem. now solved. it takes barely a second now.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: BrutuZ on 2010-04-25 03:23:40
Just tried the "full sync" script on a clean install, seems to have worked fine, but i wonder why were the Table name changed to "LASTFM_PLAYCOUNT_DB" (without 2) and the $lower() fnction added to the key. Gets a little messy when you try to import the full sync DB into the regular script one since the CRCs won't match

EDIT: nvm, i got the point of the $lower() funtion, really makes sense, less chances of duplicates this way  , just wonder if there's a way to convert the current values to the new CRCs (you know, just to be on the safe side, in case some faulty XML page contains tracks that you already fetched the old-fashioned way)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-04-25 03:55:49
i can only assume you've browsed my skydrive space for the full sync script as i haven't posted a link. it's not quite ready for a full release yet. i need to completely overhaul the instructions which i absolutely hate doing. i'll be merging it all into the main script linked to in the opening post. it will be recommended that users delete their old database. (it's not absolutely essential but it means it will contain loads of orphaned records which is a waste)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: BrutuZ on 2010-04-25 04:51:20
Guilty  , I did search the skydrive space, i assumed it'd be easier to find there than scavenge the link among all the topic pages. Seems I shouldn't have though, sorry about that  . Shame about the old databases, would be nice if there was a way to re-export the values to comply with the new CRC (maybe sorting the library by %LASTFM_PLAYCOUNT_DB2% and then assigning %LASTFM_PLAYCOUNT_DB% the same value as %LASTFM_PLAYCOUNT_DB2% through a CustomDB action?  )
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-04-25 14:55:37
i've tested your user ID and there weren't any problems. i've found a few more usernames to test who have more than 50,000 tracks in their last.fm libraries and there weren't any problems with those either. but it can take awhile depending on the size of your collection. i haven't done exact timing but it's around 50 pages (2500 tracks) per minute. i guess connection speeds and last.fm server response times may vary for each person though.

i'll post it later on when i can finally be bothered to do the readme. 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: muzack on 2010-04-25 16:59:59
hi,
just to add my experience with marc2003 forthcomming script.
It works very nice, lfm download need some time, but thats no problem.
Because I am using custom_db for some other values, I didn't want to use a new clean db, so I cleaned it by myself, with
http://sqlitebrowser.sourceforge.net/ (http://sqlitebrowser.sourceforge.net/) and a simple SQL Query to remove the previous downloaded LFM playcounts
Code: [Select]
DELETE FROM quicktag WHERE fieldname = 'LASTFM_PLAYCOUNT_DB2'

Then compact the db and run the new script.

I tried to clean up orphaned records with the plugin build in tools, but foobar freeze - don't know how long it takes or if this function is buggy?
cheers
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-04-25 18:19:23
you could have used the old "Customdb Delete Playcount" action on the context menu before updating it with the new settings. oh well.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-04-25 20:31:23
ok, new main version uploaded. same link as first post

http://cid-649d3bfeaf541fbb.skydrive.live....ount%20sync.zip (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/playcount%20sync.zip)

-import whole last.fm library at once. please read the documentation carefully
-still has the same features as the old script to update as you play/love tracks/etc
-not compatible with old version so please read instructions as if you are a new user
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: isosceles294 on 2010-04-25 20:53:36
ok, new main version uploaded. same link as first post

http://cid-649d3bfeaf541fbb.skydrive.live....ount%20sync.zip (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/playcount%20sync.zip)

-import whole last.fm library at once. please read the documentation carefully
-still has the same features as the old script to update as you play/love tracks/etc
-not compatible with old version so please read instructions as if you are a new user


thanks for all of your work, the script works great! I've been looking for something to do this for a while now
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: BrutuZ on 2010-04-25 23:54:44
Any chances to have an option to sync all Loved tracks at once too? Nvm, there were so few tracks that it was easier to set the Loved status manually searching the library
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: eikaramba on 2010-04-26 00:10:37
hey marc2003,

i got a little problem, in the old version either the new one. My Problem is, that he didn't update the lastfm playcount from songs, that are already in the customdb database.

for example:
i play the song and this is what he calls for the WshShell.Run Command:
Code: [Select]
sqlite3.exe "D:\Media\foobar2000\\"customdb_sqlite.db "INSERT INTO quicktag(url,subsong,fieldname,value) VALUES(\"930765360\",\"-1\",\"LASTFM_PLAYCOUNT_DB\",\"8\")";


The real interessting part is, that with an SQL Viewer like the firefox addon sqlitemanager i tried to UPDATE the record, instead of insert a new one, because this fails also in the sqlite viewer for the customdb database.

But when i run the following command:
Code: [Select]
 "UPDATE quicktag SET value='15' WHERE url='930765360' AND fieldname='LASTFM_PLAYCOUNT_DB'";


it works. Mhm okay, lets try this with sqlite3.exe

and i run this in the cmd shell:
Code: [Select]
sqlite3.exe "D:\Media\foobar2000\\"customdb_sqlite.db "UPDATE quicktag SET value=\"9\" WHERE url=\"930765360\" AND fieldname=\"LASTFM_PLAYCOUNT_DB\""


Guess what? That works 100%, he updates the database and in foobar i see the new value (of course i have to refresh the playlist panel)

So i tried to get this working in foobar and ended with this little snippet:

Code: [Select]
if(fb.TitleFormat("%LASTFM_PLAYCOUNT_DB%").EvalWithMetadb(g_metadb)>0){
                    var query1 = '\"UPDATE quicktag SET value=\\"' + userplaycount + '\\" WHERE url=\\"' + crc32 + '\\" AND fieldname=\\"LASTFM_PLAYCOUNT_DB\\"\";';
                    WshShell.Run("sqlite3.exe \"" + fb.ProfilePath + "\\\"customdb_sqlite.db " + query1, 0, true);
            }else{
                while(fb.TitleFormat("%LASTFM_PLAYCOUNT_DB%").EvalWithMetadb(g_metadb) != userplaycount && attempt <=3) {              
                    var query1 = '\"INSERT quicktag(url,subsong,fieldname,value) VALUES(\\"' + crc32 + '\\",\\"-1\\",\\"LASTFM_PLAYCOUNT_DB\\",\\"' + userplaycount + '\\")\";';
                    WshShell.Run("sqlite3.exe \"" + fb.ProfilePath + "\\\"customdb_sqlite.db " + query1, 0, true);
                    attempt++;
                }
            }


But unfortunately that doesn't work and i don't know why, it seems that he's not starting sqlite3.exe at all, because if i run this command exactly manually from the cmd shell, everything works. I just wonder myself why you don't update the database, i mean, if you insert a new record he seems to return a error, well .... at my computer

hope you can help me or that you have an idea of whats going on.

PS:Tried the last version of your config, your new "get all lastm data" script works really great, but he does not update the files.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Fractal_Mortality on 2010-04-26 00:40:36
So marc..... I'm sure I'm in the minority of wanting this here but... Is there any way to make your scripts actually write tags instead of using customdb anymore 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-04-26 01:00:26
Any chances to have an option to sync all Loved tracks at once too? Nvm, there were so few tracks that it was easier to set the Loved status manually searching the library

you can use foo_softplaylists to generate a playlist of your loved tracks (Library>Last.fm Loved tracks>user). then simply highlight, right click and choose "Legacy commands (unsorted)>Customdb Love 1".

@eikaramba - i have no idea what you're doing. i'll try and digest your post tomorrow when i have a little less alcohol in me.

@Fractal_Mortality - if you need file tagging support there's no reason to stop using the original version. although it's old, the only changes have been foo_customdb related. i can't tag files using this new library import method even if i wanted to. but you could use the foobar properties dialog and "format from other fields" to transfer database records to tags.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Fractal_Mortality on 2010-04-26 05:52:33
I can't tag files using this new library import method even if i wanted to. but you could use the foobar properties dialog and "format from other fields" to transfer database records to tags.


Good strategy, I think I will do this and just retain my older version of your script (seeing as how import library is really only a one time deal anyway  )
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-04-26 10:15:25
eikaramba, the reason i don't UPDATE is because the database is locked when foobar is running. i hack around this by deleting the playcount record for the current track and then INSERT should work (it still fails on very rare occasions - i'm talking maybe a few times a month playing 70 tracks or so a day which isn't that bad really).
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: eikaramba on 2010-04-26 12:46:41
hey marc,

i found the problem!!!

As is said, my foobar didn't update the playcounter and now when i noticed that you first delete the record and then insert a new one, i thougt maybe he just don't execute the delete command. Well in the past I deactivated the context menu for the "Legacy Commands", because i dont need them in the context menu, but without visible they seems to not working. So the solution was to reactivate them in the context menu and now the delete&insert command works.

Maybe this help some people.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-04-26 13:38:43
maybe i'll add that to the readme - don't hide context menu items.

could a mod completely replace the opening post with the following text:

UPDATED 26th April 2010

this isn't a proper a component but a script that utilises WSH panel mod (http://www.hydrogenaudio.org/forums/index.php?showtopic=70363), foo_customdb (http://blog.99ravens.net/index.php?e=283) and foo_softplaylists (http://www.hydrogenaudio.org/forums/index.php?showtopic=76133)

features:

-script runs inside a WSH panel which is supported in both default UI and columns UI
-import your last.fm library playback statistics into foobar in one go
-uses foo_customdb so your file tags won't be touched
-automatically updates stats in the background as you play more music
-also stores last.fm loved track status
-uses foo_softplaylists to love tracks via a button

full instructions can be found here. please read carefully.

http://cid-649d3bfeaf541fbb.skydrive.live....ount%20sync.zip (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/playcount%20sync.zip)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: dankine on 2010-04-27 12:12:39
Installed this all yesterday, followed instructions to the letter. It is all working bar the on the fly playcount update. I play a track (Can see the ok response from lfm in the console) yet the playcount does not update. I can do "create and import SQL file" each time I want it updated but would really prefer for it to be auto. Any ideas what may be going wrong?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-04-27 13:03:34
it won't increment on the first play after an import because the playcount is still the same. a play isn't scrobbled until you've finished listening to a track.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: dankine on 2010-04-27 13:10:37
oh i apologise, i think i understand now. the playcounts will always be one behind lfm?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-04-27 13:48:49
at the time the sync occurs, the playcount will the same as last.fm. but at the end of the track when that play is scrobbled, it will be 1 behind.

minor update:

http://cid-649d3bfeaf541fbb.skydrive.live....ount%20sync.zip (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/playcount%20sync.zip)

--documentation updated with the following info
how to use foo_softplaylists to import loved track status for the whole library
explanation of why playcount won't increment immediately after library import

--playcount sync.txt updated (the file which you import into a panel). it now outputs a console message when the playcount hasn't changed.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: BrutuZ on 2010-04-28 18:51:01
Maybe it's worth mention to anyone (like me) that feels bothered by the fact the playcount displayed is always 1 unity behind Last.fm after the track is played and scrobbled, that you can change that with a simple mod on "playcount sync.txt" (or the imported code itself inside WSH panel config). All that is needed is add a pair of + in the code so that line 96:
Code: [Select]
try { userplaycount = xmlDoc.getElementsByTagName("userplaycount")[0].childNodes[0].nodeValue; } catch(e) { userplaycount = 0;}
becomes
Code: [Select]
try { userplaycount = ++xmlDoc.getElementsByTagName("userplaycount")[0].childNodes[0].nodeValue; } catch(e) { userplaycount = 0;}
The downside on doing that is that the increment will occour after 10 seconds of play (unless you change the value on line 74).
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-04-28 21:30:21
i've just noticed that foo_softplaylists can only fetch up to 1000 loved tracks (the default is 500 so you have to change this in it's preferences). are there any people who have more than 1000? if there are, make yourself heard and i might add an option to fetch the records myself, bypassing this limitation.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Fractal_Mortality on 2010-04-29 01:00:38
*raises hand* 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: dutch109 on 2010-04-29 02:14:45
Just spotted a bug (or is it a problem on my side ?) since I updated to the last version of your script :

When I click on "Visit your Last.fm user profile page", I get this in the console :

Code: [Select]
Error: WSH Panel Mod (GUID: 47866B82-E515-452D-A530-BFF018766B4C): (null):
(null)
Ln: 206, Col: 4
<source text only available in compile time>


Everything works perfectly apart from that.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-04-29 02:33:21
that would seem to indicate there is a problem with your system handling the default action for "http://..." links. have you got a default browser set ok? what happens if you go to start, run and type in

http://google.com (http://google.com)

anyway, to stop the script from crapping out. on line 206, replace this

Code: [Select]
      
WshShell.run("http://www.last.fm/user/" + encodeURIComponent(username));


with

Code: [Select]
            try {
                WshShell.run("http://www.last.fm/user/" + encodeURIComponent(username));
            } catch(e) {
                fb.ShowPopupMessage("Unable to launch your default browser.", "Playcount Sync");
            }


i'll put this in the next update as well.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: dutch109 on 2010-04-29 02:44:37
Weird, I just restarted Firefox and now it works. 
I don't have any other browser so I don't see what could have changed the HTTP protocol association.

Anyway, thanks for your quick answer.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-04-29 05:08:54
new version uploaded

http://cid-649d3bfeaf541fbb.skydrive.live....ount%20sync.zip (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/playcount%20sync.zip)

-imports loved track status automatically at the same time as playcount. there are no limits to the number of loved tracks. unfortunately this has a required an update to the db structure so existing users (since the import script update) will need to delete their database and overwrite foo_customdb.dll.cfg again and of course import the new playcount sync.txt into their WSH panel.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-04-30 17:21:18
another new version, same link as above.

-changes made to the panel script only. automatic updating now adds 1 to the returned result. instead of running after 10 seconds, it now runs at either half the track length or 4 minutes - whichever comes first. this is part of the the guidelines for having a play "count" set by last.fm so even though i'm manipulating data, it should be accurate when the track has finished playing.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: the_miker on 2010-05-03 17:08:08
This script is perfect, thanks!

I have one question/request though.  Would there be any way to get artist names that are non-English to download from the API as their translated names rather than their names in the original language?  For example, Nobuo Uematsu is actually 植松伸夫 on Last.fm (see here (http://www.last.fm/music/%E6%A4%8D%E6%9D%BE%E4%BC%B8%E5%A4%AB)) and that's how the API downloads the stats, as 植松伸夫 and not his English name.  My artist tags for him are all in English so the play counts and loved status don't import (because there's no way to tell fb2k that 植松伸夫 and Nobuo Uematsu are actually the same artist).

Does that make sense?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-05-03 19:26:13
like i said in the readme file, all i can do is match tags. but you could see if the "artist translation" option on this page helps. i have no idea if it will or not.

http://www.last.fm/settings/website (http://www.last.fm/settings/website)

also, if you turned off spelling correction, i think that would force all plays to be counted against your tags exactly as they are. so the above artist would end up here..

http://www.last.fm/music/+noredirect/Nobuo+Uematsu (http://www.last.fm/music/+noredirect/Nobuo+Uematsu)

i'm not sure how those 2 options would work together though.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: n0obie4life on 2010-05-03 20:13:24
This script is perfect, thanks!

I have one question/request though.  Would there be any way to get artist names that are non-English to download from the API as their translated names rather than their names in the original language?  For example, Nobuo Uematsu is actually ???? on Last.fm (see here (http://www.last.fm/music/%E6%A4%8D%E6%9D%BE%E4%BC%B8%E5%A4%AB)) and that's how the API downloads the stats, as ???? and not his English name.  My artist tags for him are all in English so the play counts and loved status don't import (because there's no way to tell fb2k that ???? and Nobuo Uematsu are actually the same artist).

Does that make sense?


You could use the similar() function I posted in the thread. It works perfectly fine for me when fixing such problems. I refuse to turn off spelling correction...so.

http://www.hydrogenaudio.org/forums/index....st&p=687610 (http://www.hydrogenaudio.org/forums/index.php?showtopic=76772&view=findpost&p=687610)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-05-03 20:27:33
^i must confess, i forgot about your workaround that you mentioned earlier in the thread.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: the_miker on 2010-05-03 21:19:05
like i said in the readme file, all i can do is match tags. but you could see if the "artist translation" option on this page helps. i have no idea if it will or not.

http://www.last.fm/settings/website (http://www.last.fm/settings/website)

also, if you turned off spelling correction, i think that would force all plays to be counted against your tags exactly as they are. so the above artist would end up here..

http://www.last.fm/music/+noredirect/Nobuo+Uematsu (http://www.last.fm/music/+noredirect/Nobuo+Uematsu)

i'm not sure how those 2 options would work together though.

This is so confusing.  Not only am I dealing with translating, but once a name is translated, it's an artist redirect as well.  I think that's where I'm getting confused.

I turned off spelling correction temporarily and rebuilt/redownloaded the database from your script ("Create and import SQL file") and I suddenly had a lot more loved tracks showing up in fb2k.  Didn't do what I wanted though, because now if I love a track from fb2k that has a redirected artist (let's say Beatles -> The Beatles, to keep it simple), it will love the track by the non-redirected artist (Beatles) and not the properly corrected one (The Beatles).

You could use the similar() function I posted in the thread. It works perfectly fine for me when fixing such problems. I refuse to turn off spelling correction...so.

http://www.hydrogenaudio.org/forums/index....st&p=687610 (http://www.hydrogenaudio.org/forums/index.php?showtopic=76772&view=findpost&p=687610)


I added everything from your post to the script but I'm not sure what this does exactly, even though it does sound like something I'd want.  Using my example above, would your fix make it so if I loved a track from "Beatles" in fb2k, it would actually love that track from "The Beatles" instead, because "The Beatles" is the #1 similar artist to "Beatles"?  And if so, would my %LASTFM_LOVED_DB% and %LASTFM_PLAYCOUNT_DB% be updated accordingly?

I'll say it again, this is confusing the hell out of me, haha.  I'm pretty sure this would all be a non-issue if Last.fm started merging artist pages instead of just redirecting, or "correcting."
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-05-03 22:23:35
yup, tis very confusing indeed. this is my take on what's going on the moment.

your files are tagged as Nobuo Uematsu but gets auto corrected by last.fm to 植松伸夫 when you scrobble (or love a track). when you import the whole library from last.fm, all the entries will be under 植松伸夫 so of course they won't show in foobar because of the tag mismatch.

now when you play a track, the auto update feature uses a different last.fm feed and this simply uses the tag data found in your files. in this instance it will look up Nobuo Uematsu against your username and will find no entries and so return nothing. this is where n0obie4life's workaround should come in handy for you. but there is no realistic way you could use that feature when importing your whole library. i guess at this point large chunks of your library will be missing data but it will get updated eventually as you play more songs with it running in the background.

i can't say anything about the "artist translation" option because i've never used it. but if you turned off "spelling correction"  (which i would not recommend in your case), then all future last.fm scrobbles with Nobuo Uematsu tracks would count against this tag on last.fm. of course this would mean starting this artist again from 0 which you wouldn't want. but in this scenario both elements of my script would work fine.

your options:
1) what i'd recommend: leave your tags/last.fm options as they are. accept the gaps in your library and use n0obie4life's workaround for updating tracks as you listen
2) obey last.fm by adjusting your tags to match theirs
3) force them to obey you by turning off spelling correction. 

obviously 2 and 3 aren't very appealing.




Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: sylla on 2010-05-05 11:45:27
What do I need to do if I just want my last.fm played and loved stats synced once, and directly to the tags?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-05-05 13:43:37
you can't import into the tags directly so you'd need to follow all the steps in the guide to import the playcount/loved status into the database as usual. then you could transfer the data into file tags afterwards.

when the import is complete, assuming all your music is in the foobar library, open a Library>Search window (if not add, all your music to a single playlist and use Edit>Search)

%LASTFM_PLAYCOUNT_DB% PRESENT

now with all files highlighted, right click, properties. create a new tag by double clicking one of the empty boxes. click ok. now right click this newly created tag and select "Format from other fields". in the format box, type in

%LASTFM_PLAYCOUNT_DB%

then repeat the above step for %LASTFM_LOVED_DB%
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Mercenary09 on 2010-05-06 18:06:30
Hrm, I am pretty bad with anything to do with scripts, but I think it may be the mix of components I have, but foo_customdb.dll crashes for me. I am wondering if you know of a solution at all, but I suspect there's probably nothing I could do besides maybe stop using other components, if that's even the problem.
crash log for customdb.dll (1.0 beta, I think it is):  http://pastebin.com/qETsaqw7 (http://pastebin.com/qETsaqw7)

also errors (but these haven't crashed for me yet): http://help.foobar2000.org/troubleshooter/...ba43d13612b80e2 (http://help.foobar2000.org/troubleshooter/components/11a6e5e581d4a49d+cba43d13612b80e2)
A list of components I use: http://content.imagesocket.com/images/foob...mponents3d5.png (http://content.imagesocket.com/images/foobar.components3d5.png)

Any help is appreciated, but as far as it goes, I can still love tracks, but it won't show the silly icon without the customdb. Also.. more very minor problems, but I'm just going to be thankful it mostly works besides that crashing, haha. I think I messed up somewhere configuring.

---------- Below can be completely ignored if there's no way to stop customdb.dll from crashing, but if it can, if anyone likes to help >_>
Ah, also, if possible, but maybe just ignore this. Anyways, like you have the 1 heart in the screenshot for this, I guess I messed it up, either way I went with a work around. I just made 3 buttons with hearts and use one to love(to Last.fm), the other to display the heart in foobar columns, but I can't unlove a track with it. Actually, it's the Love 0 context menu, which just removes the heart, but I thought it would also unlove from Last.fm Puzzled
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: muzack on 2010-05-06 19:34:34
Just a hint, check all custom db action if they are mapped to an existing field.
I noticed crashes when an action (like Media Library (Modified)) tried to update a field which not exist anymore.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-05-06 20:40:58
i do find customdb unstable with it's default actions in place. that's why i removed them all in the foo_customdb.dll.cfg file i provide. i've not had a single problem with it. seems odd how it crashes in it's default configuration but has been rock solid with the abuse i give it. in older versions of this script, i used to run 7 actions at a time and it was fine.

@Mercenary09 - you can't unlove a track on last.fm with this script/foo_softplaylists. last.fm don't provide any way for us to do that. you have to use the website.

unfortunately i can't help with your component errors. like i said above, it's been rock solid for me. and there is no thread on these forums either. the developer doesn't post here.

the context menu options are only there because the script needs them to work. lets say you loved a track but later changed your mind and you used the website to unlove it, the script would detect this on the next play and remove it from the database.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Mercenary09 on 2010-05-06 20:56:56
Hm, that's fine. I guess unlucky for me I may keep getting crashes. Thanks for the reply, heh.

Just a hint, check all custom db action if they are mapped to an existing field.
I noticed crashes when an action (like Media Library (Modified)) tried to update a field which not exist anymore.


Just going to ask dumb questions since I am not sure.
Tools -> Custom Database -> Fields
Those fields, you mean? I think these are mapped, but beyond that, I'm not sure. Well, maybe more under the Action tab. Since I haven't editted anything in Custom Database, I think I may be unfortunate. I  just replaced the old .cfg with the one marc provided, but I think I was already using it. Just doing it to see if foobar will crash again now.

Anyways, it doesn't seem like it will crash. It usually would have crashed by now unless there is something more to what's making it crash.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: laite on 2010-05-09 14:36:57
First of all, I'd like to thank marc2003 for this wonderful script!

I was just wondering if it would be also possible to get total plays of album and artist somehow from last.fm to database? (for example, it would be something like "Bob Dylan (100 plays) / Blonde on Blonde (75 plays) / Just like a woman (10 plays))
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-05-09 18:44:14
it's certainly possible to get that info from last.fm. whether i can be bothered to implement it is another thing entirely.

i'll think about it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Skoromax on 2010-05-11 17:51:22
Hi.
Can i get some help with this great script. After i install it and do all the instructions, i don't have any playcounts, as well as in track properties there is no "LASTFM_PLAYCOUNT_DB", it works only for loved tracks, but track shows to be loved only after it was played about 50% (or it is supposed to be so?) And btw, playcounts should appear immediately or after playing track too?
When i pressed "Create and import SQL file" it showed  in console requests the script made.  Several times I tried installing this script every time precisely following instructions but still it doesn't work    I even made a clear install of Foobar with only column_ui, but still i get the same - no playcounts, only shows loved tracks. When playing song i can see the following in console:
Code: [Select]
Watching: F:\
WSH Panel Mod (GUID: FA707B22-3808-4B06-ACEF-725BF60B027B): Parsing file "C:\Program Files\foobar2000\scripts\marc2003\v2\common.js"
WSH Panel Mod (GUID: FA707B22-3808-4B06-ACEF-725BF60B027B): Parsing file "C:\Program Files\foobar2000\scripts\marc2003\v2\tooltip_buttons.js"
Custom Database: Initialize
Custom Database: table quicktag already exists (1)
Custom Database: table database_version already exists (1)
Custom Database: index url_idx already exists (1)
Custom Database: Completed
WSH Panel Mod (GUID: FA707B22-3808-4B06-ACEF-725BF60B027B): initliased in 0.0000278 s
Filter Panel - Genre: initialised in 0.010 s
Filter Panel - Artist: initialised in 0.071 s
Filter Panel - Album: initialised in 0.075 s
Startup time : 0:00.937253
Properties dialog refresh: 0:00.000049
Properties dialog display refresh: 0:00.001912
Opening track for playback: "F:\Mylène Farmer\2001 - Les Mots\09 - Je Te Rends Ton Amour.mp3"
Properties dialog refresh: 0:00.000045
Properties dialog display refresh: 0:00.001920
Playcount sync: Contacting Last.fm....
Playcount sync: Last.fm responded 'OK'

I have no ideas why it doesn't work 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Jeddix on 2010-05-11 19:04:02
Hi Marc,
first thanks for this script.

I have an idea for the damn auto correction at Last.fm: how about adding two tags to our files, maybe LASTFM_ARTIST and LASTFM_TITLE, where we could store the artist and title just like Last.fm expects us to.
My problem is that turning off the correction is not an option. And since my differences are mainly in the titles the workaround posted in this thread is not working either . I hate having the "(feat. ...)" in my titles but Last.fm sometimes redirect to these titles.

I hope this could somehow be implemented because it would solve my problem () and the problem with foreign names.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-05-12 09:25:36
additional tags? i don't think so. that would be a usability nightmare.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: BrutuZ on 2010-05-13 02:08:11
Besides the tag bloat for those who have the tags set according to lfm and/or don't mind having a few tracks displaying only the default DB playcount.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Jeddix on 2010-05-13 08:23:50
Besides the tag bloat for those who have the tags set according to lfm and/or don't mind having a few tracks displaying only the default DB playcount.


No, i would make them completely optional .
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Jeddix on 2010-05-13 14:06:34
Since it was a pretty small change I did it by myself .

Just change the following lines in on_metadb_changed()
Code: [Select]
    artist = fb.TitleFormat("%artist%").EvalWithMetadb(g_metadb);
    track = fb.TitleFormat("%title%").EvalWithMetadb(g_metadb);


to
Code: [Select]
    artist = fb.TitleFormat("$if2(%lastfm_artist%, %artist%)").EvalWithMetadb(g_metadb);
    track = fb.TitleFormat("$if2(%lastfm_title%, %title%)").EvalWithMetadb(g_metadb);


Now it will get the artist and title out of the LASTFM_ARTIST and LASTFM_TITLE tags if they are present.

But remember that this method is only working with live syncronization and not with the script that updates your complete library.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-05-19 13:28:00
for anybody still having problems getting this to work, i've bodged together a video showing the complete install process:

http://cid-649d3bfeaf541fbb.skydrive.live....obar/foobar.wmv (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/foobar.wmv) (15.7 MB)

(i forgot to install full font support for the ♥ but that's not really important for this)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Fractal_Mortality on 2010-05-21 06:49:33
Yo Marc, I recall awhile back you talking about implementing some sort of script that could grab more than 1000 loved tracks from last.fm (like soft playlists)... Do you still have any plans of doing this? Just curious.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-05-21 07:26:59
i did that ages ago.

new version uploaded

http://cid-649d3bfeaf541fbb.skydrive.live....ount%20sync.zip (http://cid-649d3bfeaf541fbb.skydrive.live.com/self.aspx/.Public/foobar/guide/playcount%20sync.zip)

-imports loved track status automatically at the same time as playcount. there are no limits to the number of loved tracks. unfortunately this has a required an update to the db structure so existing users (since the import script update) will need to delete their database and overwrite foo_customdb.dll.cfg again and of course import the new playcount sync.txt into their WSH panel.


i used your account for testing because i don't know anyone else with more than 1000 loved tracks.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Fractal_Mortality on 2010-05-21 08:08:57
ahhhh, ok. Thanks.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: wdekler on 2010-05-23 09:17:48
Would it be possible to submit the tracks played with foo_upnp to lastfm as well?

The latest version of foo_upnp now uses foo_playcount so maybe that opens up some possibilities.... 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-05-23 10:37:18
you're in the wrong thread. this has nothing to do with submissions.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: wdekler on 2010-05-23 17:43:01
you're in the wrong thread. this has nothing to do with submissions.



Whoops, sorry, you're right of course.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Steve Forte Rio on 2010-05-26 14:04:08
GREAT THANK YOU FOR FULL STATISTICS IMPORT FEATURE!

And little question: can I "love" tracks with DUI toolbar button instead of WSH panel button??
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-05-26 15:10:26
the "love track" feature is provided by foo_softplaylists so you can create a DUI toolbar button to do just that.

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: random_asdf on 2010-06-02 23:28:50
Similar problem but no idea if loved tracks works either since I don't have any.
I'm trying to use [%LASTFM_PLAYCOUNT_DB%] with elplaylist and wshpanel but nothing is returned.

Hi.
Can i get some help with this great script. After i install it and do all the instructions, i don't have any playcounts, as well as in track properties there is no "LASTFM_PLAYCOUNT_DB", it works only for loved tracks, but track shows to be loved only after it was played about 50% (or it is supposed to be so?) And btw, playcounts should appear immediately or after playing track too?
When i pressed "Create and import SQL file" it showed  in console requests the script made.  Several times I tried installing this script every time precisely following instructions but still it doesn't work    I even made a clear install of Foobar with only column_ui, but still i get the same - no playcounts, only shows loved tracks. When playing song i can see the following in console:
Code: [Select]
Watching: F:\
WSH Panel Mod (GUID: FA707B22-3808-4B06-ACEF-725BF60B027B): Parsing file "C:\Program Files\foobar2000\scripts\marc2003\v2\common.js"
WSH Panel Mod (GUID: FA707B22-3808-4B06-ACEF-725BF60B027B): Parsing file "C:\Program Files\foobar2000\scripts\marc2003\v2\tooltip_buttons.js"
Custom Database: Initialize
Custom Database: table quicktag already exists (1)
Custom Database: table database_version already exists (1)
Custom Database: index url_idx already exists (1)
Custom Database: Completed
WSH Panel Mod (GUID: FA707B22-3808-4B06-ACEF-725BF60B027B): initliased in 0.0000278 s
Filter Panel - Genre: initialised in 0.010 s
Filter Panel - Artist: initialised in 0.071 s
Filter Panel - Album: initialised in 0.075 s
Startup time : 0:00.937253
Properties dialog refresh: 0:00.000049
Properties dialog display refresh: 0:00.001912
Opening track for playback: "F:\Mylène Farmer\2001 - Les Mots\09 - Je Te Rends Ton Amour.mp3"
Properties dialog refresh: 0:00.000045
Properties dialog display refresh: 0:00.001920
Playcount sync: Contacting Last.fm....
Playcount sync: Last.fm responded 'OK'

I have no ideas why it doesn't work 

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-06-02 23:40:55
first thing to check, right click any track in your playlist and look under "Legacy commands (unsorted)". does it have 4 customdb related commands like this screenshot?

(http://k5sbdw.blu.livefilestore.com/y1pgrBOwEPYG6AtU132Jjw7sR9xO0Xm8DiNC3hggrMBNu9Q6exx9IAqgrtf2I8Dd2yDdS-5JRZFh1WMGy7MgYFGJOSHV7gz3gI-/lastfm%20context.PNG)

if not, then you didn't place the foo_customdb.dll.cfg file in the correct place. check the manual again making sure foobar isn't running while you do it.

if this looks ok then tell me exactly what you've done and where you're stuck at.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: random_asdf on 2010-06-02 23:49:28
Woops, sorry about that.
I thought I had placed it in my foobar appdata config folder but that was actually the autogenerated foo_customdb.dll.cfg. it works now.

Thanks

first thing to check, right click any track in your playlist and look under "Legacy commands (unsorted)". does it have 4 customdb related commands like this screenshot?

(http://k5sbdw.blu.livefilestore.com/y1pgrBOwEPYG6AtU132Jjw7sR9xO0Xm8DiNC3hggrMBNu9Q6exx9IAqgrtf2I8Dd2yDdS-5JRZFh1WMGy7MgYFGJOSHV7gz3gI-/lastfm%20context.PNG)

if not, then you didn't place the foo_customdb.dll.cfg file in the correct place. check the manual again making sure foobar isn't running while you do it.

if this looks ok then tell me exactly what you've done and where you're stuck at.

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Mercenary09 on 2010-06-06 14:51:49
so unluckily, the customdb_sqlite.db didn't update for me and after testing random things, I found out the file wouldn't, so I moved the old one and let a new one take its place it updated fine, but besides the

Quote
There is a 2nd context menu item labelled “Import SQL file”. This is a precautionary option that hopefully you won’t have to use. It’s only there in case the database update fails and it means you don’t have to download the data all over again.


is there a way to import the playlist count from the non-updating customdb? I noticed some files don't have the LASTFM_PLAYCOUNT_DB count when I imported them, but maybe it is because it's not correctly updating for me.

Quote
Couldn't load foo_custominfo DB: Playback Statistics Custom (0x0007)
Playcount sync: Contacting Last.fm....
Playcount sync: Contacting Last.fm....
Playcount sync: Last.fm responded 'OK'
Playcount sync: Playcount not updated. No changes found.
Playcount sync: Last.fm responded 'OK'
Playcount sync: Playcount not updated. No changes found.


Something is so messed up for me.. and it doesn't update counts after I restart foobar.

---

I may as well keep the old post. I guess it was my PlaybackStatistics.dat, so I just renamed it and let a new one be made. Yet, it seems eventually it stops updating. Eh, is my only option to delete the PlaybackStatistics.dat and customdb_sqlite.db?

---

It seems like it only adds the playcount once and it no longer updates which is the Playcount sync message, I guess. Could I have accidentally changed something to limit the update count to only count once?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-06-06 15:07:28
PlaybackStatistics.dat is used by foo_playcount. it has nothing to with this at all.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Mercenary09 on 2010-06-06 15:18:59
PlaybackStatistics.dat is used by foo_playcount. it has nothing to with this at all.


Okay, just ignoring all of what I posted. Know any reason why it won't update if it has at least 1 lastfm_playcount? I am just.. unaware why it does this. This is basically all I would like to find out.

and possibly 'Couldn't load foo_custominfo DB: Playback Statistics Custom (0x0007)' that message. Even though it does update, and has in the past.. maybe it doesn't really mean anything.

Anyways, any answers are appreciated, or even anything, heh.

---
edit: maybe weird, but I don't know what changed besides using the 1.4.7 audio scrobbler instead of this 2.3.1 version I was using, but it seems fine updating now.

Double edit: maybe it doens't. Some tracks update and others don't. Maybe only tracks actually on last.fm or ones with the exact artist / title / album? Not sure, but it worked before. another problem to bother me.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-06-06 15:33:14
foo_custominfo is also completely unrelated. this script uses foo_customdb.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Mercenary09 on 2010-06-06 16:45:31
Haha, you are right. It's minor and doesn't have much to do with this.

It's weird because, I'm guessing, most tracks scrobble, but this track doesn't.. or these. All these FFVI songs don't seem to scrobble beyond one lastfm_playcount. Playing them again just shows:

Quote
Playcount sync: Last.fm responded 'OK'
Playcount sync: Playcount not updated. No changes found.


Now I really have nothing more to say, though I feel I basically repeated myself practically.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-06-06 17:02:12
i suspect that's the last.fm spelling correction at work. check your profile page for recent scrobbles against your tags and you might see what's different. this subject was covered a few page back...

edit: the reason it shows "1" on the first play is because i'm faking it. i add 1 to whatever is returned by last.fm to take into account a scrobble isn't counted until playback stops.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Fractal_Mortality on 2010-06-19 05:21:24
So marc... quick question.

How hard would it be for me to edit the current version of the script to write regular tags instead of custom_db? Is it just a matter of changing the %custom_db% fields in the script to my desired fields?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: YoG on 2010-06-26 13:40:59
Thanks.. looks nice!

Where do i place that $ifequal(%LASTFM_LOVED_DB%,1,♥,) command?

Edit, FooText is able to output the scriptcommand.. but how do i integrate it inside the Playlist-panel like you did, shown in this image (http://public.blu.livefilestore.com/y1pgBH00Bax60aYQwwPFuelnNjIOT8MzxkUwOChhOCIHZxTR_3zCmRBIPUTYMMbCDhM6U-WPPb-tcXXVktYbhw02A/cui_lastfm.png)?
I cannot add it as a Custom Column, like i did with "%LASTFM_PLAYCOUNT_DB%".. that one works fine
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-06-26 13:56:22
if you're running XP you need to install asian font support to get the ♥ symbol. other than that, it should work anywhere as it's just normal title formatting.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Fractal_Mortality on 2010-06-26 19:21:35
So marc... quick question.

How hard would it be for me to edit the current version of the script to write regular tags instead of custom_db? Is it just a matter of changing the %custom_db% fields in the script to my desired fields?


Still wondering if this would work... I mean I guess I could try, but I'd rather not screw with my current script unless this is possible. The only reason I'd try this is because the last version of your script that supported actual tag writing is pretty old at this point.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-06-26 20:32:06
i've made the necessary modifications here. remember the library import still requires customdb - it's not possible to do that with file tagging.

http://pastie.org/1020191 (http://pastie.org/1020191)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Fractal_Mortality on 2010-06-27 00:01:50
Right right, many thanks Marc, as always 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-06-27 02:18:55
i just realised i forgot to remove an extra line i put in for testing. remove line 91.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Steve Forte Rio on 2010-07-18 21:26:59
As last.fm autocorrects some artist names, it is not possible to "love" tracks of this artists directly from foobar2000 - in fact you "love" either track, not track that will be scrobbled.
And here is my question: is it possible to autocorrect this artists' names using some info requested from last.fm. It would be great to see plugin that will be able to do it.

Or maybe it would be better to autocorrect artist name "on the fly" before loving the track?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zarggg on 2010-07-18 23:36:40
I believe Last.fm are working on a new version of the API to allow this very feature. (The "update metadata from Last.fm corrections" one.)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Steve Forte Rio on 2010-07-19 15:22:09
So, then I'll ask marc2003 for including this feature into the next playcount sync versions.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-07-19 17:38:36
the love track feature is provided by foo_softplaylists. nothing i can do about that.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Steve Forte Rio on 2010-07-19 21:56:45
So, the only way to go is creating special plugin, something like tagger, right?  it would be nice to see this plugin...
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zarggg on 2010-07-19 22:08:57
If I'm remembering (and understanding) the blog post properly, the correction data would be sent back over the API protocol at the time of submission, so it would probably be best incorporated in foo_audioscrobbler (or something similar).
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ThorHxC on 2010-08-01 08:03:07
I'm sorry but I'm new to foobar (as in I just downloaded it a few hours ago), but I wanted to try out this plugin. I don't what the instructions meant by "add a WSH panel to your layout."

Could someone help me out with this?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-08-01 11:49:21
if you use default UI, then check out how to use layout editing mode..

http://wiki.hydrogenaudio.org/index.php?ti...ut_Editing_Mode (http://wiki.hydrogenaudio.org/index.php?title=Foobar2000:Layout_Editing_Mode)

if you use columns UI, look here...

http://yuo.be/wiki/columns_ui:config:layout (http://yuo.be/wiki/columns_ui:config:layout)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ThorHxC on 2010-08-01 18:39:40
Yeah. I feel like I'm doing this completely wrong.
My foobar looks like this now:

(http://i31.tinypic.com/vy19mr.png)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-08-01 19:01:23
i'm not really sure how you managed that. goto the view menu>layout>quick setup and pick something from the "main layout" on the left hand side. there really isn't much else i can say apart from read that first link again.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ThorHxC on 2010-08-01 19:27:14
i'm not really sure how you managed that. goto the view menu>layout>quick setup and pick something from the "main layout" on the left hand side. there really isn't much else i can say apart from read that first link again.


I went to View > Layout > Create Scratchbox then right click > Add New UI Element > WSH Panel Mod. I imported the playcount sync script, then hit apply and okay. Edit > Apply Layout and then that's it.

I'm using the Album List + Properties Layout.

What could I be doing wrong?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ThorHxC on 2010-08-02 06:49:05
Nevermind. I got it working.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: mehcore on 2010-08-02 16:13:33
I followed all the instructions, everything installed correctly, and both test.sql and customdb_sqlite.db are populated, but the playcount list remains empty, as does the loved column.

Console output:
Code: [Select]
Opening track for playback: "Z:\Music\Full Albums\65daysofstatic\[65 Days Of Static] - One Time For All Time\01 - Drove Through Ghosts To Get Here.flac"
Playcount sync: Contacting Last.fm....
Playcount sync: Last.fm responded 'OK'
Playcount sync: Contacting Last.fm....
Playcount sync: Last.fm responded 'OK'


This track is loved and has plays already, but the columns are still empty. Just to try I tested with a mp3 version of the track but the issue persists.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-08-02 16:22:10
right click any track in the playlist and look under "Legacy Commands (unsorted)". do you see 4 customdb entries like this?

Code: [Select]
Customdb Love 1
Customdb Love 0
Customdb Delete Playcount
Customdb Refresh


if not, then you didn't put foo_customdb.dll.cfg in the correct place. check the readme again.... (and make sure foobar is closed while you do it)

if the context menu is correct, what happens when you open a library search window and type in

Code: [Select]
%LASTFM_PLAYCOUNT_DB% PRESENT


also it might be worth looking under preferences>tools>custom database>database tab. how many entries are there?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: mehcore on 2010-08-02 17:02:20
Sorted, I presume that the cfg was overwritten when I closed and reopened F2K with the old version. Works perfectly, cheers!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-08-02 17:29:56
i'll update the readme so hopefully it won't happen again.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Jny on 2010-08-07 08:48:59
marc2003 thanks for script
can you fix "do not hide legacy commands (unsorted)" or this is customdb plugin problem?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-08-07 10:20:25
that submenu and commands need to be visible for WSH panel mod to do continuous updates in the background. i had to mention it because too many people were hiding it and then complaining it didn't work.  sorry but there's nothing i can do about it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: lediur on 2010-08-17 03:43:03
Just a small question, as I wasn't quite sure from the instructions PDF.

If I use a keyboard shortcut to "Love" a track, will it automatically sync back to Last.FM? I know it sets the variable in the customdb, I'm just not sure if it reflects it back to the service.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: lediur on 2010-08-17 07:08:15
Just a small question, as I wasn't quite sure from the instructions PDF.

If I use a keyboard shortcut to "Love" a track, will it automatically sync back to Last.FM? I know it sets the variable in the customdb, I'm just not sure if it reflects it back to the service.


To elaborate: is there a way to have the Last.fm Love Tracks action also trigger a sync()? I've bound the Love Tracks to a keyboard shortcut, but it only sends the Love status to the server without updating the loved status in the player.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-08-17 16:23:07
normally when you click the button, it triggers foo_softplaylists to love a track on last.fm. the script then immediately fetches this updated track information from last.fm and writes it to customdb. if the action to love a track somehow fails, no record will be written to the database. it would be confusing if i updated the database without confirmation from last.fm that the track is actually loved.

now when you use a keyboard shortcut, you're bypassing the script and using foo_softplaylists to update last.fm only. but the script would notice you'd loved this track the next time it automatically updates (which should happen during normal playback after either half the track or 4 minutes has passed - whichever comes first).
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: lediur on 2010-08-17 23:27:35
normally when you click the button, it triggers foo_softplaylists to love a track on last.fm. the script then immediately fetches this updated track information from last.fm and writes it to customdb. if the action to love a track somehow fails, no record will be written to the database. it would be confusing if i updated the database without confirmation from last.fm that the track is actually loved.

now when you use a keyboard shortcut, you're bypassing the script and using foo_softplaylists to update last.fm only. but the script would notice you'd loved this track the next time it automatically updates (which should happen during normal playback after either half the track or 4 minutes has passed - whichever comes first).


If I were to change this code:

Code: [Select]
function on_playback_time(time) {
    time_elapsed++;
    if((time_elapsed == target_time)) sync();
}


so it also had
Code: [Select]
|| (time_elapsed == Math.floor((fb.PlaybackLength - 5)))
as a condition, would that help in ensuring it synchs with Last.fm before the song ends? It shouldn't increment the playcount twice, right?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: BrutuZ on 2010-08-19 03:16:49
If by that you mean chenge you code into
Code: [Select]
function on_playback_time(time) {
    time_elapsed++;
    if((time_elapsed == target_time) || (time_elapsed == Math.floor((fb.PlaybackLength - 5)))) sync();
}
Then yeah, it would sync twice, but the count would remain correct. The point is, why sync twice? I'd choose among sync on a pre-determined time (like the old 10s), OR the current mid-song, OR on the last 5s as you suggested. But no more than one sync at a time, just to avoid unneeded queries.
Personally, if i had this need with the shortcut, i'd just set the sync to the last 5s as you figured, and ommit the middle-song condition.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: acmodeu on 2010-08-24 13:41:17
last.fm gives the time of the 1st scrobble of the song now, so can this be embedded in the script too?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-08-25 11:13:32
@acmodeu, only the website shows the first played date for tracks. this information isn't available via the last.fm API.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: muzack on 2010-08-25 11:42:15
@acmodeu, only the website shows the first played date for tracks. this information isn't available via the last.fm API.


@marc2003
it's possible, but a bit quirky because you need to download all played artisttracks and then search for the right title.
http://www.last.fm/api/show?service=432 (http://www.last.fm/api/show?service=432)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-08-27 10:32:35
depending on how many plays you have for an artist, you could end up parsing 100+ pages which is totally unworkable.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: muzack on 2010-08-27 11:25:24
depending on how many plays you have for an artist, you could end up parsing 100+ pages which is totally unworkable.

yep right.
I tested this all for myself.
It runs ok but there are some backlashes.
I pull just all pages in a defined timespan (beginning till a month ago) and cache them.
this ends up in lot of files depending on played tracks per artist but it works (I've got 10000+ played tracks on one artist).
It could be possible to write one file after first parsing to use it later easily.
So data will be loaded just once per artist on first play. if the song is too short and data is still retriving it mess up the stuff, but this happend very rarely.
If all data there, I reverse the array and search for the track, write the date into file and import into playbackstat (via wsh contextmenu call)
Sometimes foobar hangs if I have too much (3) UpdatefileinfoSimple calls.
Don't know why...
Anyway that's the way I sove it...
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: demauvaisgout on 2010-08-28 20:53:52
First import problem..

I don't know, if this has been discussed here, or if anybody else has encountered this problem, but I just can't get the very first creation of the SQL file done. I assume the problem is the size of my library, over 1000 pages.. and it just stops usually after some 100 pages, the topmost i could get done were about 500..

My friend's got the exactly same problem, the import stopping around the lower hundreds..

Maybe you have a hint for me, how I can solve this, or suggest a workaround... I'd be utterly grateful!

Since this plugin would be something like a latent dream come true..
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: McBag on 2010-09-04 21:00:52
Hi,
I'm having a problem.
(http://www.abload.de/img/kjkknj7gib.png) (http://www.abload.de/image.php?img=kjkknj7gib.png)
As you can see, the data won't get updated.
And for me, this:

8)  Lastly, you’ll need to configure your playlist (or some other panel) to show the data.

        //this is what you use to display the play count.
        [%LASTFM_PLAYCOUNT_DB%]

        //show if a track is loved
        $ifequal(%LASTFM_LOVED_DB%,1,♥,)

doesn't work, too (I go to Library, then search and copy&paste the lines and nothing appears)
Thank you for your help.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: BrutuZ on 2010-09-05 01:32:06
As far as i know, this error has nothing to do with the script (assuming you are talking about the last two lines), they are foo_audioscrobbler plugin fault. The lines pertinent to the script are ok as you can see (Playcount sync: Last.fm responded 'OK'). It can either be a problem with the plugin itself (wich i doubt) or a problem with something in the last.fm system (more likely) that is returning unexpected data to foo_audioscrobbler.

Also, these lines are not supposed to work on the Library Search anyway, you're supposed to paste them on your playlist display configuration. From the screenshot I'd guess you have Columns UI, if so, all you have to do is create a new tab (or edit an existing one, it's up to you) with those commands in the display field. In a step-by-step manner would be something like "File > Preferences > Display > Columns UI > Playlist View > Columns TAB There you select or create the column you want to display the playcount and/or Loved status and paste the corresponding line at the Column Details AREA > Scripts TAB > Display SUB-TAB (don't forget to tick the "Use custom script" option)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: McBag on 2010-09-05 11:22:01
Ok, I got it.
But what can I do with this data, now?
Can I sort this or create autoplaylists?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: muzack on 2010-09-05 22:39:50
I can confirm the same probs like demauvaisgout ( http://www.hydrogenaudio.org/forums/index....st&p=720392 (http://www.hydrogenaudio.org/forums/index.php?s=&showtopic=76772&view=findpost&p=720392) )
Import stops without any info on a 700+ paged db on pages around 100. My own archive with 530+ pages works well.
very strange... any idea?

Edit: When I play music while downloading I came on 500 downloaded pages but then it stops again. And I don't think it depends on playing music while downloading?!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: BrutuZ on 2010-09-06 04:02:15
@McBag: Yes, you can achieve both. For example, i have an autoplaylist called "Really Never Played", that keeps every song Last.fm has never registered (i used to use Winamp a couple years ago), and another called "Never Played" that has only the tracks Foobar2000 haven't played yet.

@muzack: I'm not sure, but would guess this can be some sort of spam protection on Last.fm servers. Perhaps if there was an option to resume the script from a given page so that you could then wait a while after the import stops and then resume from the page it stopped it could work. The only workaround i can think of though.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-09-06 09:24:33
i've tested accounts with more than 1000 pages and they worked fine. can people having problems post their last.fm account names and i'll try and test them. i don't need your api key. if you don't want to post here then send me a PM.

i don't have internet at home at the moment so it may be a day or 2 before i can reply.

@brutuz, regarding "spam protection", last.fm have a limit of 5 requests per second and there is no chance of this script ever breaking that.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: muzack on 2010-09-06 10:15:48
hi marc,
it's a weird behaviour, but I think I had track it down.
as I describe above for my own account it works without any problems, for a friends account it stops.
I debugged your lastfm function and looked at the responsecodes.
the request that returns nothing and results in stopping the process has the responsecode 12152 which means the server returns nothing.
so there is no responsetext in your function if status != 200 .
this 12152 response is something strange in msxmlhttp versions - i don't know... microsoft stuff 
to solve this you just have recall the lastfm function on this responsecode and after a short hang the process runs till end.

here is the modified function with some traces:

Code: [Select]
function lastfm(qs, user_agent, func) {
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    xmlhttp.open("GET", "http://ws.audioscrobbler.com/2.0/?api_key=" + api_key + "&username=" + username + qs + "&s=" + Math.random(), true);
    fb.trace("http://ws.audioscrobbler.com/2.0/?api_key=" + api_key + "&username=" + username + qs)
    xmlhttp.setRequestHeader('User-Agent',user_agent);
    xmlhttp.send();
    xmlhttp.onreadystatechange = function() {
    fb.trace("readystate:"+xmlhttp.readyState)
    
        if (xmlhttp.readyState == 4) {
        fb.trace("status:"+xmlhttp.status)
        fb.trace("statusText:"+xmlhttp.statusText)
            if (xmlhttp.status == 200) {
                func();
            } else {        
            fb.trace("error readystate:"+xmlhttp.readyState)
            fb.trace("error status:"+xmlhttp.status)
            fb.trace("error statusText:"+xmlhttp.statusText)
            fb.trace("error responsetext:"+xmlhttp.responsetext);
            if(xmlhttp.status == 12152){
        fb.trace("tryagain")
        lastfm(qs, user_agent, func)
            }
            }
        }
    }
}


and here all MS error codes:
http://msdn.microsoft.com/en-us/library/aa383770(VS.85).aspx (http://msdn.microsoft.com/en-us/library/aa383770(VS.85).aspx)
and something here:
http://stackoverflow.com/questions/872206/...n-in-ms-xmlhttp (http://stackoverflow.com/questions/872206/http-status-code-0-what-does-this-mean-in-ms-xmlhttp)

hope that helps.
cheers m.

edit: this strange responsecode happend around 6 times on downloading 700 pages. I think this happend randomly...
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-09-07 09:45:02
hmm, i guess my script isn't very robust, expecting a 200 repsonse code otherwise it craps out. 

thanks for the links.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: muzack on 2010-09-07 10:00:08
The MS doku is much more crap - and the weird behaviours of msxmlhttp.
for your script I would suggest in first line a more descriptive output on failture even if users don't know what it mean.

Code: [Select]
try{ ... }catch(e) { fb.trace("error: "+e.description)}

could help to get a hint why the script fails without broke it.

Maybe it makes sense to write the sql file in runtime and append the statements for every block and store the pagenumber to resume downloading when the script fails.
This may slow it down a bit - and maybe it's not necessary if you catch the statuscode and recall the downloading function. At least in this case.

Just my 2cents.


Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: thiagonl on 2010-09-07 18:55:31
hey marc, i have a little problem:

when i create and import sql file it creates one, but i don't think it's importing.

when the blue window demands me to close foobar, it opens sqlite3.exe black box and foobar again, but nothing gets updated in the database ;\

i'm using foobar v1.1
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-09-08 09:31:37
^ see this post...

http://www.hydrogenaudio.org/forums/index....st&p=716593 (http://www.hydrogenaudio.org/forums/index.php?showtopic=76772&view=findpost&p=716593)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: thiagonl on 2010-09-08 18:12:22
^ see this post...

http://www.hydrogenaudio.org/forums/index....st&p=716593 (http://www.hydrogenaudio.org/forums/index.php?showtopic=76772&view=findpost&p=716593)

i see all these customdb entries

when i perform the library search for %LASTFM_PLAYCOUNT_DB% PRESENT i see only some music i listened to yesterday(i installed foobar yesterday too)

in the database tab it shows 478 entries(i have a ~13000 songs database and ~14000 plays in last.fm)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-09-09 09:31:18
try running the import again and have the foobar console window open while you do it. does it appear to show the correct number of pages?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: thiagonl on 2010-09-09 18:41:30
yeah, 33 pages

http://twitpic.com/2mrpoc (http://twitpic.com/2mrpoc)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-09-10 09:28:29
the database tab it shows 478 entries(i have a ~13000 songs database and ~14000 plays in last.fm)


so the 13000 tracks you mention here is your foobar library and not how many different tracks you've submitted to last.fm??? (and the 14000 plays is irrelevant because there is only 1 entry per track anyway regardless of how many times it's been played.)

yeah, 33 pages

http://twitpic.com/2mrpoc (http://twitpic.com/2mrpoc)


1623 different tracks? so how many entries on the database tab now?

any chance you can share your last.fm username please so i can see for myself what's going on.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: mxut01 on 2010-09-10 16:48:44
This plugin works great.
I thought you meant it'll synchronize plays after I play 10 seconds of every song in my library.
Fortunately, it synchronized plays so quickly  Looks really nice
I would like to add the "heart" in a column(so it exist there for every song) but I can't figure out how...
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: thiagonl on 2010-09-10 18:38:50
494 entries on the database, still not importing.

and yeah, i've scrobbled only 1623 different tracks from my library

my last.fm username is thnlopes: http://www.last.fm/user/thnlopes (http://www.last.fm/user/thnlopes)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: BrutuZ on 2010-09-11 01:49:43
This plugin works great.
I thought you meant it'll synchronize plays after I play 10 seconds of every song in my library.
Fortunately, it synchronized plays so quickly  Looks really nice
I would like to add the "heart" in a column(so it exist there for every song) but I can't figure out how...

As stated somewhere else (I believe in the help file or something like that), to display the loved status of the tracks in the playlist you add the following value to the column
Code: [Select]
$ifequal(%LASTFM_LOVED_DB%,1,?,)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-09-11 10:18:04
494 entries on the database, still not importing.

and yeah, i've scrobbled only 1623 different tracks from my library

my last.fm username is thnlopes: http://www.last.fm/user/thnlopes (http://www.last.fm/user/thnlopes)


works fine here....

(http://k5sbdw.blu.livefilestore.com/y1pPpXA4Tam3TdGzDE3xPdYND4gkfOniHCoz0EDo-R6yxnOSZeDgxNgLUHRtRqECfN57gU_2RLgS8WfFVnjcTM6XFGk5yxeDxjz/db.PNG)

it's 1800 odd because of your loved tracks as well. all i can suggest is closing foobar, deleting the database file (usually found at %appdata%\foobar2000\customdb_sqlite.db) and trying again.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: thiagonl on 2010-09-12 18:15:30
ok, i'll try to make this work

thanks for the help
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: RatzaChewy on 2010-09-14 14:56:18
Got everything sorted using Columns UI, there's juts one problem. Whatever I do using the WHS panel mod, the love heart doesn't fit the toolbar and there's a gap to the right hand side of it.

(http://img690.imageshack.us/img690/3051/foobar2000.png)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: BrutuZ on 2010-09-15 01:18:41
That's normal, you have to fiddle with the script to fine-tune the look. I have mine set with the following parameters to fit my UI perfectly. I have changed the Heart icon, but can't really remember if it makes any difference.
Code: [Select]
var bw = 16;
var bh = 16;
var top_margin = 2;
var left_margin = 2;
window.MinWidth = window.MinHeight = window.MaxWidth = window.MaxHeight = 20;
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-09-15 11:08:34
to make it look better you can also right click the panel and change the background colour to "splitter" so it matches the toolbar.

but i think you're stuck with the gap to the right as it's a problem with using WSH panel mod when added to the toolbar in CUI. if it was added as panel to your layout, you could resize it how you want.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: BrutuZ on 2010-09-16 01:31:46
I have to disagree, mine doesn't have that gap anymore. It's been a while since i messed with the code so can't really remember if I changed something besides the lines mentioned above. (http://i51.tinypic.com/1zgs1fk.png)

EDIT: Indeed, the last line in my previous message is what does the trick. It sets the total size of the "window". In the code i posted it is set to 20, 16 for the button size (i reduced it to match CUI toolbar buttons size) + 4 (the 2 pixels margin on every edge). Perhaps you should consider adding it to your script too marc
Also, I found the Background option set to "None" to look even better since instead of trying to match the color (wich it doesn't here, btw) it just makes it transparent.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: bloodclot on 2010-09-19 21:45:30
I try to set last.fm username or last.fm api and I get this error message.

(http://imgur.com/C8dM7.png)

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-09-20 12:09:00
sorry i have no idea what would cause that or how to fix it? have you been tweaking windows/stripping out components at all? that's all i can think of. the script has been tested to work fine on XP, vista and windows 7???
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Steve Forte Rio on 2010-09-20 12:29:55
Hello! I have a problem with playcount_sync and foobar2000 on windows 7 32 bit

I'm trying to install playcount sync on clean foobar2000 1.1 portable installation. But when I add WSH panel to the layout and import the script - there is no buttons or something else on the panel, the panel is empty, Options "Create and import SQL file" and "Import SQL file" are unavailable ((

I was following the instructions but wsh panel doesn't work
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-09-21 11:36:24
well there is no difference between a portable install and standard install other than the fact the "configuration" folder resides in the main foobar directory when using portable mode. i can only suggest starting again from the top?? missing buttons/images would probably indicate you didn't extract the files from the zip properly.

@bloodclot, i forgot you can easily set your username/api key inside the script. just edit lines 17 and 19 like this...

17
Code: [Select]
var username = "marc2003";


19
Code: [Select]
var api_key = "123456.....";
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Steve Forte Rio on 2010-09-21 15:23:19
I'm sure that I have properly extracted all files. E.g. all images are present in foobar2000\scripts\marc2003\v2\images folder

I have no idea why it doesn't work...
It have been working on previous installation of Windows 7, and on Win XP.

Maybe script needs some libraries like JRE or Visual C++  ???
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-09-22 11:26:18
i assume you have something in your playlist? it won't show any button if you start foobar with an empty playlist. as soon as you add a file or switch to a populated playlist, you will see a button....
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Steve Forte Rio on 2010-09-22 17:55:04
))

Thank you!

Creating/importing buttons are now available too


And now I have another one question...


where the files from playcount_sync archive should be located in case of standard foobar2000 v1.1 instalation with user profiles enabled and separate user-components folders?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Steve Forte Rio on 2010-09-22 17:59:31
And again, the problem with script...

Quote
working....
Error: unable to open database "C:\Users\└фьшэшёЄЁрЄюЁ\Desktop\foobar2000\custom
db_sqlite.db": unable to open database file
Для продолжения нажмите любую клавишу . . .


I believe this happens because of cyrillic symbols in the path

User's appdata folder contains this symbols in it's path too.

Now I see the cause of all my problems with playcount sync.

marc2003, could you fix the problem with cyrillic symbols?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: bloodclot on 2010-09-22 18:58:35
@bloodclot, i forgot you can easily set your username/api key inside the script. just edit lines 17 and 19 like this...

17
Code: [Select]
var username = "marc2003";


19
Code: [Select]
var api_key = "123456.....";


I actually tried that already. It doesn't change anything for some reason.

It's all good, I got the old version up and running again.

One question though, I have loved_tag_name to "RATING" and I want to change the number it updates the tag with from 1 to 5. How can I do this?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: BrutuZ on 2010-09-23 02:21:18
I don't think you can do that. The Loved value is a boolean (either True OR False), this is a Last.fm parameter, and it doesn't support rating. You probably should keep the original tag name and use a rating system appart from that.
Maybe, code an implementation into the script so that if a track has a rating of above, say, 4, then the script automatically "loves" it on Last.fm (and consequently on the customDB too). That way the rating and loving system would be somewhat integrated.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-09-23 10:49:48
where the files from playcount_sync archive should be located in case of standard foobar2000 v1.1 instalation with user profiles enabled and separate user-components folders?


from the zip, the "scripts" folder still needs to go in the main foobar directory. as for the "components" you have 2 options...

a) place them in the main components folder as before
b) if you really want per user component settings, use the "install" button on the components page in the preferences to browse to the dll files.

the manual tells you where you need to place the foo_customdb.dll.cfg file.

And again, the problem with script...

marc2003, could you fix the problem with cyrillic symbols?


i don't think that has anything to do with the script. it looks to be a problem with the foo_customdb component.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Steve Forte Rio on 2010-09-23 15:39:10
Thanks for the reply

i don't think that has anything to do with the script. it looks to be a problem with the foo_customdb component.


But as I see, program can't save DB file into destination folder. And as far as I know this program is sqlite3.exe - don't we have the problem with it?

Because custom db component properly reads and writes database (e.g. if I "love" track this info stores to data base file)

Though, maybe I'm wrong...


P.S. How can I change the destination folder for saving customdb_sqlite.db (after downloading)?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Steve Forte Rio on 2010-09-23 19:13:37
Quote
as for the "components" you have 2 options...


and what about API files? Should I place them into the wsh panel's folder? Or in the "main" component folder?


add:

Looks like you was right when saying about custom_db component problem. Component can't save the new playcount value into the database
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-09-24 12:26:55
ah it might be the script then. at first i thought you copy/pasted that error from the foobar console which made me think it was a component problem.

are you saying it's the command prompt window with blue background that comes up with that error?

loving a track works because the script works like a macro. it simply triggers the playlist context menu action to set the database value. however, updating the playcount means using the windows command line which could be the cause of failure due to these cyrillic symbols.

i'll have a think on how to get around that.

edit: i can't test this as i'm using a restricted machine with no access to the user profile folder but try this....

close foobar

1) move the file "lastfm_sql.cmd" from the main foobar directory in to your foobar profile folder (%appdata%\foobar2000)
2) move the file "test.sql" from your "profile folder\wsh_lastfm" into the of the profile folder (this should save you from downloading the data all over again)
3) now in %appdata%\foobar2000 there should be 3 files...

customdb_sqlite.db
lastfm_sql.cmd
test.sql

4) start foobar, right click the panel and choose "configure". now replace lines 20 and 21 with this....

Code: [Select]
var sql_file = fb.ProfilePath + "test.sql";
var batch_file = fb.ProfilePath + "lastfm_sql.cmd customdb_sqlite.db test.sql";

5) now right click the panel and select "import sql file", closing foobar as instructed.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: CaptainTrips on 2010-09-25 17:27:45
Can I import all my previous plays from foobar to Last.fm profile?
(all PLAY_COUNTER infos from each file)
I've searched on Google but it seems to be possible only with iTunes, Windows Media Player or Winamp.

I post it because i thought "synchronise" means last.fm <-> foobar, and if i understand it's only last.fm -> foobar
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: BrutuZ on 2010-09-26 02:50:44
I'd guess that if it is ever going to be possible, will be up to foo_audioscrobble to do that. I'm no expert, but batch scrobbles may be a little sketchy, specially with past plays due to Last.fm's anti-spam (a.k.a anti-"cheat") system. iTunes, WMP and Winamp can probably do that since they use the official plugins and have "closed" databases, while foobar2000 uses a third-party plugin to scrobble AND despite having the default playback statistics database, it is not actually mandatory, you can choose not to use it or even worse (for LFM to control), you have N options of third-party databases to choose from.

BTW, syncs are not necessarily two-way. Actually more than often they are only one-way like this script (or google calendar and outlook without the google separate program, for that matter)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: CaptainTrips on 2010-09-26 07:38:23
Thanks
I hope someone is working on it (a way to import all previous plays from foobar to Last.fm). It could be useful for many people, at least for those who use this player... maybe not numerous enough to interest last.fm.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Audio N00b on 2010-10-03 09:34:59
Hello,

Yes, It'd be great to have this working on Foobar 1.1

I just switched from 9.x, and now with all plugings disabled and deprecated components uninstalled... I feel a bit sad with the fact my playcounts are gone, although they remain on Last.fm (good lord, thankfully I started using it a long time ago  )
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-10-18 12:23:09
new version uploaded.

http://cid-649d3bfeaf541fbb.office.live.co...ount%20sync.zip (http://cid-649d3bfeaf541fbb.office.live.com/self.aspx/.Public/foobar/guide/playcount%20sync.zip)

contains new foo_softplaylists (http://www.hydrogenaudio.org/forums/index.php?showtopic=76133) component which allows you to unlove tracks.

@audionoob, i'm not really sure what your point is. this script does import playcounts from last.fm into foobar. it works fine in 1.1 (i always use the latest foobar version/components available).

it's the thing CaptainTrips is asking for that it can't do. only the last.fm client app with WMP/itunes/winamp can import playback stats into a new last.fm account.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: rafib on 2010-10-18 13:00:42
marc2003: Is it possible to save the stats inside the MP3 itself, in the new version? I know in the old version it was possible.

Thanks for your great work
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-10-18 13:18:11
just continue using the old version. all recent updates are related to foo_customdb / importing the whole last.fm library which it isn't possible to do when file tagging.

i suppose one option is to use the new version to import all playcounts into foo_customdb. then you could use the properties dialog and use "format from other fields" to transfer data from %LASTFM_PLAYCOUNT_DB% into your own file tag. then you can go back to the old version for the continuous background updates.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Audio N00b on 2010-10-21 06:42:36
Holy Guacamole!!!!!!!!!!!!!!!!!!!!!!!!

Man this is so great hahahhaa... love you marc2003. Will have to sit down and install the plugin and else this weekend but you just gave me some amazing news this cold night!!!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Jango on 2010-10-27 07:36:35
Thanx marc2003 for the Last.fm Love Button script!
I use it wit my config called Silent Night here... http://arnie77.deviantart.com/art/Silent-N...V-5-1-154667359 (http://arnie77.deviantart.com/art/Silent-Night-V-5-1-154667359)
When I first aply the script the only thing i see is an white WHS pannel.
I want to have an transparent pannel with an transparent *.png from startup...
...is it possible to change that? I am no Jscript coding expert.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-10-27 10:08:38
the original script already uses transparent png files just fine. i'm guessing the theme author has replaced my images/file locations with his own so you'll have to ask him. i'm not providing support for that. i'm not installing all that guff just to check it out.




Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Jango on 2010-10-27 10:57:28
the original script already uses transparent png files just fine. i'm guessing the theme author has replaced my images/file locations with his own so you'll have to ask him. i'm not providing support for that. i'm not installing all that guff just to check it out.


I got it!
It was my fault. 
When noting is in the libary or in the playlist no image will be displayed.
could be this...
function on_metadb_changed() {
   if(!g_metadb) return;...

Thanx !
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: omarak2229 on 2010-10-27 16:55:14
Thanks for this! This is awesome. One problem though. I don't have that heart in my character map or whatever, so instead of showing a heart, it shows a little box. It even does this when I copy the heart from the readme.pdf into the script. I'm on XP Service Pack 3 if it matters.

Thanks in advance!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: BrutuZ on 2010-10-28 02:11:40
You ought to use a font that has that character mapped, otherwise it will show the box you're getting.
Tip: Open up windows character map (%windir%\system32\charmap.exe), select a font in the dropdown list and search for "heart" in the proper box, if it's there you can use that font on your playlist and the loved status will display just fine. You could also change the heart to something else your current font supports, like S2, <3 or any other regular symbol/character, but that could be kind of lame 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-10-28 09:41:37
install "east asian" character support through "regional settings" in the control panel then you should get that character with all fonts.

(you'll need your XP installation cd to do this)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: omarak2229 on 2010-10-29 05:59:34
Alright, thanks fore the help guys! 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: bubi jackson on 2010-10-29 15:13:49
i suppose one option is to use the new version to import all playcounts into foo_customdb. then you could use the properties dialog and use "format from other fields" to transfer data from %LASTFM_PLAYCOUNT_DB% into your own file tag. then you can go back to the old version for the continuous background updates.

Thank you very much for this hint.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: n0thng2bd0ne on 2010-10-31 01:20:37
thank you for this.  i managed install and retrieve my info but i have two issues.

1. not all loved tracks are shown.  this might be because i've moved a bunch of tracks around so no big deal, i don't have many loved tracks anyway.

2. when i click the heart to love a track, the component (but not foobar) crashes "aw, crashed ):"

using foobar 1.1, win7 32bit, and music files are on a network drive.  i put the component in a default skin tab - it shows the heart.

thanks for help.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: n0thng2bd0ne on 2010-10-31 02:26:22
Error: WSH Panel Mod (Playcount Sync by marc2003): Microsoft JScript runtime error:
Invalid procedure call or argument
Ln: 93, Col: 2
<source text only available in compile time>


EDIT--added a toolbar button as described in this thread--works great, so disregard #2.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: n0thng2bd0ne on 2010-10-31 03:43:51
sorry for writing this garbage. i think the missing loved tracks are those that i loved while listening online, so i don't have those tracks. 

thanks again
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: bubi jackson on 2010-10-31 06:11:41
Hi marc2003,

would it be possible, to get the "lastfm_firstplayed" by the lastfm database, too?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: muzack on 2010-10-31 14:55:11
would it be possible, to get the "lastfm_firstplayed" by the lastfm database, too?


it's possible in theory, but not implemented yet (afaik)
http://www.hydrogenaudio.org/forums/index....st&p=719890 (http://www.hydrogenaudio.org/forums/index.php?s=&showtopic=76772&view=findpost&p=719890)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: thuan on 2010-10-31 16:38:00
Hum, possible, but ugly like hell, track.getinfo should have returned that info instead.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: bubi jackson on 2010-10-31 19:15:39
would it be possible, to get the "lastfm_firstplayed" by the lastfm database, too?


it's possible in theory, but not implemented yet (afaik)
http://www.hydrogenaudio.org/forums/index....st&p=719890 (http://www.hydrogenaudio.org/forums/index.php?s=&showtopic=76772&view=findpost&p=719890)

I see - it's a pity, thx for the link.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-11-01 09:38:30
sorry for writing this garbage. i think the missing loved tracks are those that i loved while listening online, so i don't have those tracks. 

thanks again


so long as the tracks that you loved online exist on your pc somewhere with the exact same artist/track tags then they will show in your foobar library/playlists.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-11-02 14:24:21
new version uploaded. now supports auto spelling correction for the artist. you can toggle the option on/off via the context menu. this applies to background updates only.

http://cid-649d3bfeaf541fbb.office.live.co...ount%20sync.zip (http://cid-649d3bfeaf541fbb.office.live.com/self.aspx/.Public/foobar/guide/playcount%20sync.zip)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: laite on 2010-11-03 06:41:18
new version uploaded. now supports auto spelling correction for the artist. you can toggle the option on/off via the context menu. this applies to background updates only.


What exactly should this do? Update the file tags on %artist%? If so, it doesn't seem to work with me (I tested it by changing artist "Joni Mitchell" to "Joni Mitchel", last.fm page showed correction right but nothing happened in foobar).
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-11-03 09:28:16
oh no - i wouldn't touch people's tags. 

by default, last.fm has spelling correction enabled on their website. so let's say you have a song incorrectly tagged as

Joni Mitchel - Big Yellow Taxi

last.fm would auto-correct this and store your playcount data for "Joni Mitchell". previously, this script could only do exact tag matches. it would look up "Joni Mitchell" but because your playcount data had been auto-corrected, it would return a playcount of nothing. but now last.fm API has been modified so i can fetch the data from the auto-corrected pages.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Jny on 2010-11-04 08:32:37
cool new feature, thanks
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: スラッシュ on 2010-11-05 17:48:08
Ooh that IS a cool new feature! Maybe you could make a separate script/panel/thingie that allows you to update your tags*? I tend to want to fix the tags usually (it usually involves Japanese composers that have romanised names), so something that could do that quickly would be nice... Sometimes you don't get the right tags from freedb or Musicbrains or whatever.

Unless there's a last.fm type script for this already that I've not noticed?

* EDIT--Just to clarify, this would be on a per-song basis with a confirmation, so it would be like you press a button and a dialog pops up saying "The artist is currently tagged Shinji Hosoe, but Last.FM redirects to 細江慎治. Do you want to fix this?

Or maybe a list panel with before -> after, like how Rename does it...

Anyway!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Steve Forte Rio on 2010-11-09 19:16:38
new version uploaded. now supports auto spelling correction for the artist. you can toggle the option on/off via the context menu. this applies to background updates only.


Big thank you! This is exactly what I needed!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Steve Forte Rio on 2010-11-09 20:35:04
After installing the playcount sync I encountered the next problem:
If script has updated custom_db playcount value at least once (for current foobar2000 session), after closing foobar2000 I see error:

(http://audiophilesoft.ucoz.ua/misc/c-error.png)

and then:

(http://audiophilesoft.ucoz.ua/misc/c-error2.png)

(sorry for Russian)

Here is translated message from Windows journal:

Quote
The name of the offending applications: foobar2000.exe, version: 1.1.1.0, time stamp: 0x4cd3e09b
The name of the offending module: foobar2000.exe, version: 1.1.1.0, time stamp 0x4cd3e09b
Exception Code: 0x40000015
Offset error: 0x0013ab27
Faulting process id: 0x1720
Faulting application startup time: 0x01cb80477c0c3dab
Faulting application path: E: \ Program Files \ foobar2000 \ foobar2000.exe
Faulting module path: E: \ Program Files \ foobar2000 \ foobar2000.exe
Code Report: a23bfae1-ec3e-11df-a1d7-daee5f7b8875


What is the cause of this problem and how to fix it? Error occuring only on Windows 7
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: BrutuZ on 2010-11-11 15:09:33
Are the .NET Framework and Visual C++ 2005 Redistributable installed?

BTW marc, I use a modified version of your script (for custom Tag reading, time setting and button configurations like size, margins and the images) so whenever there is an update i have to manually change the code so as not to lose these customisations. With the last version i noticed that the lines that set the images of the button (around line 57) didn't work properly. Your new code is
Code: [Select]
        default:
            n = old_userloved == 1 ? "love_h.png" : "love.png";
            h = old_userloved == 1 ? "love_u.png" : "love.png";
but the button wouldn't appear unless i changed it into
Code: [Select]
        default:
            n = (old_userloved == 1 ? "love_h.png" : "love.png");
            h = (old_userloved == 1 ? "love_u.png" : "love.png");
Was it some sort of glitch on my part?

PS: Disregard the image filenames, as mentioned before I use different icons, hence the discrepancy with the original code filenames. The only change that makes the button appear or not is the use of the round brackets.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Steve Forte Rio on 2010-11-11 22:14:18
Are the .NET Framework and Visual C++ 2005 Redistributable installed?


What version of .NET Framewvork does it need? There is Framework 1.1, 4.0 and MSCVC 2005, 2008 and 2010 installed
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: BrutuZ on 2010-11-12 01:58:42
I'd guess .NET 2, but given what you have installed that's probably not the problem
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Xengrid on 2010-11-13 11:30:45
The script doesn't seem to work in my case very well. After I've scrobbled a track once, it updates the counter but if I'm listening to the same track again, it doesn't update the counter at all (track played two, three, four etc. times only shows it's been played once).

The console doesn't show up any erros, when the track is scrobbled second/third/etc. time, the log is same than during the first time playing: "Playcount sync: Contacting Last.fm.... Playcount sync: Last.fm responded 'OK'" "Audioscrobbler: Submitting track... Audioscrobbler: Submission succeeded."

I'm using the newest version and tried reinstalling it, but the problem still exists. Any ideas what I should do? Other than updating the counter, I haven't encountered any other problems - loving tracks, creating soft playlists etc. are working very well.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: BrutuZ on 2010-11-14 02:40:37
If i remember correctly, Last.fm ignores the scrobbles if the track is played over and over - like a repeat-track behaviour - and considers only the first scrobble. If that's not the case and you're listening other tracks between the replays then disregard this message.

BTW, that wouldn't be a problem with the script since it's not the responsible for scrobling the tracks, foo_audioscrobbler is, so any further problems in this matter should be directed to it's topic 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Xengrid on 2010-11-14 12:13:06
If i remember correctly, Last.fm ignores the scrobbles if the track is played over and over - like a repeat-track behaviour - and considers only the first scrobble. If that's not the case and you're listening other tracks between the replays then disregard this message.

BTW, that wouldn't be a problem with the script since it's not the responsible for scrobling the tracks, foo_audioscrobbler is, so any further problems in this matter should be directed to it's topic 
That's not the issue here. It doesn't matter if I listen to other tracks meanwhile or same track all over again (tracks already having at least one play on the LASTFM_PLAYCOUNT_DB table) - it never updates the counter on foobar if I listen to previously listened track again at some point. The only way it updates the playcount from 1, 2, 3 etc. plays is the manual "Create and import SQL file"-function - hardly practical.

To sum it up, I have no problems with scrobbling to last.fm - this script just doesn't update the playcount on foobar automatically after the tracks have been listened to once, in my case.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: PrimulaRosea on 2010-11-16 04:05:00
Code: [Select]
Playcount sync: Last.fm responded 'OK' 
Error: WSH Panel Mod (Playcount Sync by marc2003): (null):
(null)
Ln: 118, Col: 6
<source text only available in compile time>

what did i do wrong? o.O
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: PrimulaRosea on 2010-11-16 05:29:19
Code: [Select]
Playcount sync: Last.fm responded 'OK' 
Error: WSH Panel Mod (Playcount Sync by marc2003): (null):
(null)
Ln: 118, Col: 6
<source text only available in compile time>

what did i do wrong? o.O

ok, please disregard this post >.<
forgot to copy lastfm_sql.cmd and sqlite3.exe to foobar directory >.<

hope no one makes a mistake as dumb as this D:
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Kamon on 2010-11-19 08:42:46
When I right click on the panel and click on "Create and import SQL file" I get this....

http://i.imgur.com/dMJFM.png (http://i.imgur.com/dMJFM.png)

It starts at 1 and just keeps on going up.. What do?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: jack_steel on 2010-11-30 20:01:10
I'm very new using foobar 2k so I had no last.fm account and playcount statistic at all. I created a last.fm account and when I 'love' a track, i see it in my online profile. When I play the track the foobar console is telling me:

Code: [Select]
Playcount sync: Contacting Last.fm.... 
Playcount sync: Last.fm responded 'OK'
Playcount sync: Playcount not updated. No changes found.


The counter in foobar is increasing every time I play the song but in my last.fm profile all loved tracks have the counter 0. What I'm doing wrong?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: djphatic on 2010-12-02 14:21:30
Just set this up, excellent script.

I searched this thread for a solution to getting the correct playcount for a track with the same title from different albums. There was a post (http://www.hydrogenaudio.org/forums/index.php?showtopic=76772&view=findpost&p=687170) back in February that stated that the track.getInfo api did not retreive the album info.

Is this still the case with current version of the API and it has yet to be implemented or is it still impossible to distinguish between the same track from different albums. I know when viewing my library through last.fm if I click on the individual albums of an artist it shows the playcount for that track from that album. Though viewing all albums at once the playcount is accumulated.

If this is not possible, I suppose the alternative would be to tag the tracks different from different albums. I am referring to live performances by the way, so instead of "Misery Business (Live)" on 3 different albums from different venues I would change the tags to "Misery Business (Live from xxx)" and I think that should work correctly.

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: BrutuZ on 2010-12-03 01:02:02
I'd humbly ask you not to do that. This would increase the Last.fm "tag pollution".
It seems the API will only return the correct album if the MusicBrainz ID is supplied (not sure though), but the current DB structure only stores the Artist and Track Name anyway. However, maybe there could be a workaround using library.getTracks with artist and album filters after the whole library playcount has been downloaded.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: jack_steel on 2010-12-04 11:23:19
I'm very new using foobar 2k so I had no last.fm account and playcount statistic at all. I created a last.fm account and when I 'love' a track, i see it in my online profile. When I play the track the foobar console is telling me:

Code: [Select]
Playcount sync: Contacting Last.fm.... 
Playcount sync: Last.fm responded 'OK'
Playcount sync: Playcount not updated. No changes found.


The counter in foobar is increasing every time I play the song but in my last.fm profile all loved tracks have the counter 0. What I'm doing wrong?

Can anybody help me why my playcount is not updated?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: tytan on 2010-12-04 14:43:09
Hi, it's my first post on this forum.

Is it possible to transfer statistics from foo_customdb to PlaybackStatistics3.0.1 (foo_playcount) ?
I can think of 3 ways of doing that:

1. writing foo_customdb tags to file tags and then import to foo_playcount from tags
2. exporting foo_customdb to .xml file and then import to foo_playcount
3. I don't know, maybe there is any direct way?

But I don't know how exacly it would look like. Write if You have any idea!

Please, help!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: djphatic on 2010-12-05 13:50:26
Is there anyway to have the Last.fm Loved Tracks playlist (downloaded from Last.fm) update every so often?

Using an autoplaylist based on LASTFM_LOVED_DB it displays the loved tracks but also displays the same tracks in every other album, which is abit annoying if the same track has appeared on numerous livesets I have in my library.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: n0thng2bd0ne on 2010-12-05 13:57:53
Is there anyway to have the Last.fm Loved Tracks playlist (downloaded from Last.fm) update every so often?

Using an autoplaylist based on LASTFM_LOVED_DB it displays the loved tracks but also displays the same tracks in every other album, which is abit annoying if the same track has appeared on numerous livesets I have in my library.


yeah i noticed this when i loved the headhunters version of herbie hancock's watermelon man.  when i went back to listen to it, it was a totally different version.  i guess last.fm is limited to artist - track title, so if someone runs into this frequently they're better off with a ratings component.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: aereogramme on 2010-12-06 04:28:03
I have just recently started using you script and I love it.  I was just wondering; when I updated my library, everything seemed to go smoothly, when foobar was reloaded, there were albums that I have listened to multiples time and they were mostly all listened to a few times.  Most of them showed up fine, but a few songs show that it is an empty field (blank).  I am using ELPlaylist with the tagging columns added that you said in your readme.pdf.

I was also wondering, when you listened to a song, should everything update in terms of the listen count increasing by one and if I love a track, should I be able to see the heart right away?  If so, that doesn't seem to be working for me, it updates when I re-import my whole library though, just not real time.

Thanks for the awesome script again!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-12-18 10:41:05
new version uploaded.

http://cid-649d3bfeaf541fbb.office.live.co...ount%20sync.zip (http://cid-649d3bfeaf541fbb.office.live.com/self.aspx/.Public/foobar/guide/playcount%20sync.zip)

now has a "show debug info" option on the context menu. this displays the full server response from last.fm in the foobar console so it may give people a clue if the auto-update isn't working as expected.

it would look something like this....

Code: [Select]
<?xml version="1.0" encoding="utf-8"?>
<lfm status="ok">
<track>
    <id>3081424</id>
    <name>Self Suicide</name>
    <mbid></mbid>
    <url>http://www.last.fm/music/+noredirect/Goldie+Lookin+Chain/_/Self+Suicide</url>
    <duration>224000</duration>
    <streamable fulltrack="0">0</streamable>   
        <listeners>2640</listeners>
    <playcount>8233</playcount>
        <userplaycount>16</userplaycount>    <userloved>0</userloved>
        <artist>
        <name>Goldie Lookin Chain</name>
        <mbid>5167695e-3a2a-4311-9990-b7e2d13686a2</mbid>
        <url>http://www.last.fm/music/+noredirect/Goldie+Lookin+Chain</url>
    </artist>
        <album position="2">
        <artist>Goldie Lookin' Chain</artist>
        <title>Greatest Hits</title>
        <mbid>772857ca-fdb6-4cf6-8130-e2072e6527e2</mbid>
        <url>http://www.last.fm/music/Goldie+Lookin%27+Chain/Greatest+Hits</url>       
        <image size="small">http://userserve-ak.last.fm/serve/64s/8678127.jpg</image>
        <image size="medium">http://userserve-ak.last.fm/serve/126/8678127.jpg</image>
        <image size="large">http://userserve-ak.last.fm/serve/174s/8678127.jpg</image>
        <image size="extralarge">http://userserve-ak.last.fm/serve/300x300/8678127.jpg</image>
    </album>
        <toptags>
        <tag>
  <name>rap</name>
  <url>http://www.last.fm/tag/rap</url>
</tag>
        <tag>
  <name>welsh</name>
  <url>http://www.last.fm/tag/welsh</url>
</tag>
        <tag>
  <name>hip-hop</name>
  <url>http://www.last.fm/tag/hip-hop</url>
</tag>
        <tag>
  <name>comedy</name>
  <url>http://www.last.fm/tag/comedy</url>
</tag>
        <tag>
  <name>death</name>
  <url>http://www.last.fm/tag/death</url>
</tag>
      </toptags>
    </track></lfm>

the 2 fields the script uses to update your stats in foobar are userplaycount and userloved. if these values are not what you expect, it's likely there is a conflict between the spelling correction options on the website and in the script - you need to make sure they match. also- mis-spelt track names may cause a mismatch - and i must admit, i haven't really looked into it.

i've been offline for quite awhile so i'll try and address a few posts...

@Steve Forte Rio - sorry i have no idea about that error or how to fix.

@Xengrid, are you listening to enough of the track for the script to run (half-way if track is less than 4 minutes or 4 minutes for longer tracks)

@Kamon, i'll need your last.fm userid to investigate that error

@jack_steel - i assume you are using foo_audioscrobbler to update last.fm? - http://www.mp3tag.de/en/fb2k.html (http://www.mp3tag.de/en/fb2k.html)

@tytan, you can use the standard foobar properties dialog and transfer the stats into a "RATING" file tag (right click>format from other fields). you can then use playback statistics to import the tags into it's own database

@aerogramme, when you love a a track, you should see the heart straight away. i'm not sure what is happening there...

sorry if i've missed anyone - just give me a shout.

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: joelzhao on 2010-12-19 03:20:15
sqlite3 seems to update to version 3.74, what you supply seems older.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-12-20 11:50:27
edit: nvm....
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: blogbourri on 2010-12-23 22:59:00
Loving the script, but I am having one issue... I think because I use the field re-mapping "[$meta(artist,0)]" in the audioscrobbler plugin, your script isn't able to match the last.fm stats to the tracks in my library. I tried replacing all instances of '%artist%' with '$meta(artist,0)', and after doing that it now syncs whether a track is loved or not—but still no playcount gets returned.

-Devin.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: BrutuZ on 2010-12-24 00:45:51
Correct me if I'm wrong (and the documentation FAQ too), but doesn't your mapping add 0 as a separator in the case there are multiple artists in the field? If so then it should be scrobbling something like "Artist0ContrArtist" instead of "Artist, ContrArtist". Perhaps you could tell your Last.fm username in order to check the scrobbles (Maybe spell-correction kicked in or something)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: blogbourri on 2010-12-24 00:55:20
Nope, it returns only the first value, so if I have multiple artists tagged to the track (say, featured artists), instead of scrobbling:

Artist, Featured Artist - Track

...it scrobbles:

Artist - Track

-Devin.

Edit: here's a track I had a hard time with:

http://www.last.fm/music/Sister+Rosetta+Th...aim+Jesus+First (http://www.last.fm/music/Sister+Rosetta+Tharpe/_/I+Claim+Jesus+First)

%artist% - %title% results in:

Sister Rosetta Tharpe, Sam Price Trio - I Claim Jesus First

If i change %artist% to $meta(artist,0) in lines 42 and 47 in the WSH configuration window, this track will show up as "Loved" (but the script doesn't return playcount data for ANY tracks anymore)... if I leave it alone, I get nothing returned for this track (no playcount and no indication that it's a loved track), but other tracks unaffected by this quirk work properly.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2010-12-24 11:56:28
if you just change line 42 then that should work for you. don't change line 47 as that needs to match the database configuration which you don't really want to mess with.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: blogbourri on 2010-12-24 18:19:35
Worked, thanks.

-Devin.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-01-05 18:52:50
new version uploaded.

http://cid-649d3bfeaf541fbb.office.live.co...ount%20sync.zip (http://cid-649d3bfeaf541fbb.office.live.com/self.aspx/.Public/foobar/guide/playcount%20sync.zip)

nothing new, just a little tidying up.

-moved a few context menu items into sub-menus so they make more sense.
-updated documentation explaining auto-correction limitations when doing a library import

anybody upgrading must make sure they extract the new scripts folder from the zip and import the new playcount sync.txt file. you can delete sqlite3.exe and lastfm_sql.cmd from the foobar root directory. i've placed new copies inside the scripts folder to keep the root directory a little cleaner. don't move the old files as i've made some changes.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Steve Forte Rio on 2011-01-23 10:53:59
Again, can't setup it for user-separated config

After importing of script text, wsh panel don't show any icon, only "set api key" "set lastfm username", etc. in the context menu
Library import commands are unavailable

here is info from console:

Code: [Select]
WSH Panel Mod (Playcount Sync by marc2003): Parsing file "C:\Users\Администратор\AppData\Roaming\foobar2000\\marc2003\common.js"
WSH Panel Mod (Playcount Sync by marc2003): Parsing file "C:\Users\Администратор\AppData\Roaming\foobar2000\\marc2003\tooltip_buttons.js"
WSH Panel Mod (Playcount Sync by marc2003): initialized in 35 ms
WSH Panel Mod (Playcount Sync by marc2003): Parsing file "C:\Users\Администратор\AppData\Roaming\foobar2000\\marc2003\common.js"
WSH Panel Mod (Playcount Sync by marc2003): Parsing file "C:\Users\Администратор\AppData\Roaming\foobar2000\\marc2003\tooltip_buttons.js"
WSH Panel Mod (Playcount Sync by marc2003): initialized in 3 ms


marc2003 and playcount sync folders are placed into foobar2000 profile folder

add:

The same problem even with portable foobar2000:

Code: [Select]
WSH Panel Mod (Playcount Sync by marc2003): Parsing file "E:\Program Files\foobar2000\\marc2003\common.js"
WSH Panel Mod (Playcount Sync by marc2003): Parsing file "E:\Program Files\foobar2000\\marc2003\tooltip_buttons.js"
WSH Panel Mod (Playcount Sync by marc2003): initialized in 4 ms
WSH Panel Mod (Playcount Sync by marc2003): Parsing file "E:\Program Files\foobar2000\\marc2003\common.js"
WSH Panel Mod (Playcount Sync by marc2003): Parsing file "E:\Program Files\foobar2000\\marc2003\tooltip_buttons.js"
WSH Panel Mod (Playcount Sync by marc2003): initialized in 4 ms


What's wrong?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-01-23 11:12:12
do you have a playlist with something in? it won't show a button if there are no playlists or if the playlist is empty.

edit: i've just tested with "Администратор" in the path and that works fine as well.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Steve Forte Rio on 2011-01-23 11:26:54
Quote
do you have a playlist with something in?


Oh, sorry, I forgot it. Thanks for reminding

Hope now it will work fine...
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Steve Forte Rio on 2011-01-23 11:44:48
Code: [Select]
working....
Error: unable to open database "C:\Users\└фьшэшёЄЁрЄюЁ\AppData\Roaming\foobar2000\customdb_sqlite.db": unable to open database file



the same problems with custom_db and cyrillic characters
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-01-23 12:49:55
i guess that's because i'm working from the command line to update the DB. i don't think there is anything i can do about that.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: thuan on 2011-01-23 13:16:21
Marc, have you tried to use short path in your code? I haven't taken a look at your code but I solved the same problem with wget using Windows short path.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-01-23 14:30:41
^thanks for that. it should now be fixed.

@Steve, you'll need to download and extract the folder contents again and import the updated script.

and now it displays a button even with empty playlists so as not to confuse people.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Steve Forte Rio on 2011-01-23 15:12:05
Excellent!
Thank you guys.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-02-04 22:51:03
if anybody has upgraded to the latest version of foo_softplaylists and finds their "love/unlove" button not working anymore, you need to replace line 46 with this....

Code: [Select]
command = "Last.fm " + (old_userloved == 1 ? "Unlove" : "Love") + " Track '" + track + "' by '"+ artist + "'";


Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: JohanDeBock on 2011-02-05 14:34:50
if anybody has upgraded to the latest version of foo_softplaylists and finds their "love/unlove" button not working anymore, you need to replace line 46 with this....

Code: [Select]
command = "Last.fm " + (old_userloved == 1 ? "Unlove" : "Love") + " Track '" + track + "' by '"+ artist + "'";


Is it only possible with this command or does "Last.fm Love Track" also work?
Normally I leave this command unchanged (given by get_item_name).
But if the displayed command (given by context_get_display) only works I must remeber to not change it also.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-02-05 14:45:22
because it's triggered through a WSH panel mod function called fb.RunContextCommandWithMetadb(), it has to be an exact text match to what is displayed on the context menu.

it's no issue at all really (so long as you don't change it on every release  - please    ).
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zageron on 2011-02-07 20:33:20
Every time I close foobar.
(http://i.imgur.com/moBDT.png)

Edit: By the way this is amazing! Thanks so much for supplying the public with this plugin. It makes recording play counts and song information so easy, especially cross-computer/cross-format.

:]
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-02-07 20:48:24
well that has to be a component error of some sort. if you're sure that error has only appeared since you installed this package maybe you can try and isolate which component causes that? try removing each one in turn until the error goes away? (wsh panel mod, foo_softplaylists, foo_customdb)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zageron on 2011-02-07 21:59:02
The recent soft-playlist update, seems to have fixed it. Will update if it comes back. (It's been giving me an error ever since I installed your addon.) (Like in December)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Maeldun on 2011-02-14 21:47:36
Hello,

I have followed your instructions to the letter, installed the script and it seems to be functioning... but I'm not getting any increased playcounts. It's been almost a month since I started using it, and playcount stats remained at a normal level, despite listing on a daily basis.

The console reports everything is working the way it's supposed to, but still nothing happens.

Console Screenshot (http://img35.imageshack.us/i/clipboard01an.gif/)

Am I doing something wrong?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-02-14 22:28:31
well i don't know what's going on there. the fact it says "OK" means the value is different from before.

anyway, find line 113 in the script. it should be this....
Code: [Select]
    if(fb.IsPlaying && time_elapsed >= target_time) {


now insert these 2 lines directly after it....

Code: [Select]
        fb.trace("Old value: " + old_userplaycount);
        fb.trace("New value: " + userplaycount);


now see what the console says after a few more plays.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: uberkrieg on 2011-02-15 20:34:39
Hi. this is a great tool and I've been looking for something like this for a very long time.
I've been trying to get it working under wine in linux for a few days now and I followed the instructions but when I try to input my username/API key I don't get a window or anything to actually input it (a wine problem obviously).
I've been reading this thread and read about an external files that holds this information. could you tell me where is it located and exactly what name should I give to it and what information should I put in said file? I tried changing it at the beginning of the script (var username_file = settings_path + "username"; var api_key_file = settings_path + "api_key";) but that doesn't seem to work at all.

the script seems to be working fine, but I'm stuck here according to foobar console.  "Playcount sync: Can't contact Last.fm. Check your username / API KEY settings. " and since I can't actually input that information, well, you can imagine.

Thanks a lot.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Maeldun on 2011-02-15 22:46:58
well i don't know what's going on there. the fact it says "OK" means the value is different from before.

anyway, find line 113 in the script. it should be this....
Code: [Select]
    if(fb.IsPlaying && time_elapsed >= target_time) {


now insert these 2 lines directly after it....

Code: [Select]
        fb.trace("Old value: " + old_userplaycount);
        fb.trace("New value: " + userplaycount);


now see what the console says after a few more plays.


Hello,

I've implemented the code, and the console now displays the "old" and "new" last.fm playcount values. From what I could tell, the big problem in my case seems to be that foobar doesn't save this value.

New console display (http://img522.imageshack.us/i/clipboard01gz.png/)

In the screenshot I've posted you can see that I've been playing songs from the same artist, that (at least for the tracks I've played so far) should have combined playcounts that are supposed to go way over the "31" that facets reports (the number of real foobar plays). Also, I've played the last song twice, to see if I would get a "?" for an old value twice (as if this was played for the first time, i suspect). As you can see,  the correct number of last.fm plays is reported (27, then 28) yet foobar doesn't save this value anywhere, treating the track as if it was played for the first time.

Am I making sense here? What do I need to do?

Thanks for your time.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: BrutuZ on 2011-02-16 00:47:27
Your screenshot isn't very clear (shouldn't have shrunk it). This may sound silly, but since I couldn't get a clearer picture I'll ask:
1- Are you using "%LASTFM_PLAYCOUNT_DB%" vlaue to display the count?
2- You understand that the counts are stored for each track individually on CustomDB. Therefore if you are referring to the "album playcount" on the Facets, which probably counts by the built-in Playback Satistics Plugin, it will completely disregard the Last.fm statistics unless you import them to Statistics tags in the files or have any way to make it read the "%LASTFM_PLAYCOUNT_DB%" value intead of standard %play_count%.

Sorry if any of this sound obvious to you, but there is no way to know how deep you understand the program without asking these, just trying to help.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-02-16 00:52:54
where are you expecting to see these values? i don't see any custom columns in your layout. 

from the manual....

Quote
8)   Lastly, you’ll need to configure your playlist (or some other panel) to show the data.

//this is what you use to display the play count.
[%LASTFM_PLAYCOUNT_DB%]

//show if a track is loved
$ifequal(%LASTFM_LOVED_DB%,1,♥,)


EDIT: doh, brutuz beat me to it.

@uberkrieg, you can set the variables by replacing lines 19 & 21

Code: [Select]
var username = "marc2003";

var api_key = "abcdef....";


i would be amazed if you got this running in WINE though.  if you do get it working, let me know how you did it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: uberkrieg on 2011-02-16 03:28:54
@uberkrieg, you can set the variables by replacing lines 19 & 21

Code: [Select]
var username = "marc2003";

var api_key = "abcdef....";


i would be amazed if you got this running in WINE though.  if you do get it working, let me know how you did it.


hey, thanks for your answer.
I tried that but it didn't work. I got the login information to work by copying the username and api_key files from a windows install to wine. now the script seems to be working but not completely. I can love/unlove songs in my playlist, but now the problem is the actual playcount doesn't seem to be working. I used database from the windows install after importing all the playcounts from my account on last.fm and they showed in foobar, but when I hit play and the script contacts last.fm,  it resets the playcount to 1 no matter what the previous number was. any ideas/suggestions? I'll keep investigating.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-02-16 03:39:52
so the script is contacting last.fm and getting a response? how did you get that far? i seem to remember the last time i tried WSH panel mod on foobar/WINE, i got all sorts of errors like "Automation server can't create object".
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: uberkrieg on 2011-02-16 04:11:12
so the script is contacting last.fm and getting a response? how did you get that far? i seem to remember the last time i tried WSH panel mod on foobar/WINE, i got all sorts of errors like "Automation server can't create object".


WSH seems to be working without that much fixing around. at least it loads this script. I did get a lot of crashes during the first attempts of running it but it was because the script was looking for a registry key that wasn't there, so after creating it, it worked. the script "seems" to be contacting last.fm but I'm not really sure. I think the love/unlove part works because its based on soft playlists and that plugin works flawlessly as far as I know, so I'm not sure who is actually doing the last.fm contact there. when it comes to the actual play count update, it says its contacting last.fm and getting a response but it resets the playcount to 1 so I'm not really sure whether the contact is being made or the script things its being made and that's why it keeps reseting the playcount to 1.

if there's anyone else interested in getting this working under wine what I've managed to do so far is doing the complete library update in windows (you have to have access to your library from both win and linux) and getting all your playcounts from last.fm. then copy that database to your linux install and use the masstagger to import those playcounts to %play_count% or any other tag you prefer BEFORE actually playing your files because as you play them, this script is going to reset those play counts you imported from window back to 1.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: berong91 on 2011-02-16 14:16:30
hello marc2003, it's seem that the last sync script has something wrong with me.
i added those line like you said.
http://www.hydrogenaudio.org/forums/index....mp;#entry742331 (http://www.hydrogenaudio.org/forums/index.php?showtopic=76772&st=475&p=742331&#entry742331)
http://www.hydrogenaudio.org/forums/index....mp;#entry743685 (http://www.hydrogenaudio.org/forums/index.php?showtopic=76772&st=475&p=743685&#entry743685)

the last.fm playcount and love/unlove still doesn't work . The last.fm system is fine, when i played a song, then import sql again, and the %LASTFM_PLAYCOUNT_DB% increase, but the tag doesnt change.

picture with console:
playcount : http://img265.imageshack.us/img265/4825/11796623.png (http://img265.imageshack.us/img265/4825/11796623.png)
love/unlove : http://img593.imageshack.us/img593/7358/45464662.png (http://img593.imageshack.us/img593/7358/45464662.png)

i guess this error happend when replace old tag %LASTFM_PLAYCOUNT_DB% and %LASTFM_LOVED_DB%

my component :
foo_customdb.dll (2009-05-09 12:17:06 UTC)
    Custom Database 0.0.9a

foo_softplaylists.dll (2011-02-04 21:04:50 UTC)
    Soft Playlists 2011-02-05

foo_uie_wsh_panel_mod.dll (2011-01-08 08:11:34 UTC)
    WSH Panel Mod 1.4.2
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-02-16 14:44:22
there is a newer version of foo_customdb - you could try that. http://blog.99ravens.net/index.php?e=283 (http://blog.99ravens.net/index.php?e=283)

and are you sure you've followed this from the readme? i don't know what else it could be.

Quote
Usage:

Note: Do not hide Last.fm or Legacy commands (unsorted) in your context menu options. The script needs these enabled to work.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: berong91 on 2011-02-16 15:22:35
Quote
Note: Do not hide Last.fm or Legacy commands (unsorted) in your context menu options. The script needs these enabled to work.

arrhh it's clear the problem 

thanks you for your great work! 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Maeldun on 2011-02-16 22:27:15

Your screenshot isn't very clear (shouldn't have shrunk it). This may sound silly, but since I couldn't get a clearer picture I'll ask:
1- Are you using "%LASTFM_PLAYCOUNT_DB%" vlaue to display the count?
2- You understand that the counts are stored for each track individually on CustomDB. Therefore if you are referring to the "album playcount" on the Facets, which probably counts by the built-in Playback Satistics Plugin, it will completely disregard the Last.fm statistics unless you import them to Statistics tags in the files or have any way to make it read the "%LASTFM_PLAYCOUNT_DB%" value intead of standard %play_count%.

Sorry if any of this sound obvious to you, but there is no way to know how deep you understand the program without asking these, just trying to help.



Yes, right, my bad. I forgot to mention that I'm a Foobar noob. I've only been using it for about a month or two. Nothing sounds too obvious to me.

I was under the impression that the script would update the playcount meta tag that is used within the file viewer (or within facets or any other playlist viewer) by itself.

I've implemented the custom playlist columns, and I had to redo step 3 of the tutorial to get it working.But it is working now.


Thanks
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: BrutuZ on 2011-02-17 01:05:50
@uberkrieg & @marc2003: I don't mean to fiddle with the pro's stuff, but couldn't that last bug be caused by the SQLite calls? I mean, does that SQLite client work under WINE? Maybe it doesn't but there probably is an alternative, or is just a matter of fiddling wwith settings. Or maybe i'm just saying bs, so i'll shut up now 

@maeldum: Glad I could help somehow
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-02-17 02:48:46
i don't believe it..... i tried it and it works. i did have to install a lot of stuff through a script called winetricks to get me started though.

(http://k5sbdw.blu.livefilestore.com/y1pLT6hIDsM_92LkBArVzstN0O-imBaiAT6FKAghDANbQMC59oRf2H3uEkN_SlBm3fCsaERxeB3FRYhr8vLu4MJLeQEn8BVrQuN/lastfm%20wine.png)

@uberkrieg, did you make sure sqlite3.exe inside the "marc2003" folder is executable?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: uberkrieg on 2011-02-17 03:22:00
i don't believe it..... i tried it and it works. i did have to install a lot of stuff through a script called winetricks to get me started though.



I tried that but it makes no difference, I'm still getting my play counts reset to 1. was about to do a clean wine install and start from scratch to see if that made any difference, but I'm going to put that on hold until I get what you did. 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-02-17 03:52:36
this is how i got it working on ubuntu 10.10. i deleted my .wine folder and tested again to be sure....

1) run the "configure tool" so your wine folder gets created again.
2) download and save this as "winetricks" http://www.kegel.com/wine/winetricks (http://www.kegel.com/wine/winetricks)
3) open a terminal and navigate to where you saved the above file and run

sh winetricks

4) select these packages

gdiplus
ie6
msxml3
winhttp
wininet
wsh56

5) copy your foobar2000 folder to somewhere on the wine c drive. make sure foobar2000.exe is executable (likewise for sqlite3.exe inside the "marc2003" folder)
6) that's it.

BTW, i use columns UI because i find default UI redrawing of panels/toolbars to be very glitchy.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: uberkrieg on 2011-02-17 05:47:01
this is how i got it working on ubuntu 10.10. i deleted my .wine folder and tested again to be sure....

1) run the "configure tool" so your wine folder gets created again.
2) download and save this as "winetricks" http://www.kegel.com/wine/winetricks (http://www.kegel.com/wine/winetricks)
3) open a terminal and navigate to where you saved the above file and run

sh winetricks

4) select these packages

gdiplus
ie6
msxml3
winhttp
wininet
wsh56

5) copy your foobar2000 folder to somewhere on the wine c drive. make sure foobar2000.exe is executable (likewise for sqlite3.exe inside the "marc2003" folder)
6) that's it.

BTW, i use columns UI because i find default UI redrawing of panels/toolbars to be very glitchy.


you are a god among men my friend. I can confirm that this works perfectly. thanks you very very much.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-02-17 11:42:48
one thing i forgot to mention incase anybody else wants to try this and that's how to get around this....

I did get a lot of crashes during the first attempts of running it but it was because the script was looking for a registry key that wasn't there


just open "marc2003\common.js" in a text editor and on line 349, replace

Code: [Select]
var font = WshShell.RegRead("HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProductName") == "Microsoft Windows XP" ? "Tahoma" : "Segoe UI";


with this...

Code: [Select]
var font = "Tahoma";


(the line could be commented out as it's not required for this script but i've left it in because i've got all my other last.fm related scripts running as well)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Bryter on 2011-02-21 22:46:41
Ive just tried creating a column that will show loved tracks using esplaylist. I used the
"//this is what you use to display the play count.
[%LASTFM_PLAYCOUNT_DB%]

//show if a track is loved
$ifequal(%LASTFM_LOVED_DB%,1,♥,) "

but nothing is showing in the column. This code works flawlessly with NGplaylist. Any sugestions?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-02-21 22:55:55
all i can say is..."you're doing it wrong". if it works in one component then it must work everywhere else.....

FWIW, i use EsPlaylist myself...

(http://k5sbdw.blu.livefilestore.com/y1prId8se3eZqIifcXga82m0p7KonKqpOE_ApsQn22Y2JnkWS_BvGEvlToB3HjeG_SkzWxz9XeuRIdfvK8PM63dmikYrzIMMU8O/lastfm%20esp.png)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Bryter on 2011-02-21 23:05:06
I had to change the fonts to Unicode and now it is working.
Thanks Marco, you're the best
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: vogueblackheart on 2011-02-22 02:50:45
Hello. Looked around for other reports of this, did the whole procedure twice, but got this console error both times:

'settings_path' is undefined

..Am I doing something dumb?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-02-22 03:19:51
oops, it looks like i've stuffed up the readme file by deleting something i shouldn't have.

you need to extract the "marc2003" folder from the zip into your foobar profile folder.

standard install: %appdata%\foobar2000
or inside the main foobar folder if portable

i'll get the corrected readme uploaded ASAP. 

edit: fixed version uploaded and apologies for the confusion.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: vogueblackheart on 2011-02-22 04:04:26
Thanks! Worked!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Fractal_Mortality on 2011-02-25 00:51:58
Marc, I can't possibly ask you to do this but... Would you be able to give me your latest version of this script with file tag writing instead of foo_customdb?

The version I had been using seems to be broken. If you don't have time, I perfectly understand, as I can't expect you to coddle one user that likes to do things differently.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Fractal_Mortality on 2011-02-25 00:53:06
edit: double post
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-02-25 01:30:01
you've caught me in a good mood. i'll have a go at it later on.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-02-25 11:03:42
ok, here: http://cid-649d3bfeaf541fbb.office.live.co...ging%20mode.txt (http://cid-649d3bfeaf541fbb.office.live.com/self.aspx/.Public/foobar/guide/playcount%20sync%20file%20tagging%20mode.txt)

i'm sure you know the drill by now but a few reminders anyway....

-no library import support
-requires "marc2003" folder saved in %appdata%\foobar2000 (you already have this from using my autoplaylists sample the other day. it's also contained in the zip linked on the first post of this thread)
-you can customise the file tag names at the start of the script - obviously alter your columns to match
-right click the panel to set your username/api key
-you now have support for auto-correction. but if you turn it off on the website, you need to make sure you turn it off on the script as well (again using the context menu)
-you can now unlove tracks
-it now runs at the same time a scrobble would count so the playcounts should always be in sync.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: PrimulaRosea on 2011-02-25 13:19:52
Code: [Select]
Skipping track...
Error: WSH Panel Mod (Playcount Sync by marc2003): Microsoft JScript runtime error:
Object required
Ln: 83, Col: 3
<source text only available at compile time>
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-02-25 13:35:26
i'm assuming that's a problem with the file tagging version i posted above?

i don't have any problems using the main version with foo_skip. i'll look into it....
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: PrimulaRosea on 2011-02-25 13:39:55
nevermind, seems it's because my files is read only (some of them inside a zip file)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-02-25 13:46:39
i've just checked and it is a problem that will happen with the file tagging script with foo_skip/rating set to 1 with any file. i've updated it - same link as above.

EDIT: i've double checked with zipped files, foo_skip enabled and a rating of 1.

just to be clear again, this does not affect the main script in the OP that uses foo_customdb.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Fractal_Mortality on 2011-02-25 13:51:26
ok, here: http://cid-649d3bfeaf541fbb.office.live.co...ging%20mode.txt (http://cid-649d3bfeaf541fbb.office.live.com/self.aspx/.Public/foobar/guide/playcount%20sync%20file%20tagging%20mode.txt)

i'm sure you know the drill by now but a few reminders anyway....

-no library import support
-requires "marc2003" folder saved in %appdata%\foobar2000 (you already have this from using my autoplaylists sample the other day. it's also contained in the zip linked on the first post of this thread)
-you can customise the file tag names at the start of the script - obviously alter your columns to match
-right click the panel to set your username/api key
-you now have support for auto-correction. but if you turn it off on the website, you need to make sure you turn it off on the script as well (again using the context menu)
-you can now unlove tracks
-it now runs at the same time a scrobble would count so the playcounts should always be in sync.


<3 forever
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: eminn3m on 2011-02-27 01:42:35
First thanks for such an ingenious solution to something I've wanted to do for awhile.

I'm having problems with the script freezing when doing a full library import though. For example right now it's stuck at "Completed page 411 of 499 (playcount)" and hasn't advanced for an hour. When I try restarting foobar it pauses at other points (page 360 last time) but never seems to get to the end.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-02-27 02:35:34
hmmn, i really need to implement something a little more robust. my script expects last.fm to reply to every request in a timely fashion otherwise it just conks out. i have a few ideas on how to fix it but i won't be able to do it until monday. i'm currently away from home and i can barely navigate the internet with the crappy trackpad on my laptop let alone do anything more serious.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: eminn3m on 2011-02-27 02:41:17
hmmn, i really need to implement something a little more robust. my script expects last.fm to reply to every request in a timely fashion otherwise it just conks out.

No worries, glad to know it's not just me.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: thuan on 2011-02-27 09:50:54
hmmn, i really need to implement something a little more robust. my script expects last.fm to reply to every request in a timely fashion otherwise it just conks out. i have a few ideas on how to fix it but i won't be able to do it until monday. i'm currently away from home and i can barely navigate the internet with the crappy trackpad on my laptop let alone do anything more serious.

I'm also waiting to your solution to this problem. I did come to one (currently used in my code), but it works not quite well (it rarely crashed but heck it can). I have another solution in mind but it's too much rewrite that I haven't wanted to touch. Both do not rely on external supported interfaces or methods. If only I can find a way to use property timeout and method ontimeout here http://msdn.microsoft.com/en-us/library/ms...v=VS.85%29.aspx (http://msdn.microsoft.com/en-us/library/ms535874%28v=VS.85%29.aspx) but I couldn't.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-02-27 10:04:43
i was thinking of writing the results to file after every page is fetched. so if it stops, the user can start it again from a page of their choosing.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: eminn3m on 2011-02-27 22:11:13
I got it work by waiting and doing it a different time. Amazing plugin, I was able to retrieve 227 extra days of listening statistics compared to what I had saved locally.  This is awesome because now when listening to unplayed tracks, I can come closer to truly getting unplayed tracks. Thanks!

Question: Is there anyway to bulk love tracks that I rated good on my end (ie. sync ratings back to last.fm)? Also is there anyway to simultaneously rate a track as %rating% and love it on last.fm at the same time? When I try double assigning the keyboard shortcut I use only one of them works.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: thuan on 2011-02-28 03:37:12
i was thinking of writing the results to file after every page is fetched. so if it stops, the user can start it again from a page of their choosing.

Hum, the recent last.fm server outage caused my script to hang indefinitely on http request because I have no way to timeout the operation with available methods and stuffs. I think your method solve a different case than this one.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-02-28 07:48:41
i doubt i'll be able to implement timeouts either which is why i want to save each page to file. then if it conks out on page 411 of 499, the user won't have to start again from scratch which i think will be quite helpful. obviously it will require manual intervention from them watching the console but i don't really know how else to solve it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: BrutuZ on 2011-03-01 00:18:45
Couldn't you just output the last fetched (is this a word?) page number to the first line of the said file besides the console? That way when running the script, it checks if the cache file exists, if so, it then kicks into "continue mode", picking up at the page written on the file. Upon succesfull fetching of all pages the cache file is then deleted and the world moves on
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-03-02 23:25:45
new version uploaded: http://cid-649d3bfeaf541fbb.office.live.co...ount%20sync.zip (http://cid-649d3bfeaf541fbb.office.live.com/self.aspx/.Public/foobar/guide/playcount%20sync.zip)

library import: now retries automatically if last.fm stops responding. does not require any user interaction.

i tested with a few different 50,000+ track libraries (not mine) and all went ok.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: eminn3m on 2011-03-03 19:13:23
Thanks for the update! Any idea about bulk syncing highly rated tracks to last.fm?

BTW: Any thought of putting a donation link up for your hard work?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-03-03 19:45:38
there is no proper way to bulk submit loved tracks. having said that, you could modify the script to automatically love tracks as they are played if they meet certain criteria. i did have this feature in a very old version of this script. i could tell you how to do that if you're interested.

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-03-03 21:17:09
new version: http://cid-649d3bfeaf541fbb.office.live.co...ount%20sync.zip (http://cid-649d3bfeaf541fbb.office.live.com/self.aspx/.Public/foobar/guide/playcount%20sync.zip)

auto-love track feature brought back from the dead. it's off by default but you configure it using the context menu. the "condition" dialog will give you info on how to use it. if enabled, it waits until 3 seconds of the track has played before it runs.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: eminn3m on 2011-03-03 22:42:30
new version: http://cid-649d3bfeaf541fbb.office.live.co...ount%20sync.zip (http://cid-649d3bfeaf541fbb.office.live.com/self.aspx/.Public/foobar/guide/playcount%20sync.zip)

auto-love track feature brought back from the dead. it's off by default but you configure it using the context menu. the "condition" dialog will give you info on how to use it. if enabled, it waits until 3 seconds of the track has played before it runs.


You are a scholar and a gentleman. Can't wait to try this out.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zageron on 2011-03-04 04:13:14
Any chance that in future updates you can let us know which files need to be replaced? It isn't much work to replace everything but, you know...

Thanks for the hard work, I love this program. (Although I still get an error when I quit foobar.)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-03-04 09:29:45
always import "playcount sync.txt" into the panel. that changes on every update.

and that should be enough 99.9% of the time. i try not to change anything else unless i have to. i usually mention in the post if the "marc2003" folder needs extracting again. and the configuration folder (foo_customdb.dll.cfg) never changes (well it has once but that was  a major change and is unlikely to happen again).

as for your error, all i can suggest is making sure your components are the latest. what actually happens?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zageron on 2011-03-05 03:02:57
always import "playcount sync.txt" into the panel. that changes on every update.

and that should be enough 99.9% of the time. i try not to change anything else unless i have to. i usually mention in the post if the "marc2003" folder needs extracting again. and the configuration folder (foo_customdb.dll.cfg) never changes (well it has once but that was  a major change and is unlikely to happen again).

as for your error, all i can suggest is making sure your components are the latest. what actually happens?


As long as foobar has attempted access to Last.fm at least once, when I close foobar:
***
Runtime Error!

Program: C:\Program Files (x86)\foobar2000\foobar2000.exe

R6025
- pure virtual function call

*Press OK*

foobar2000 has stopped working
A problem caused the program to stop working correctly. please close the program.
CLOSE THE PROGRAM.
***
Nothing else.

Code: [Select]
Faulting application name: foobar2000.exe, version: 1.1.5.0, time stamp: 0x4d6aa984
Faulting module name: foobar2000.exe, version: 1.1.5.0, time stamp: 0x4d6aa984
Exception code: 0x40000015
Fault offset: 0x0013d397
Faulting process id: 0xa88
Faulting application start time: 0x01cbdaac5dbb77ce
Faulting application path: C:\Program Files (x86)\foobar2000\foobar2000.exe
Faulting module path: C:\Program Files (x86)\foobar2000\foobar2000.exe
Report Id: 26f25a6c-46d4-11e0-afed-005056c00008
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: thuan on 2011-03-05 04:10:53
@Zageron: Which OS are you using? I'm on Windows 7 64bit and I have the same error, thinking this is an error that happens with certain combination of OS version/flavor and foo_customdb.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-03-05 04:33:25
I'm on Windows 7 64bit and I have the same error


that's my main OS and i've never seen that error. i also use windows XP SP3 (x86) and windows XP SP2 (x64) a lot and again, not a single problem.

latest component versions:
Code: [Select]
foo_customdb.dll (2010-03-04 13:10:54 UTC)
    Custom Database 0.1.0_beta1
foo_softplaylists.dll (2011-02-05 09:23:59 UTC)
    Soft Playlists 2011-02-05
foo_uie_wsh_panel_mod.dll (2011-01-08 08:11:34 UTC)
    WSH Panel Mod 1.4.2
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zageron on 2011-03-05 04:51:35
I'm on Windows 7 64bit and I have the same error


that's my main OS and i've never seen that error. i also use windows XP SP3 (x86) and windows XP SP2 (x64) a lot and again, not a single problem.

latest component versions:
Code: [Select]
foo_customdb.dll (2010-03-04 13:10:54 UTC)
    Custom Database 0.1.0_beta1
foo_softplaylists.dll (2011-02-05 09:23:59 UTC)
    Soft Playlists 2011-02-05
foo_uie_wsh_panel_mod.dll (2011-01-08 08:11:34 UTC)
    WSH Panel Mod 1.4.2



I also use that OS.

Code: [Select]
foo_audioscrobbler.dll (2010-11-26 22:49:20 UTC)
    Audioscrobbler 1.4.7
foo_customdb.dll (2011-01-04 06:54:45 UTC)
    Custom Database 0.1.0_beta1
foo_softplaylists.dll (2011-02-07 21:55:38 UTC)
    Soft Playlists 2011-02-05
foo_uie_wsh_panel_mod.dll (2011-01-04 06:54:48 UTC)
    WSH Panel Mod 1.4.0


I will update my WSH and come back.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zageron on 2011-03-05 05:06:45
That was the problem. I can't reproduce the error anymore. I'll let you know if it arises again.

Thanks for that. I assumed because foobar didn't update the component that it was up to date.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: laokin28 on 2011-03-24 07:20:41
Hi,

I'm searching for the foo_customdb component, but I can't find it, all links lead to the same site, which returns error 404 ^^
Could someone upload it somewhere or give it to me?
Thanks
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-03-24 11:42:57
http://cid-649d3bfeaf541fbb.office.live.co...5E_customdb.zip (http://cid-649d3bfeaf541fbb.office.live.com/self.aspx/.Public/foobar/foo%5E_customdb.zip)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: jahtimes on 2011-03-24 19:23:32
I got a problem : I don't know where I have to put this :

//this is what you use to display the play count.
[%LASTFM_PLAYCOUNT_DB%]
//show if a track is loved
$ifequal(%LASTFM_LOVED_DB%,1,♥,)   

Can you answer me ?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zageron on 2011-03-24 21:14:51
I got a problem : I don't know where I have to put this :

//this is what you use to display the play count.
[%LASTFM_PLAYCOUNT_DB%]
//show if a track is loved
$ifequal(%LASTFM_LOVED_DB%,1,?,)   

Can you answer me ?


- Library, Configure. (Or File, Preferences)
- Go to Display, Default User Interface, Playlist View.
- Under Custom Columns add those two.
Name | Patterns | Alignment
? | $ifequal(%LASTFM_LOVED_DB%,1,?,) | center
Plays | [%LASTFM_PLAYCOUNT_DB%] | center

I hope you can figure that much out! :]

One you have those:
- Right click on the Playing, Title, Artist, Filename, Duarion, blablabla sorting bars in the top of the playlist view window bar. (Right clicking on any of them will do)
- Click Columns
- Check ?, and Plays.

Have fun organizing everything. :]
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: jahtimes on 2011-03-25 11:13:59
Thanks, this was simple, i'm a newbie sorry...

I have one more question, I have an iPod 5G, I wonder if all my played tracks can be updated on Last.FM. I didn't find a subject on that. When I use Itunes, I see my "playcount", is it possible that this "playcount" may be updated on Last.FM ?

For example I have "Soudtrack to fail in love - Charlie Winston" played 22 times. Is it possible, when i connect my iPod that on my profile last.FM, to see that Soundtrack to fail in love has been playing 22 times ?

Sorry for my english. I didn't find a subject on this thread precisely !

Thanks again.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-03-25 11:20:48
i don't have an ipod but have a look here...

foo_dop: http://www.hydrogenaudio.org/forums/index....showtopic=45160 (http://www.hydrogenaudio.org/forums/index.php?showtopic=45160)
foo_audioscrobbler: http://www.hydrogenaudio.org/forums/index....showtopic=44320 (http://www.hydrogenaudio.org/forums/index.php?showtopic=44320)

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zageron on 2011-03-25 17:23:49
Thanks, this was simple, i'm a newbie sorry...

I have one more question, I have an iPod 5G, I wonder if all my played tracks can be updated on Last.FM. I didn't find a subject on that. When I use Itunes, I see my "playcount", is it possible that this "playcount" may be updated on Last.FM ?

For example I have "Soudtrack to fail in love - Charlie Winston" played 22 times. Is it possible, when i connect my iPod that on my profile last.FM, to see that Soundtrack to fail in love has been playing 22 times ?

Sorry for my english. I didn't find a subject on this thread precisely !

Thanks again.


You'll want to have itunes, and get Last.FM's own audioscrobbler. That will sync up all of your previous iTunes plays with Last.FM.

Any other form of playcount tagging does not count toward your last.fm library until you begin scrobbling with the above links.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zageron on 2011-04-08 04:57:08
Does WSH v1.4.3 work with this plugin?

:]
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-04-08 07:26:52
yes.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: zjapam on 2011-04-13 16:06:49
I have a problem.

I followed exactly as  the readmefile says.
but when I do the Full library import, I can't update customdb_sqlite.db so that I can't get any synchronization with last.fmdb ,except that manualy updating LASTFM_LOVED_DB from context menu or with the LOVE buttom.(when I update field LASTFM_LOVED_DB manually, the field value is saved in customdb_sqlite.db correctly though)

When I am importing library, the console shows message "...Completed page 36 of 36 (playcount)" and It seems test.sql is made correctly.
Do you have any idea what is wrong with my process.

I used
fb2k v1.1.5
foo_customdb 0.1.0_beta1
WSH Panel Mod 1.4.2
Soft Playlists 2011-02-05

sorry for my English.


Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zageron on 2011-04-13 19:15:37
I have a problem.

I followed exactly as  the readmefile says.
but when I do the Full library import, I can't update customdb_sqlite.db so that I can't get any synchronization with last.fmdb ,except that manualy updating LASTFM_LOVED_DB from context menu or with the LOVE buttom.(when I update field LASTFM_LOVED_DB manually, the field value is saved in customdb_sqlite.db correctly though)

When I am importing library, the console shows message "...Completed page 36 of 36 (playcount)" and It seems test.sql is made correctly.
Do you have any idea what is wrong with my process.

I used
fb2k v1.1.5
foo_customdb 0.1.0_beta1
WSH Panel Mod 1.4.2
Soft Playlists 2011-02-05

sorry for my English.


Are you closing foobar, before activating the small CMD line window that pops up after the "36" pages have been processed?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: mhru154 on 2011-05-14 16:27:53
"automatically love tracks" is so convenient,thanks 
i don't need a love button,just give the tracks 5 stars and it'll automatically love when playing

sorry for my english
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: labou on 2011-05-14 22:54:35
this is pretty cool. thanks
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: WizzyKid on 2011-05-15 23:01:38
Heya, absolutely love this, big thanks for writing this all up. Very useful to me to have.

How would I go about creating a button to un-love tracks too however? That would be really nice to have, especially since last.fm itself doesn't allow you to mass un-love tracks.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zageron on 2011-05-15 23:10:44
Heya, absolutely love this, big thanks for writing this all up. Very useful to me to have.

How would I go about creating a button to un-love tracks too however? That would be really nice to have, especially since last.fm itself doesn't allow you to mass un-love tracks.


Pressing the heart will unlove the track, however a mass-love mass-unlove would be a cool feature!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-05-16 00:00:42
batch unlove? you shouldn't be so fickle changing your minds like that.

and although it's not possible to batch "love" tracks, you can setup automatic loving of tracks when they are played based on any criteria you can come up with using foobar title formatting.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: mhru154 on 2011-05-16 04:41:42
I want it automatically love tracks by rating 5 or 10+ plays
can i use 2 TF set?

sorry for my english
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-05-16 05:34:24
Code: [Select]
$ifequal(%rating%,5,1,$ifgreater(%LASTFM_PLAYCOUNT_DB%,9,1,0))


or if you want to use playcount from playback statistics then use %play_count%
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: mhru154 on 2011-05-16 06:09:00
thank you very much
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: mhru154 on 2011-05-16 07:24:33
Code: [Select]
$ifequal(%rating%,5,1,$ifgreater(%LASTFM_PLAYCOUNT_DB%,9,1,0))


or if you want to use playcount from playback statistics then use %play_count%

this works

and i also try with
Code: [Select]
$ifequal(%rating%,5,1,$ifequal(%LASTFM_LOVED_DB%,1,1,0))

but it doesn't work
what's wrong with my code

thanks in advance
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: mhru154 on 2011-05-16 16:16:32
Code: [Select]
$ifequal(%rating%,5,1,$ifgreater(%LASTFM_PLAYCOUNT_DB%,9,1,0))


or if you want to use playcount from playback statistics then use %play_count%

this works

and i also try with
Code: [Select]
$ifequal(%rating%,5,1,$ifequal(%LASTFM_LOVED_DB%,1,1,0))

but it doesn't work
what's wrong with my code

thanks in advance


http://www.last.fm/stationchanges2010 (http://www.last.fm/stationchanges2010)

Code: [Select]
So What's Changing at Last.fm?

The following subscriber-only radio stations will no longer be available:
Loved Tracks Radio: streaming your list of loved tracks
Playlists: streaming a list of tracks you've chosen for a playlist
Personal Tag Radio: streaming a list of artists, albums or tracks that you have tagged


wasting my time...
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-05-16 17:30:44
and i also try with
Code: [Select]
$ifequal(%rating%,5,1,$ifequal(%LASTFM_LOVED_DB%,1,1,0))

but it doesn't work
what's wrong with my code


this doesn't make any sense. the option is to automatically love tracks - what are you doing trying to love tracks that are already loved? btw, a side of effect of a track already being loved is that the action would actually unlove the track. i didn't for-see this outcome as i didn't think anybody would be daft enough.

Quote
<last.fm radio stuff>

wasting my time...


yes you are wasting time posting in a thread that has nothing whatsoever to do with last.fm radio. 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: WizzyKid on 2011-05-18 05:45:08
batch unlove? you shouldn't be so fickle changing your minds like that.

and although it's not possible to batch "love" tracks, you can setup automatic loving of tracks when they are played based on any criteria you can come up with using foobar title formatting.


Haha, sometimes music we listened to from years go doesn't really... well apply so much now.

My tracks won't 'unlove' when I click the love button, like Zageron said it should. Which is somewhat odd considering I could of sworn it used too. Hm...

EDIT: Aha, my WSH Panel mod doesn't seem to work anymore. I set up another button for setting skip on tracks as well, and that has also stopped working. The legacy commands work fine, just not the panels. I wonder why that isn't working anymore, I'm sure I haven't changed anything and I haven't updated my foobar since installing the components either.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zageron on 2011-05-18 09:38:12
batch unlove? you shouldn't be so fickle changing your minds like that.

and although it's not possible to batch "love" tracks, you can setup automatic loving of tracks when they are played based on any criteria you can come up with using foobar title formatting.


Haha, sometimes music we listened to from years go doesn't really... well apply so much now.

My tracks won't 'unlove' when I click the love button, like Zageron said it should. Which is somewhat odd considering I could of sworn it used too. Hm...

EDIT: Aha, my WSH Panel mod doesn't seem to work anymore. I set up another button for setting skip on tracks as well, and that has also stopped working. The legacy commands work fine, just not the panels. I wonder why that isn't working anymore, I'm sure I haven't changed anything and I haven't updated my foobar since installing the components either.

Make sure you are using 1.4.3
http://code.google.com/p/foo-wsh-panel-mod/downloads/list (http://code.google.com/p/foo-wsh-panel-mod/downloads/list)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: WizzyKid on 2011-05-22 11:02:33
That is the version I am using. I just tried deleting it, re-downloading it and putting it back in but still the same issue. :/

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-05-22 11:21:25
does loving tracks still work? also, the foo_softplaylists component which is used to love/unlove tracks leaves it own messages in the foobar console as to whether it's successful or not. have you checked there?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: WizzyKid on 2011-05-23 08:27:52
Loving and unloving tracks still works, just not from the panel mod.

When I had removed the WSH panel mod from my layout, then put it back on, the loved tracks panel crashes upon startup and I get the message:

Scripting Engine Initialization Failed (Playcount Sync by marc2003, CODE: 0x80020101)
Check the console for more information (Always caused by unexcepted script error).

In the console, I get the following:

Watching: X:\Documents\My Music\My Music Library
WSH Panel Mod (Playcount Sync by marc2003): Parsing file "C:\Users\Administrator.Zaks-PC\AppData\Roaming\foobar2000\marc2003\common.js"
WSH Panel Mod (Playcount Sync by marc2003): Parsing file "C:\Users\Administrator.Zaks-PC\AppData\Roaming\foobar2000\marc2003\tooltip_buttons.js"
Error: WSH Panel Mod (Playcount Sync by marc2003): Microsoft JScript runtime error:
Automation server can't create object
Ln: 359, Col: 1
<source text only available at compile time>
WSH Panel Mod ({511683A5-0876-4012-A61A-7E668A836948}): Parsing file "C:\Program Files (x86)\foobar2000\\scripts\dui_buttons.js"
WSH Panel Mod ({511683A5-0876-4012-A61A-7E668A836948}): initialized in 12 ms
Custom Database: Initialize
Custom Database: table quicktag already exists (1)
Custom Database: table database_version already exists (1)
Custom Database: index url_idx already exists (1)
Custom Database: Completed
Startup time : 0:00.395500
Seekbar: taking Direct2D1 path.
Seekbar: Frontend initialized.

For some reason the scripts won't initialise it seems, but I checked the directory and they're definitely there. I haven't modified them in anyway, and like I said, this used to work just fine until it stopped working about a week ago. :/
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-05-23 08:36:05
Quote
Automation server can't create object


this means you haven't disabled WSH panel mod "safe mode" in the foobar preferences. it does mention this in the readme.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: WizzyKid on 2011-05-23 16:18:15
Oh, that must of been re-enabled when I deleted the WSH panel mod and put that back in! Silly me.

Anywho, I'm back to the issue of the buttons not actually working now. I can't for the life of me figure this out. I haven't tinkered with the code in anyway, and it definitely leeds to my foobar2000 profile path. There's no errors in the console, and loving/unloving tracks works just fine through the legacy commands. I did reset my last.fm plays recently, perhaps that might have something to do with it?

Furthermore when I right mouse click on the love track panel and try to set my last.fm username or api key, nothing shows up there either. However, right mouse clicking on 'Visit your last.fm profile page' does work. There must be a conflict somewhere, but I just can't figure out where. I haven't installed any new components since I first started using this script.

Also, would just like to add I got my other panel to work, I must of ended up tinkering with the code at somepoint to try and make something else happen which is why that didn't work, so this doesn't seem to be an issue with the WSH Panel mod itself.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: スラッシュ on 2011-05-24 16:20:40
I don't know if this is related, but it seems like my script has stopped triggering soft_playlists. I am using the old one that still tagged the files, and it says the following in the console:

[17:17:52] Playcount sync: Auto-love is on. Triggering soft_playlists....

But nothing else happens. No message from soft_playlists, and (more importantly) no change on last.fm. I don't know when this changed, it seems like it was a while ago. My last loved track was in February (and I only love through this script).

EDIT: And safe mode is disabled.
EDIT2: I tried manually loving a track using softplaylists's menu command, and that worked... So there seems to be some kind of communication breakdown between the script and soft_playlist? Sorry about insisting on using such an outdated version, I know that's an annoying habit for a developer.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-05-24 17:24:38
foo_softplaylists did change the way it needs to be triggered a few months back. the script would have broken if you updated foo_softplaylists....

http://www.hydrogenaudio.org/forums/index....st&p=742331 (http://www.hydrogenaudio.org/forums/index.php?s=&showtopic=76772&view=findpost&p=742331)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: スラッシュ on 2011-05-24 17:39:59
Nice, it took a bit of jiggling since my version of your script is very old, so the placement wasn't quite the same (and it needed to be love_command instead of just command), but this was exactly the hint I needed, thanks!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: fominator on 2011-05-30 16:24:44
WTF????
(http://i22.fastpic.ru/big/2011/0530/c4/f6d5c01782985c944b624cfb97f8adc4.jpg)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-05-30 16:38:51
1) right click>configure and enable "pseudo transparency".
2) with the editor still open, edit the 2 variables "bw" and "bh" to 24. click ok.
3) right click the panel>background>none
4) hover the mouse over the panel and a tooltip which show you what you need to do.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: fominator on 2011-05-31 08:46:25
thank you!)
but in addition i changed this parameters too, now it's centered
is it right?

var top_margin = -2;
var left_margin = 13;

(http://i22.fastpic.ru/big/2011/0531/3b/e06f478e021b7a5fc2acabb33d39b43b.jpg)

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: WizzyKid on 2011-05-31 20:56:40
I tried removing all of my components and configuration files for them and even reinstalling foobar2000, and then re-downloading the components needed making sure they're the latest version, but I still have the same issue. Using the legacy commands through the menu works just fine, but the button simply won't work. I had copy and pasted the code exactly as it was in playcount sync.txt, and the marc203 folder is certainly in my foobar2000 profile folder. Like I said, this used to work, but for some reason it no longer does. When I try to set my last.fm username or API key, no box comes up for me to input them. :/

I must of done something wrong somewhere, but I just can't figure out what. I am certain I followed the instructions exactly as they were, I've gone through them several times. Also, safe mode is definitely disabled this time.

Ah well, if this is to be a mystery, I can live without it anyway. It is still a wonderful script though, and you have my thanks for creating it and helping me out.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Fractal_Mortality on 2011-06-10 23:40:19
Marc, this is really weird but... After installing Windows 7 service pack 1, I keep having this particular script crash after awhile. Here's what the console says:

"Error: WSH Panel Mod ({18BD462A-FB22-45A3-BC2D-828BD4187711}): msxml3.dll:
The download of the specified resource has failed."
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-06-11 07:11:59
i doubt the problem is related to SP1. i've been running that since it came out in february with no problems.

you haven't been tinkering trying to strip out Internet Explorer from your system? or maybe a temporary glitch at the last.fm server end? other than that, i have no idea.....
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Fractal_Mortality on 2011-06-12 00:42:41
i doubt the problem is related to SP1. i've been running that since it came out in february with no problems.

you haven't been tinkering trying to strip out Internet Explorer from your system? or maybe a temporary glitch at the last.fm server end? other than that, i have no idea.....


Nope to both.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Steve Forte Rio on 2011-06-13 16:30:41
Hello. My English is so poor that, I guess, I'll can't properly explain what exactly I want, sorry. But I hope you'll understand me.

All I need is to use %composer% tag in place of %artist%. So if I "love" track I want it to be added to lastfm database (and then downloaded the to local db) in format %composer% (not %artist%) - %title%, and I need the same for playcount of course. I replaced the %artist% with %composer% in audioscrobbler settings, but what should I do with playcount sync script (and custom db maybe)???
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-06-13 17:47:36
@Fractal_Mortality. sorry i have no idea then.

@Steve Forte Rio

file>preferences>tools>custom database>fields tab

edit each of the 2 entries to become

Code: [Select]
$crc32($lower(%composer%%title%))


restart foobar (very important).

then edit the script

Code: [Select]
line 62:
artist = fb.TitleFormat("%composer%").EvalWithMetadb(g_metadb);


Code: [Select]
line 67:
crc32 = fb.TitleFormat("$crc32($lower(%composer%%title%))").EvalWithMetadb(g_metadb);

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Steve Forte Rio on 2011-06-13 18:03:26
Thank you. Seems like playcount works fine for now. But now I can't love tracks with WSH button (it doesn't add anything to loved tracks, at all), only with context menu legacy command, but actually it loves %artist% - %title%

What would you advise me?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-06-13 18:07:10
ah sorry. that's a limitation of the foo_softplaylists component. it's hard-coded to use %artist% and %title% and can't be changed. maybe ask the author to add configurable fields?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Steve Forte Rio on 2011-06-13 18:10:55
As I expected.

Quote
maybe ask the author to add configurable fields?


Yes, I guess, this is the only way.

Anyway, thank you for you great script 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Snik4er on 2011-06-26 18:46:22
Nice!

How can i add Love Button in Default UI. I know how to do it with columns UI. but i want it in default thems? I neead a specific component or?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-06-26 18:57:38
you add panels using view>layout>enable layout editing mode. remember to turn the option off when finished.

http://wiki.hydrogenaudio.org/index.php?ti...ut_Editing_Mode (http://wiki.hydrogenaudio.org/index.php?title=Foobar2000:Layout_Editing_Mode)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-06-26 21:13:21
skydrive has gone to shite so i'm now using dropbox to host (and yes i'm aware of the security lapse they had this week but this is hardly sensitive.  )

could a moderator please replace the whole opening post with this....

//////////////////////////////////////////////////////////////////////////////
This isn't a plugin but a script which simply utilises 3 rather excellent components (WSH panel mod, foo_customdb and foo_softplaylists) to do the following:

-it can trigger foo_softplaylists to love/unlove tracks on last.fm via a button.
-it can automatically love tracks when they are played based on title formatting (for example, it can be set to automatically love tracks with a RATING of 5)
-it can import the playcount/loved tracks from your entire last.fm library into foobar. it uses foo_customdb so your files are not touched.
-after doing the library import it will automatically update in the background as you listen.
-works the same in both default and columns UI
-you can display/filter the data in any custom columns, library viewers, display panels, etc using these simple tags:

Code: [Select]
%LASTFM_PLAYCOUNT_DB%
%LASTFM_LOVED_DB% //has a value of 1 for loved tracks


full instructions can be found here: http://dl.dropbox.com/u/22801321/playcount%20sync.zip (http://dl.dropbox.com/u/22801321/playcount%20sync.zip)



Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: enigmatik on 2011-06-28 10:46:39
How to this whole thing on a portable foobar installation?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-06-28 10:59:40
from the readme:

Quote
3)   Extract the marc2003 folder from this zip into your foobar profile directory. On a standard foobar install this directory will be located at

%appdata%\foobar2000\

If using portable mode just dump it inside the main foobar install directory.

4)   If you’ve never used foo_customdb before then you should also extract the configuration folder to the same folder location as above.

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: enigmatik on 2011-06-28 11:08:55
from the readme:

Quote
3)   Extract the marc2003 folder from this zip into your foobar profile directory. On a standard foobar install this directory will be located at

%appdata%\foobar2000\

If using portable mode just dump it inside the main foobar install directory.

4)   If you’ve never used foo_customdb before then you should also extract the configuration folder to the same folder location as above.




Ah thanks. For some reason I haven't noticed that.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: enigmatik on 2011-06-28 20:39:52
Every time I click on Create and import SQL file, I get the message "Aww, crashed " Grr!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-06-28 20:50:29
main menu>view>console might give something more helpful...
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: venice26 on 2011-07-05 21:14:43
so I tried the whole thing today. I have the latest foobar version, Ive added latest versions of components as instructed and did all I should. I think

wsh mod added, library imported (even though wsh displayed a crash on the way) so it should be good. the only thing not matching the readme file is that the "legacy commands unsorted" do not contain the love and playcount commands (I copied the folder specified to the app data folder).
even though, loving the track by a foobar icon is shown on my last.fm profile which is great

still though, I cannot get the columns in my playlist to display neither playcount nor loved status (I created the columns with the code specified).
any ideas what I should do to make it work? maybe it was already discussed before but I did not manage to find it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-07-05 21:45:19
you haven't installed foo_customdb properly. the link is in section 2 of the readme.

edit: script now updated and will warn you when the aforementioned component is not installed. also, clarified readme a little to explain that you must check the legacy commands (unsorted) context menu commands exist before continuing.

http://dl.dropbox.com/u/22801321/playcount%20sync.zip (http://dl.dropbox.com/u/22801321/playcount%20sync.zip)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: venice26 on 2011-07-06 00:39:39
you were right, I made a mistake in one of the steps with custom database. the plugin works now just fine. thx very much for this awesome plugin and your help
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: sylvaedawn on 2011-07-06 15:41:20
hey marc, thanks for a great work...

unfortunately i'm having a problem =>

error message:

Code: [Select]
Scripting Engine Initialization Failed (Playcount Sync by marc2003, CODE: 0x80020101)
Check the console for more information (Always caused by unexcepted script error).


console:

Code: [Select]
WSH Panel Mod (Playcount Sync by marc2003): Parsing file "C:\Users\xxx\AppData\Roaming\foobar2000\marc2003\common.js"
WSH Panel Mod (Playcount Sync by marc2003): Parsing file "C:\Users\xxx\AppData\Roaming\foobar2000\marc2003\tooltip_buttons.js"
Error: WSH Panel Mod (Playcount Sync by marc2003): Microsoft JScript runtime error:
Automation server can't create object
Ln: 372, Col: 1
<source text only available at compile time>


as you previously (and in the read me) said, i unchecked, rechecked and unchecked "safe mode" in wsh panel mode several times to no avail - error persists

any help, pls?

edit:
versions of required components i installed:

wsh panel mod 1.4.3
custom database 0.1.0_beta1
soft playlists 2011-02-05
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: sylvaedawn on 2011-07-06 17:43:22
and i forgot to mention:
i'm using DarkOne v3.0.1 theme
(see picture with newly created panel for love/ban)

(http://i55.tinypic.com/2e58da9.jpg)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Falstaff on 2011-07-06 18:35:33
maybe the answer : http://www.hydrogenaudio.org/forums/index....st&p=680662 (http://www.hydrogenaudio.org/forums/index.php?s=&showtopic=76772&view=findpost&p=680662)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: sylvaedawn on 2011-07-06 19:47:31
maybe the answer : http://www.hydrogenaudio.org/forums/index....st&p=680662 (http://www.hydrogenaudio.org/forums/index.php?s=&showtopic=76772&view=findpost&p=680662)

as i wrote earlier, i did uncheck "safe mode", yet error still occurs
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-07-06 21:14:19
Quote
Automation server can't create object


if you really have disabled safe mode, then your windows is broken in such a way i wouldn't know know to fix. i assume you are definitely running windows and not WINE through linux?? your screenshot certainly looks like windows.....

does the panel crash if you clear all text and have this one line of code??

Quote
var WshShell = new ActiveXObject("WScript.Shell");

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: sylvaedawn on 2011-07-07 07:07:55
thank you, marc, for a quick answer.

Quote
if you really have disabled safe mode, then your windows is broken in such a way i wouldn't know know to fix. i assume you are definitely running windows and not WINE through linux?? your screenshot certainly looks like windows.....

Win7 x64

Quote
does the panel crash if you clear all text and have this one line of code??

var WshShell = new ActiveXObject("WScript.Shell");

yes, with almost the same messages =>

Code: [Select]
err msg:
Scripting Engine Initialization Failed ({AFD1C6E9-84EB-4FD7-A6A2-224AD9102730}, CODE: 0x80020101)
Check the console for more information (Always caused by unexcepted script error).

console:
Error: WSH Panel Mod ({AFD1C6E9-84EB-4FD7-A6A2-224AD9102730}): Microsoft JScript runtime error:
Automation server can't create object
Ln: 1, Col: 1
<source text only available at compile time>
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-07-07 10:55:06
well i'm stumped then.

you haven't used any tools to strip files out of your windows ISO/dvd before you installed it? it's not subject to any restrictions like on a windows server domain?

if you're running a bog standard install, i guess you could report the issue in the main WSH panel mod component thread....

http://www.hydrogenaudio.org/forums/index....showtopic=70363 (http://www.hydrogenaudio.org/forums/index.php?showtopic=70363)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: faemir on 2011-07-17 14:14:53
Hi Marc, thanks for all the hard work, the script rocks. Unfortunately after getting it working yesterday, I had to do a system restore after messing something else up, which wiped foobar back to how it was before. I've gone through doing it just as I did last time, but when I try to initialise the customdb, it crashes and says

Quote
Error: WSH Panel Mod (Playcount Sync by marc2003): Microsoft JScript runtime error:
'parsed_data.lovedtracks.@attr' is null or not an object
Ln: 170, Col: 16
<source text only available at compile time>


Oddly it did that the first time, so I tried again and it worked, but then it failed after a few pages, and now won't work at all.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-07-17 14:49:23
last.fm are having pretty major problems today. obviously their servers playing up shouldn't cause my scripts to crash - i should be able to handle it gracefully. i'll look into handling errors better.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: faemir on 2011-07-17 14:52:08
Ah yeah, it managed to work again but then died on sync 40 of 84.

It's nice to know that I'm not doing something wrong though, thanks
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-07-17 15:32:52
now updated with an error dialog:

(http://dl.dropbox.com/u/22801321/playcount%20error.png)

http://dl.dropbox.com/u/22801321/playcount%20sync.zip (http://dl.dropbox.com/u/22801321/playcount%20sync.zip)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zarggg on 2011-07-17 23:40:31
To give a bit more detail on the last.fm issue... Their main submission servers failed and then their backups failed at pretty much the same time. Bad news all around, but they're working on it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-07-18 10:49:00
another little update: http://dl.dropbox.com/u/22801321/playcount%20sync.zip (http://dl.dropbox.com/u/22801321/playcount%20sync.zip)

last.fm being sketchy the last day has thrown up a little conundrum for me with the way my script works. at the moment it checks to see if the local playcount is different from what is fetched from last.fm. and if different, the value from last.fm always takes precedence- afterall you could have scrobbled from other computers/devices and you want the update to show. if last.fm was completely down, you'd keep your local playcount and you'd get an error in the foobar console.

the problem at the moment is that last.fm is not throwing errors but infact returning valid data for a given track  - but it's not returning user data with it. my script assumes it hasn't been played before so it overwrites the existing playcount with 1 play. do you guys think the script should only overwrite if the value returned from last.fm is more than the local value? the only downside i can see from this is if you clear your stats/remove tracks from your last.fm library and then play them again, you'd have to manually clear the local database as well.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: bfdr on 2011-07-18 13:40:08
Hi,
I'm a long time lurker on hydrogenaudio. I've decided to finally make an account and deal with the problem I'm having.

Here's the story. Having previously the 1.0.1 version of foobar with lots of stuff on it, I decided to use this skin: http://sparanoid.com/work/monolite-plus/ (http://sparanoid.com/work/monolite-plus/) - the monolite plus. Everything worked like a charm. Unfortunately, I did a clean install of foo 1.1.7 and reapplied the skin again, hoping for the best. As usual, it did not go so smooth this time.

The actual error:
Quote
Scripting Engine Initialization Failed (GUID: 5DB6173B-8325-480E-8302-360E421ECF7D, CODE: 0x80020101)
Check the console for more detailed information (Always caused by unexcepted script error).


And the console log:
Quote
Custom Database: Initialize
Custom Database: table quicktag already exists (1)
Custom Database: table database_version already exists (1)
Custom Database: index url_idx already exists (1)
Custom Database: Completed
WSH Panel Mod (GUID: 1F73EB63-C052-4E32-8A7A-BF4FBF6C1430): initliased in 0.0000062 s
WSH Panel Mod (GUID: 82E26BE2-93C2-497A-BFE4-C40892B2AFDD): initliased in 0.0000009 s
WSH Panel Mod (GUID: ED89F4DA-FDCC-4CBC-8DDB-58D202FD6BF3): initliased in 0.0000003 s
WSH Panel Mod (GUID: 5DB6173B-8325-480E-8302-360E421ECF7D): Parsing file "C:\Program Files\foobar2000\skin\mono_lite\scripts\common.js"
Error: WSH Panel Mod (GUID: 5DB6173B-8325-480E-8302-360E421ECF7D): Microsoft JScript - błąd czasu wykonywania:
Nie można odnaleźć ścieżki.
Ln: 183, Col: 38
<source text only available in compile time>
Startup time : 0:00.461587


The "Microsoft JScript - błąd czasu wykonywania: Nie można odnaleźć ścieżki." part is basically the unknown file path error. Apparently it can't find something, although the skin and all the scripts are where they should be.

Some help would be greatly appreciated, as I'm no programmer.

Cheers,
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-07-18 14:39:44
i'd be more inclined to believe the component when it says it can't find a file over taking your word for it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: bfdr on 2011-07-18 15:47:56
Ok then, what do I do?

Here's some proof.
(http://i.imgur.com/UGql3.png)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-07-18 16:41:19
having looked at the theme, it seems it's taken the nonsensical decision that you must use portable mode. however, because your foobar folder is inside "program files", the script doesn't have permission to create the folders it needs to work. so move the folder into documents or desktop or somewhere else where you have permission.

new version uploaded: http://dl.dropbox.com/u/22801321/playcount%20sync.zip (http://dl.dropbox.com/u/22801321/playcount%20sync.zip)

-now maintains current playcounts if last.fm is being an ass (not throwing errors but not returning proper user data either)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: bfdr on 2011-07-18 18:28:58
Alright, here's what I've done so far.

Tried reinstalling foo in a different folder, non-Program Files one - did not work.

Portable version - works, but there's still an issue with the WSH.

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: gxavz1 on 2011-07-19 00:19:12
i have this erro marc

http://pastebin.com/9tcSHRLG (http://pastebin.com/9tcSHRLG)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-07-19 00:45:58
dfghdzfhgzjgjdfhgjgfkzjdjfgzdjkgnzbncb

that's about how much sense that error means to me. 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: gxavz1 on 2011-07-19 00:56:43
sorry, im brazilian and i translate the erro

Error: WSH Panel Mod (Sync playcount by marc2003): Runtime Error in Microsoft JScript:
Exception thrown away and not detected
Ln: 1, Col: 3374
<source text only available at compile time>
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-07-19 01:02:02
well i don't think i have any idea how to fix that.  does that happen when you close the editor dialog or when doing something particular? if it happens during an import can you tell me your last.fm userid so i can test it?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: gxavz1 on 2011-07-19 01:07:39
i send my user id and api key in MP
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-07-19 01:39:11
i didn't need the API key. still, that doesn't matter.

i just imported your entire library without any problems. i then tried again and it prompted me with an error (a server error that i scripted it to catch). it looks like last.fm still hasn't recovered properly from the downtime at the weekend. all i can suggest is trying again later/tomorrow.

new version: http://dl.dropbox.com/u/22801321/playcount%20sync.zip (http://dl.dropbox.com/u/22801321/playcount%20sync.zip)

-under the hood stuff that aborts importing if last.fm credentials are changed from another script. (they all share credentials and notify each other when changed)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: gxavz1 on 2011-07-19 01:55:51
Completed page 45 of 45 (playcount)

ty marc
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ladiko on 2011-07-30 13:19:01
This happens, when i click on "Create and import SQL file":
Quote
Error: WSH Panel Mod (Playcount Sync by marc2003): runtime error in Microsoft JScript:
'parsed_data.lovedtracks.@attr.totalPages' is Null or not an object
Ln: 185, Col: 16
<source text only available at compile time>
Could it be a problem if i dont have loved tracks and also don't want to use them?

edit:
yes it is a problem. i *loved* on song and now it works. but to be true, i don't want to love tracks.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-07-31 05:01:39
thanks for pointing that out. fixed: http://dl.dropbox.com/u/22801321/playcount%20sync.zip (http://dl.dropbox.com/u/22801321/playcount%20sync.zip)

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ladiko on 2011-07-31 09:41:37
thank you, now it works without loved tracks. is there any other side effect than the error exclamation mark in the wsh panel if i delete the foo_softplaylists? as i understand your description, i only need it, if i am interested in the loved tracks feature?!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-07-31 14:14:48
no side effects - automatic playcount updates and library importing still work without foo_softplaylists. you can always resize the panel so you can't see the button (right click>background>splitter so it blends in).
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ladiko on 2011-07-31 17:38:10
aha, thanks. i guess the suggested configuration suites my needs. well done!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Peter8823 on 2011-07-31 20:58:01
I have imported your script and it's working great. Have just one small issue with same title songs in elplaylist. Tried it in several skins, same problem.

So, this is what happens:

[a href="http://imageshack.us/photo/my-images/84/foobarplaycount.jpg/" target="_blank"]
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-07-31 22:37:36
line 172 should be...

Code: [Select]
fb.RunContextCommandWithMetadb("Customdb Refresh", g_metadb);


add this on a new line directly after it

Code: [Select]
fb.RunMainMenuCommand("ELPlaylist/Refresh");


Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Peter8823 on 2011-07-31 22:50:52
Thank you, its working now
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zanerlan on 2011-08-01 17:47:47
I try to add your integration on br3tt's new skin Hifoo, but i can't manage to make the count appear, what should i edit to see the numbers?

thanks ahead.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-08-01 22:38:46
well i'm not picking apart other people's themes but i guess it's using ELPlaylist. just right click the playlist>settings and check either the script>track list tab or maybe field definition tab. look for anything play count related and replace it with

Code: [Select]
%LASTFM_PLAYCOUNT_DB%
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zanerlan on 2011-08-02 09:23:24
thanks but im very bad with this, here's the code to the play count in playlist, i would thank you a lot if you can explain where should i put this.

Code: [Select]
// play_counter exposant
$if($stricmp(%el_preset_name%,'album (no header)'),
  $ifgreater($add($get(artist_txt_width),$get(title_txt_width)),%_title_w%,
$puts(area_w,%_title_w%)
  ,
$puts(area_w,$add($get(artist_txt_width),$get(title_txt_width)))
  )
  $font(uni 05_53,6,)
  $ifgreater(%__playcount%,0,
$drawtextex(%__playcount%,$add(%_pad_x%,%_tracknumber_w%,-11,$get(area_w)),0,$add($get(title_txt_width),0),%el_height%,$if(%el_isplaying%,220-50-50,80-90-100),left vtop)
  ,)
,
  $ifgreater($get(title_txt_width),%_title_w%,
$puts(area_w,%_title_w%)
  ,
$puts(area_w,$get(title_txt_width))
  )
  $font(uni 05_53,6,)
  $ifgreater(%__playcount%,0,
$drawtextex(%__playcount%,$add(%_pad_x%,%_tracknumber_w%,-11,$get(area_w)),0,$add($get(title_txt_width),0),%el_height%,$if(%el_isplaying%,220-50-50,80-90-100),left vtop)
  ,)
)

and if it's not there, where i should put it, and the 'love' icon?
here's the full script:

Code: [Select]
$puts(cf_name,'hifoo')
$puts(foo_path,%el_foobar2000_path%)
$puts(z1,$get(foo_path)'/skins/'$get(cf_name))
$puts(z2,$get(z1)'/gfx/')
$puts(z3,%ps_user_profile_path%'/skins/'$get(cf_name))

// fonts
$puts(small_font,'uni 05_53')
$puts(small_font_size,6)
$puts(small_font_style,'bold')
$puts(guifx_font,'guifx v2 transports')
$puts(guifx_font_size,11)
$puts(guifx_font_style,'normal')

// stripes
$ifequal($mod(%el_item_index%,2),0,
  $drawrect(0,0,$sub(%ww%,3),%el_height%,250-250-250-6,)
,)

$if($stricmp(%el_preset_name%,'album (no header)'),,
  $ifequal($add(%el_item_index%,1),%el_item_count%,
$drawroundrect(0,-5,$sub(%ww%,3),$sub(%el_height%,-4),2,2,30-40-50-00,15-20-25,)
  ,
$drawroundrect(0,-5,$sub(%ww%,3),$sub(%el_height%,-10),2,2,30-40-50-00,15-20-25,)
  )
)

// tracknumber
$ifgreater(%_tracknumber_w%,0,
$font(segoe ui,8,bold)
$if(%queue_index%,
$font(segoe ui,8,bold)
$drawroundrect($add(%_pad_x%,1),4,30,20,1,1,155-255-155-135,055-115-055-136,)
$drawblurrect($add(%_pad_x%,7),7,20,20,155-255-155-155,4)
$if($or($greater(%mood%,0),$greater(%skip%,0)),,
$drawtextex($ifgreater($len(%queue_index%),1,,0)%queue_index%,%_pad_x%,7,33,%el_height%,020-90-020-200,hcenter vtop end_ellipsis)
)
,
$if(%el_isplaying%,
,
$if($or(%el_selected%,%el_focused%),
$drawroundrect($add(%_pad_x%,1),4,30,20,1,1,150-160-170-65,150-160-170-66,)
$if($or($greater(%mood%,0),$greater(%skip%,0)),,
$drawtextex(%__trackindex%,%_pad_x%,7,33,%el_height%,0-0-0-200,hcenter vtop end_ellipsis)
)
,
$drawroundrect($add(%_pad_x%,1),4,30,20,1,1,0-0-0-55,0-0-0-56,)
$if($or($greater(%mood%,0),$greater(%skip%,0)),,
$drawtextex(%__trackindex%,%_pad_x%,7,33,%el_height%,255-255-255,hcenter vtop end_ellipsis)
)
)
)
)
,)

// track title
$puts(playcounter_txt_width,$add($gettextwidth(%__playcount%,uni 05_53,6,),2))
$font(segoe ui,9,normal)
$puts(artist_txt_width,$gettextwidth(%artist% / ))
$puts(title_txt_width,$gettextwidth(%__title%))
$if($stricmp(%el_preset_name%,'album (no header)'),
  $drawtextex(%artist% / %__title%,$add(%_pad_x%,%_tracknumber_w%,2),1,$sub(%_title_w%,1,$get(playcounter_txt_width)),%el_height%,%_artist_colour_%,left vtop end_ellipsis)
  $drawtextex(%__title%,$add(%_pad_x%,%_tracknumber_w%,2,$get(artist_txt_width)),1,$sub(%_title_w%,1,$get(playcounter_txt_width),$get(artist_txt_width)),%el_height%,%_label_colour_%,left vtop end_ellipsis)
,
  $drawtextex(%__title%,$add(%_pad_x%,%_tracknumber_w%,2),1,$sub(%_title_w%,1,$get(playcounter_txt_width)),%el_height%,%_label_colour_%,left vtop end_ellipsis)
)

// tech info
$if(%el_isplaying%,,
  $puts(bitrate,$if($stricmp($left(%codec_profile%,3),'VBR'),%codec_profile%,$if2($if(%__bitrate_dynamic%,$if(%_isplaying%,$select($add($mod(%_time_elapsed_seconds%,2),1),%__bitrate_dynamic%,%__bitrate_dynamic%),%__bitrate_dynamic%),%__bitrate%)'K','N/A')))
  $font(uni 05_53,6,)
  $if($stricmp(%el_preset_name%,'album (no header)'),
$drawtextex(%__album%,$add(%_pad_x%,%_tracknumber_w%,3),16,$sub(%_title_w%,10),%el_height%,$if(%el_isplaying%,215-225-245,%_c03c_%),left vtop end_ellipsis)
  ,
$puts(VA,$if($stricmp(%album artist%,%artist%),0,1))
$drawtextex($ifequal($get(VA),1,$upper(%artist%)' | ',)$upper(%__codec%) $get(bitrate),$add(%_pad_x%,%_tracknumber_w%,3),16,$sub(%_title_w%,10),%el_height%,$if(%el_isplaying%,215-225-245,%_c03c_%),left vtop end_ellipsis)
  )
)

// play_counter exposant
$if($stricmp(%el_preset_name%,'album (no header)'),
  $ifgreater($add($get(artist_txt_width),$get(title_txt_width)),%_title_w%,
$puts(area_w,%_title_w%)
  ,
$puts(area_w,$add($get(artist_txt_width),$get(title_txt_width)))
  )
  $font(uni 05_53,6,)
  $ifgreater(%__playcount%,0,
$drawtextex(%__playcount%,$add(%_pad_x%,%_tracknumber_w%,-11,$get(area_w)),0,$add($get(title_txt_width),0),%el_height%,$if(%el_isplaying%,220-50-50,80-90-100),left vtop)
  ,)
,
  $ifgreater($get(title_txt_width),%_title_w%,
$puts(area_w,%_title_w%)
  ,
$puts(area_w,$get(title_txt_width))
  )
  $font(uni 05_53,6,)
  $ifgreater(%__playcount%,0,
$drawtextex(%__playcount%,$add(%_pad_x%,%_tracknumber_w%,-11,$get(area_w)),0,$add($get(title_txt_width),0),%el_height%,$if(%el_isplaying%,220-50-50,80-90-100),left vtop)
  ,)
)

// rating
$font($get(guifx_font),$get(guifx_font_size),$get(guifx_font_style))
$if(%el_isplaying%,,
$puts(rating_deb,$sub(%ww%,68))
$puts(rating_sp,13)
$puts(rx,$add(-3, $get(rating_deb)))
$puts(ry,20)
$puts(rc_off,0-0-0-250)
$puts(rc_on,%_c03c_%)
$puts(rc_yellow,%_c03c_%)
$drawellipse($add($get(rx),4,$mul(0,$get(rating_sp))),$add($get(ry),1),4,4,$get(rc_off),,)
$drawellipse($add($get(rx),4,$mul(0,$get(rating_sp))),$add($get(ry),0),4,4,$get(rc_on)-200,,)
$drawellipse($add($get(rx),4,$mul(1,$get(rating_sp))),$add($get(ry),1),4,4,$get(rc_off),,)
$drawellipse($add($get(rx),4,$mul(1,$get(rating_sp))),$add($get(ry),0),4,4,$get(rc_on)-200,,)
$drawellipse($add($get(rx),4,$mul(2,$get(rating_sp))),$add($get(ry),1),4,4,$get(rc_off),,)
$drawellipse($add($get(rx),4,$mul(2,$get(rating_sp))),$add($get(ry),0),4,4,$get(rc_on)-200,,)
$drawellipse($add($get(rx),4,$mul(3,$get(rating_sp))),$add($get(ry),1),4,4,$get(rc_off),,)
$drawellipse($add($get(rx),4,$mul(3,$get(rating_sp))),$add($get(ry),0),4,4,$get(rc_on)-200,,)
$drawellipse($add($get(rx),4,$mul(4,$get(rating_sp))),$add($get(ry),1),4,4,$get(rc_off),,)
$drawellipse($add($get(rx),4,$mul(4,$get(rating_sp))),$add($get(ry),0),4,4,$get(rc_on)-200,,)
$drawstring($repeat(b,%__rating%),$sub($get(rx),1),$sub($get(ry),4),75,15,$get(rc_off),left vtop aa)
$drawstring($repeat(b,%__rating%),$sub($get(rx),1),$sub($get(ry),5),75,15,$get(rc_yellow),left vtop aa)
)

// length
$if(%el_isplaying%,,
$puts(total_length,%length%)
$select($sub($len(%length%),3),
$ifgreater(%length_seconds%,59,
$puts(length,'  00:0')
,
$ifgreater(%length_seconds%,9,
$puts(length,'  00:00:')
$puts(total_length,$right(%length%,2))
,
$puts(length,'  00:00:0')
$puts(total_length,$right(%length%,1))
)
)
,
$puts(length,'  00:')
,
,
$puts(length,'  0')
,
$puts(length,'  ')
)
$if(%length%,,
$puts(length,'  00:00:00')
$puts(total_length,)
)
$font(segoe ui,9,)
$drawtextex($get(length),$sub(%ww%,56),1,56,%el_height%,%_c03d_%,left top)
$drawtextex($get(total_length),$sub(%ww%,63),1,55,%el_height%,%_time_colour_%,right top)
)

// Love Track Icon
$ifgreater(%_tracknumber_w%,0,
$if(%el_isplaying%,,
 $ifgreater(%mood%,0,
  $font($get(guifx_font),16,$get(guifx_font_style))
  $drawstring('^',$add(%_pad_x%,5),4,24,%el_height%,0-0-0-160,right top aa nowrap,)
  $font($get(guifx_font),14,$get(guifx_font_style))
  $drawstring('^',$add(%_pad_x%,6),6,22,%el_height%,0-0-0-150,right top aa nowrap,)
  $drawstring('^',$add(%_pad_x%,6),5,22,%el_height%,60-255-60-200,right top aa nowrap,)
 ,
  $ifgreater(%skip%,0,
$font($get(guifx_font),16,$get(guifx_font_style))
$drawstring('%',$add(%_pad_x%,7),5,23,%el_height%,0-0-0-160,right top aa nowrap,)
$font($get(guifx_font),14,$get(guifx_font_style))
$drawstring('%',$add(%_pad_x%,8),7,21,%el_height%,0-0-0-150,right top aa nowrap,)
$drawstring('%',$add(%_pad_x%,8),6,21,%el_height%,250-60-60-200,right top aa nowrap,)
  ,)
 )
)
,)

Thanks again!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-08-02 09:54:43
reading comprehension fail. you posting it here isn't going to make me change my mind.....

well i'm not picking apart other people's themes.....


if you're stuck, ask the person who made it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zanerlan on 2011-08-02 09:57:58
ok man.
thanks anyway.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-08-02 09:59:53
just had a quick glance, have you not even tried replacing all instances of %__playcount% with %LASTFM_PLAYCOUNT_DB%
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zanerlan on 2011-08-02 20:08:32
just had a quick glance, have you not even tried replacing all instances of %__playcount% with %LASTFM_PLAYCOUNT_DB%


yes.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Steve Forte Rio on 2011-08-07 14:39:21
Can't download the script. After clicking "full instructions here" the only I see is Windows Live login page.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-08-07 17:34:03
http://dl.dropbox.com/u/22801321/playcount%20sync.zip (http://dl.dropbox.com/u/22801321/playcount%20sync.zip)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Rarn on 2011-08-08 02:15:55
This is a great script but I had to uninstall it, as customdb slowed down my foobar2000 start-up significantly (I have 65000 tracks in my library...). I had a lot of fun with it for a week though!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: annalise on 2011-08-17 13:12:12
Marc,

Firstly I'd like to thank you for this great script -- simply amazing. I just have one question...

Currently, the script treats any track with the same "Artist" and "Song Title" as the same.

Lets say I have two tracks -- same artist, same title, but from different albums (i.e. one is a studio version, one is a live version).

If I listen to just ONE of the two tracks, the script's playcount feature will affect both tracks since they both have the same artist and title -- i.e., if I listen to the studio version, the live version also is credited as having been listened to.

So, in my ELPlaylist, after listening to ONE of the two tracks, both tracks are credited with the playcount.

Is there any way to prevent this? Perhaps have the script be aware of album titles in addition to artist and song title?

The way the script functions now creates a bit of "playcount inflation" on my ELPlaylist, especially since I have many live albums.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-08-17 13:59:33
sorry but there isn't anything i can do about that. when i fetch the track info from last.fm, it only allows me to supply the artist and title as parameters and not the album.

for the most part, last.fm also aggregates these artist/title play counts when browsing the track pages online. it's only if you dig deep into your "Library" that it will show play counts per album. there doesn't appear to be anyway for me to access this information.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: bloodclot on 2011-09-04 21:35:57
Completed page 131 of 170 (playcount)
Error: WSH Panel Mod (Playcount Sync by marc2003): Microsoft JScript runtime error:
'parsed_data.tracks.track' is null or not an object
Ln: 241, Col: 15
<source text only available at compile time>

o.o
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: gxavz1 on 2011-09-11 06:59:18
I got this error doing the import library (sorry my bad english)

Code: [Select]
Error: WSH Panel Mod (Sync playcount by marc2003): Runtime Error in Microsoft JScript:
Exception thrown away and not detected
Ln: 1, Col: 3395
<source text only available at compile time>
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-09-13 00:39:38
updated: http://dl.dropbox.com/u/22801321/playcount%20sync.zip (http://dl.dropbox.com/u/22801321/playcount%20sync.zip)

hopefully fix it failing on malformed last.fm content.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: djphatic on 2011-09-19 14:00:53
Is there anyway to implement a blacklist feature so that tracks by a particular artist or which contain a certain TAG are not scrobbled/synced. I presume this feature would have to be implemented outside of the script?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-09-19 16:09:24
you need to configure foo_audioscrobbler for what gets scrobbled. it can be set to only scrobble tracks that are in your library. or you could mess about with the field remapping. if the artist field is blank, it won't get submitted.

eg, this wouldn't submit if the genre was jazz....
Code: [Select]
$if($stricmp(%genre%,jazz),,[%artist%])


Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: bloodclot on 2011-09-19 17:22:54
updated: http://dl.dropbox.com/u/22801321/playcount%20sync.zip (http://dl.dropbox.com/u/22801321/playcount%20sync.zip)

hopefully fix it failing on malformed last.fm content.


Still getting the "'parsed_data.tracks.track' is null or not an object" error.

Why is this?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: djphatic on 2011-09-19 17:44:50
you need to configure foo_audioscrobbler for what gets scrobbled. it can be set to only scrobble tracks that are in your library. or you could mess about with the field remapping. if the artist field is blank, it won't get submitted.

eg, this wouldn't submit if the genre was jazz....
Code: [Select]
$if($stricmp(%genre%,jazz),,[%artist%])


Cheers, I'll take a look into this.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-09-19 20:58:49
Still getting the "'parsed_data.tracks.track' is null or not an object" error.


this should never happen during an import now. did you definitely import the new .txt file into your panel. that's all you had to do - nothing else changed. also can you can share your last.fm userid with me. PM will do if you don't want to post it here. i don't need your api key.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: bloodclot on 2011-09-20 03:50:17
Still getting the "'parsed_data.tracks.track' is null or not an object" error.


this should never happen during an import now. did you definitely import the new .txt file into your panel. that's all you had to do - nothing else changed. also can you can share your last.fm userid with me. PM will do if you don't want to post it here. i don't need your api key.


Interesting, yes I definitely did import it, then did it again to make sure.

My last.fm id is bloodclox
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-09-20 10:33:25
when i check each record i use a try...catch statement. this means it should never crash now. if it encounters an error, it should simply continue but the record it got stuck on will be missed from the final results. at the end it should output have many errors were found in the console because i count each one.

if there is a more serious error where a whole page fails, then it aborts processing altogether and spawns a popup window indicating that you should try again later along with the full error. and this is what happened to me just now testing your account. i only got to 15 pages before this happened.

Quote
There is a problem with the Last.fm web services. Please try again later.

{"error":8,"message":null}


i tried again and got the same error on page 105. so there's obviously no error on page 15 like the first attempt seemed to indicate. it's just last.fm being flaky at the moment and there is nothing i can do about that.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: bloodclot on 2011-09-20 14:55:16
when i check each record i use a try...catch statement. this means it should never crash now. if it encounters an error, it should simply continue but the record it got stuck on will be missed from the final results. at the end it should output have many errors were found in the console because i count each one.

if there is a more serious error where a whole page fails, then it aborts processing altogether and spawns a popup window indicating that you should try again later along with the full error. and this is what happened to me just now testing your account. i only got to 15 pages before this happened.

Quote
There is a problem with the Last.fm web services. Please try again later.

{"error":8,"message":null}


i tried again and got the same error on page 105. so there's obviously no error on page 15 like the first attempt seemed to indicate. it's just last.fm being flaky at the moment and there is nothing i can do about that.


If it helps, Page 132 of 171 is the last page that can complete before i get the 'parsed_data.tracks.track'. It fails at that point every time. (two weeks ago it was page 131). I've been trying every day since Sep 4 2011 but always get that error.

Thanks for your help, i really appreciate it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-09-20 15:58:25
let's try again  http://dl.dropbox.com/u/22801321/playcount%20sync.zip (http://dl.dropbox.com/u/22801321/playcount%20sync.zip)

2 whole pages are corrupt so you lose 200 records - nothing i can do about it but at least it completes now.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: bloodclot on 2011-09-21 16:49:45
WORKS! Thank you so much  I really appreciate all you have done and thanks for creating the script and tutorial
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zageron on 2011-09-26 20:28:54
Hello,
I've been getting an abnormal termination for the last month. I've just run through the majority of my other plugins, and surprisingly it isn't WSH doing the crashing. I can't find the culprit though. If I launch in safe mode the next start-up is successful. The "running" file in the foobar folder remains there when I close the program. Just wondering your script might be doing it.
Thanks,
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-09-26 21:00:05
i think it's highly unlikely. you usually know about it when it craps out.

the easy way to test is to simply remove the script for a day or 2. leave the panel in place but blank and leave the other components as they are too.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-09-27 15:44:20
a little update which does a better job of reporting errors. http://dl.dropbox.com/u/22801321/playcount%20sync.zip (http://dl.dropbox.com/u/22801321/playcount%20sync.zip)

even though i fixed the problems bloodclot was having a few days ago, it still reported 0 errors which is wrong. it now says this in the console when importing is complete.

Code: [Select]
Loved track page errors: 0 (200 records are lost for every page that fails.) 
Playcount page errors: 3 (100 records are lost for every page that fails.)
Individual errors: 0


there is nothing i can do about these errors because upon further checking, last.fm is actually returning this as the content for the problematic pages.

Code: [Select]
""
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: slyman on 2011-10-18 02:33:52
i'm not sure if this has been addressed but it's not updating the loved status of tracks for me. i can love a track but the heart icon doesn't show up in foobar unless i right click and go to Legacy Commands > Customdb love 1. i was under the impression that it would do this automatically
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-10-18 11:41:35
have you checked the foobar console to make sure foo_softplaylists is working as it should? that will display success/failure messages when you love a track. although the script itself doesn't report success/failure when fetching love tracked status, it's always worked every time for me and no one else has reported this issue.

BTW, for people who are interested, the next version of WSH panel mod will allow this script to run with the Last.fm and Legacy commands (unsorted) menu items hidden. i'll update the script when the component gets properly released.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-10-25 14:53:54
script now requires WSH panel mod 1.5.0 beta3 or above.

http://dl.dropbox.com/u/22801321/playcount%20sync.zip (http://dl.dropbox.com/u/22801321/playcount%20sync.zip)

you can now hide the Last.fm and Legacy Commands (unsorted) sub-menus under file>preferences>display>context menu without breaking the script.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Neu on 2011-11-15 21:15:22

I am continually receiving this error in console: Playcount Sync: HTTP error: 12029

I dont think it's managed to update in the last few weeks because of this. All of my components are fully up to date.

Any ideas?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Neu on 2011-11-15 22:48:47
My audioscrobbler works fine, btw. It doesn't receive any errors, just playcount.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-11-16 13:34:02
the script is working exactly as expected by writing that message to the console so there isn't much else i can do.

i just googled that error and it looks to be an issue between your machine and last.fm??

Code: [Select]
12029       ERROR_INTERNET_CANNOT_CONNECT
               The attempt to connect to the server failed.


all i can suggest is clearing all your Internet Explorer temporary files and try again?? i assume all other internet stuff is working fine? do you have another pc you can test from using the same internet connection? as you can see, i'm clutching at straws here. i really have no idea.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Neu on 2011-11-18 07:02:45
the script is working exactly as expected by writing that message to the console so there isn't much else i can do.

i just googled that error and it looks to be an issue between your machine and last.fm??

Code: [Select]
12029       ERROR_INTERNET_CANNOT_CONNECT
               The attempt to connect to the server failed.


all i can suggest is clearing all your Internet Explorer temporary files and try again?? i assume all other internet stuff is working fine? do you have another pc you can test from using the same internet connection? as you can see, i'm clutching at straws here. i really have no idea.


Looks like Internet Explorer had it's Proxy settings changed even though I've never opened it on this computer. I set it to automatically detect settings and it's working fine.

I didn't think to even check IE...

Thanks!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-11-18 11:28:36
i'd check your system for nasties. getting the proxy changed like that is not good....
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zageron on 2011-11-19 00:05:42
Database entry update on mass scrobble?

When using foobar ipod manager it imports the play counts, audioscrobbler then scrobbles them on the next submit.
afaik the songs scrobbled this way do not update on your database.

Any chance of that?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-11-19 01:08:10
i don't think this would be possible. i can fetch a user's entire last.fm library OR individual track details with user info. i don't have access to an ipod and even if i did, i believe it would be extremely cumbersome fetching info for a subset of tracks each time.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Nassoo on 2011-11-19 11:28:55
Hi marc,
I have a question... Is there an option to update the LastFM playcount info on loading a track in a playlist automatically? I often scrobble from my phone, and i'd like, if its possible, the foobar to update the info from lastFM without updating the whole database manually from Library import... Now actually it auto updates playcount only when the track plays for a few second (may be when scrobbles?).
Thank you in advance!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: BrutuZ on 2011-11-20 04:12:59
Hi marc, couldn't help but notice the discussions about updating the database to sync with scrobbles from other devices. I too often scrobble from my Windows Mobile device, and got to admit it would be cool if I could sync just the last played tracks instead of the whole library.
Wouldn't it be possible then to perform an (optional) check on startup for the last, let's say, 50 scrobbled tracks and update the database accordingly by syncing track-by-track?
Perhaps just adding a menu item on the Un/Love Button do to it instead of / in addition to doing it automatically on startup would be better since it may be slow, but that's a matter of testing.

Since the API does provide the list of last played tracks (http://www.last.fm/api/show?service=278 (http://www.last.fm/api/show?service=278)), it may be worth a shot.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-11-20 08:47:39
i'm not keen on using that API because instead of getting the real playcount value, i'd have to keep running totals (given a track could appear multiple times) and then add the values to my database. i'd have no way to verify the final values are accurate - well other than making a list of artist/titles and sending an individual request to the trackinfo method for each one but that would be a bit crap....

i'll think about it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: for4saken on 2011-11-30 15:06:18
Hey marc, I've been using your scripts for a long time, but after upgrading WSH to 1.5.0 and your Last.fm script to the latest version something broke.

It's been a couple of weeks, I was waiting to see if anyone else had this problem or to a new version to be release; but since neither happened I'm writing for help.

It throws this error message: Scripting Engine Initialization Failed (Playcount Sync by marc2003, CODE: 0x80020101)

The relevant console log:
Code: [Select]
WSH Panel Mod ({AC02127E-FD87-4354-8BFE-673DB837A5D4}): Parsing file "C:\Users\for4saken\AppData\Roaming\foobar2000\marc2003\common.js"
WSH Panel Mod ({AC02127E-FD87-4354-8BFE-673DB837A5D4}): Parsing file "C:\Users\for4saken\AppData\Roaming\foobar2000\marc2003\tooltip_buttons.js"
WSH Panel Mod ({AC02127E-FD87-4354-8BFE-673DB837A5D4}): initialized in 16 ms
WSH Panel Mod (Playcount Sync by marc2003): Parsing file "C:\Users\for4saken\AppData\Roaming\foobar2000\marc2003\common4.js"
WSH Panel Mod (Playcount Sync by marc2003): Parsing file "C:\Users\for4saken\AppData\Roaming\foobar2000\marc2003\tooltip_buttons.js"
Error: WSH Panel Mod (Playcount Sync by marc2003): Erro em tempo de execução do Microsoft JScript:
O servidor de automação não pode criar objeto
File: C:\Users\for4saken\AppData\Roaming\foobar2000\marc2003\common4.js
Ln: 375, Col: 1
<source text only available at compile time>


The line in question: var vb = new ActiveXObject('ScriptControl');

Any other script of yours that imports common4.js fails with the same error.

I'm using a heavily customized version of MonolitePlus, which imports an old version of common.js and it's working.

Any help would be immensely appreciated.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2011-11-30 15:32:46
if you clear the panel completely and have just this one line of code, i'm assuming it will also crash??

Code: [Select]
var vb = new ActiveXObject('ScriptControl');


if that's the case then there must be something wrong with your windows setup and i have no idea what that could be?  maybe some internet explorer security settings or files have been stripped away during a custom install?? i'm just guessing though....

that code is only required for the input dialogs so assuming you've already got your username and api key set, you could comment it out as a temporary workaround. the line following needs to be commented out also, like this...

Code: [Select]
//var vb = new ActiveXObject('ScriptControl');
//vb.Language = 'VBScript';


selecting any menu item that spawns an input dialog would also cause the panel to crash but for normal usage it should be fine.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: for4saken on 2011-11-30 17:57:42
This workaround helped!

Thank you.

I cannot imagine what could be the problem, as I've said, I've been using your scripts for a couple years and besides updating WSH noting relevant changed system-wise.

I tried a clean foobar install, clean reinstall of the scripts; nothing.

That's why I've cried for help
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-01-19 13:16:39
updated: http://dl.dropbox.com/u/22801321/playcount%20sync.zip (http://dl.dropbox.com/u/22801321/playcount%20sync.zip)

added option to auto-updates submenu: only update tracks in library. the default is off (update all tracks) which is the current behaviour.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Snappycakes on 2012-01-23 20:44:30
Hi Marc. Great script. Really well done. I was wondering, does the script still work if you remove the WSH Panel Mod panel? It's a little bit out of place in my foobar setup.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-01-23 21:13:29
no, you can't remove the panel. how else would it work?

possible workarounds:
if using columns UI, you can highlight it in the layout tab and hide it.
using default UI, you could put in a tab that you rarely use.
again using default UI, you could put your whole layout in the top half of top/bottom splitter. then put the WSH panel in bottom half. it might look something like this....

http://dl.dropbox.com/u/22801321/lastfm%20...nt%20before.png (http://dl.dropbox.com/u/22801321/lastfm%20playcount%20before.png)

now drag the splitter down as far as it will go and you'll end up with this. you can notice a gap between the seekbar and status bar but i think it blends in well.

http://dl.dropbox.com/u/22801321/lastfm%20...unt%20after.png (http://dl.dropbox.com/u/22801321/lastfm%20playcount%20after.png)

you can then right click on the splitter and lock the bottom panel so it stays hidden even when resizing foobar.

edit: corrected columns UI instructions.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Snappycakes on 2012-01-23 22:52:45
Did it by hiding in Columns UI. Perfect. Thanks.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: radecke on 2012-01-27 16:40:10
edit: nevermind, had an outdated version of the wsh panel
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: lucidanime on 2012-01-30 04:57:02
updated: http://dl.dropbox.com/u/22801321/playcount%20sync.zip (http://dl.dropbox.com/u/22801321/playcount%20sync.zip)

added option to auto-updates submenu: only update tracks in library. the default is off (update all tracks) which is the current behaviour.


Just to report, I found a little issue with this version when used with Columns UI + ELPlaylist. Previously Loved tracks get unloved when the tracks Last.FM Playcount gets updated. To fix, just comment out the line "if (old_userloved == 1) fb.RunContextCommandWithMetadb("Customdb Love 0", g_metadb, 8);"in "function process() "
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-01-30 05:30:40
i didn't put that line in by mistake. i need to remove the record from the database before updating the playcount. i then set it back to loved straight away. i use ELplaylist myself and it always updates properly. if yours doesn't then you could try adding this at line 195:

Code: [Select]
fb.RunMainMenuCommand("View/ELPlaylist/Refresh");
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Cпутник on 2012-02-28 20:01:06
Thanks a lot for this script Marc. I am usually not a person who posts on forums, but this time I just have to clarify how awesome this script is and why it beats stuff like playback statistcs.

In my honest opinion, playback statistics doesn't say anything about the amount of music you are listening to. Most of the people are listening to the music through their portable devices (mp3 player, smartphone, etc.). Due to this fact I spent a lot of time trying to synchronize my mp3 tags with the same mp3 files on my portable device.

After days of research I figured out, that the best method of synchronization is in using an online database. That also implies things like replacing old file tracks with some better quality ones without loosing the playcount. (I stored playcounts directly in mp3 tags)

So finally I found this thread and decided to give it a try. I have to admit that I had to replace my whole portable version of foobar to a new one. But after a clean setup it worked pretty well. Though in the beginning I was afraid of a following scenario:

Day 1: track A has 6 plays on my personal last.fm (last.fm = 6; custom_db = 0)
Day 2: after installing your script I am listening to track A one more time (last.fm = 7; custom_db = 7)
Day 3: durring the bus drive I am listening to track A for additional 2 times offline on my Sansa Clip+ with Rockbox. (last.fm = 7; custom_db = 7)
Day 4: I am uploading my last.fm scrobble listfile from my MP3 player to last.fm (last.fm = 9; custom_db = 7)
Day 5: I am listening to the track A at home using foobar (last.fm = 10; custom_db = 8?)

It is true that the track count is on 7 instead of the actual 10, but after playing the song one more time in foobar it retrives the correct playcount. (means including my mp3 player counts) After a couple of weeks I can still decide to import the whole last.fm data again, in order to display more accurate countvalues.

What I actually wanted to say - even though this thread seems to be pretty inconspicuous, it was the one and only solution for my picky perceptions of statistics. This way I can sort and play the best tracks on our flat parties according to my total overall listening experience.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-02-28 21:39:37
^glad you find it useful.

a little update.... http://dl.dropbox.com/u/22801321/playcount%20sync.zip (http://dl.dropbox.com/u/22801321/playcount%20sync.zip)

the icons can now be changed via the context menu. there is a choice of the original tango icon which is the same 32px in size and if you choose the silk icon, it will be 20px.

(http://dl.dropbox.com/u/22801321/silk%20love%20icon.png)

existing users, make sure the marc2003 folder gets extracted again so you get the required images - but people who use my other samples will already have them.

EDIT: i just re-uploaded to squish a little bug i introduced. this only applies to the new version from 30 minutes ago.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: enigmatik on 2012-03-01 13:58:20
I'm runnig fb2k through WINE on Linux Mint 12 and I'm gettting this error on launch:

(http://dl.dropbox.com/u/2777613/ScreenShots/ScreenShot252.png)

There is nothing in the console.

EDIT:

after I did "winetricks wsh56" i get the following:

Scripting Engine Initialization Failed (Playcount Sync by marc2003, CODE: 0x80020101)
Check the console for more information (Always caused by unexcepted script error).

from the console:


Error: WSH Panel Mod (Playcount Sync by marc2003): Microsoft JScript runtime error:
Automation server can't create object
File: Z:\media\4E362CDE362CC8B3\Dropbox\Applications\foobar2000-linux\marc2003\common4.js
Ln: 396, Col: 1

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-03-01 14:38:39
here's an old post listing all the winetricks stuff i installed...

http://www.hydrogenaudio.org/forums/index....st&p=744005 (http://www.hydrogenaudio.org/forums/index.php?s=&showtopic=76772&view=findpost&p=744005)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: enigmatik on 2012-03-01 14:59:47
Tried to do winetricks ie6 but it said it can't find it (broken link or something) so I did winetricks ie7 and all the rest on your list but still same error.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-03-01 15:05:13
and you disabled safe mode in the WSH panel mod preferences?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: enigmatik on 2012-03-01 15:07:37
Yes.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-03-01 15:09:01
in that case, i have no idea.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: enigmatik on 2012-03-01 15:09:39
I actually did something wrong with ie... I'll report back.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: enigmatik on 2012-03-01 16:12:25
Doesn't work. Deleted .wine dir and did everything again, doesn't work. Too bad.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-03-01 17:50:22
i just installed mint in vmware to see if could fix this.... and i did.

i found winetricks bundled with WINE didn't work so i used this from my earlier post: http://www.kegel.com/wine/winetricks (http://www.kegel.com/wine/winetricks)

save it and then run from a terminal

Code: [Select]
sh winetricks


select

Code: [Select]
gdiplus
ie8
wsh57


now browse the marc2003 folder and edit common4.js in a text editor.

edit line 23 to become

Code: [Select]
font = "Tahoma";


comment out lines 401, 402 like so
Code: [Select]
//vb.Language = 'VBScript';
//var script_path = fb.ProfilePath + "marc2003\\";


i can't get input dialogs working so if you haven't already set the username and api key, you need to edit the script in the panel itself - lines 17 and 19...

Code: [Select]
var username = "marc2003";

var api_key = "123456....";


(http://dl.dropbox.com/u/22801321/mint.png)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: enigmatik on 2012-03-01 19:21:53
Thanks, but it still doesn't work, I can't believe this.

Error: WSH Panel Mod (Playcount Sync by marc2003): Microsoft JScript runtime error:
Automation server can't create object
File: Z:\media\4E362CDE362CC8B3\Dropbox\Applications\foobar2000-linux\marc2003\common4.js
Ln: 396, Col: 1
<source text only available at compile time>
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-03-01 20:29:16
not that it matters because your error is in a different place but i completely messed up the lines you needed to comment out (400&401)

Code: [Select]
//var vb = new ActiveXObject('ScriptControl');
//vb.Language = 'VBScript';
var script_path = fb.ProfilePath + "marc2003\\";  //this line 402 should not be commented out.


but as yours isn't working anyway, there's not much else i can do.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Aratar Orome on 2012-03-26 22:37:07
hallo marc2003,

now I have managed that your script works for my foobar installation.
Now I want to display this:

//this is what you use to display the play count.
[%LASTFM_PLAYCOUNT_DB%]

//show if a track is loved
$ifequal(%LASTFM_LOVED_DB%,1,♥,)


I use ELPlaylist. Do you have a configuration file for me so I also see the heart for loved songs in my playlists?

Thank you in advanced,

Andi
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-03-27 09:21:27
you can display a heart with the default font using that code inside a $drawtextex function.

or if you want a nice to display a heart image, you can use the $imageabs function. check the ELPlaylist readme for both functions.

i would post my ELPlaylist config but i'm away from home at the moment.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-03-27 12:27:06
back at home now.. my ELPLaylist config...

Field definition tab
name: images
value: %el_user_profile_path%\marc2003\images

script>track list tab
$ifequal(%LASTFM_LOVED_DB%,1,$imageabs($sub(%el_width%,90),0,20,20,%images%\love_h_small.png,,,,),)

because you're using this script, that image should be in place already.

you'll probably want to tweak the first 2 numbers of the $imageabs function for placement.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Aratar Orome on 2012-03-27 15:59:01
Hy Marc,

thx for your fast reply. Unfortunately it doesn't work with your hint.
I don't see a heart for loved songs or a playcount. I think that I could made
a mistake because I don't have any experience in JavaScript (My home base is C).

Please can help me with the elplaylist config  .

Here is the script:
Code: [Select]
$if(%el_isplaying%,,

// track BG
$if($or(%el_selected%,%el_focused%),
    $gradientrect(0,0,%_ww_%,%el_height%,15-15-20,35-35-40,,)
    $drawrect(0,$sub(%_wh_%,1),%_ww_%,1,10-10-15,)
    $gradientrect(10,0,$sub(%_ww_%,20),1,0-0-0-0,0-0-0,horizontal,50)
    $drawrect(0,1,%_ww_%,1,35-35-40,)
    $gradientrect(0,$sub(%_wh_%,1),%_ww_%,1,40-40-45,45-45-50,horizontal,50)
,
    $gradientrect(10,0,$sub(%_ww_%,20),1,0-0-0-0,0-0-0,horizontal,50)
    $gradientrect(10,1,$sub(%_ww_%,20),1,0-0-0-0,40-40-45,horizontal,50)
)

// tracknumber or list index (when no header)
$font(%_txt_font_name_%, $sub(%_txt_font_size_%,2),)
$if(%queue_index%,
    $drawroundrect(%_tracknumber.x_%,$add(%_pad_top_%,1),$sub(%_tracknumber.w_%,8),15,2,2,47-127-47,0-0-0-160,)
    $gradientrect($add(%_tracknumber.x_%,2),$add(%_pad_top_%,3),$sub(%_tracknumber.w_%,11),13,67-167-67,37-137-37,)
,
    $drawroundrect(%_tracknumber.x_%,$add(%_pad_top_%,1),$sub(%_tracknumber.w_%,8),15,2,2,60-60-65,0-0-0-160,)
    $gradientrect($add(%_tracknumber.x_%,2),$add(%_pad_top_%,3),$sub(%_tracknumber.w_%,11),13,75-75-85,45-45-55,)
    $gradientrect($add(%_tracknumber.x_%,2),$add(%_pad_top_%,3),$sub(%_tracknumber.w_%,11),6,0-0-0-0,250-250-255-20,)
)
$drawtextex(%_tracknumber_%,%_tracknumber.x_%,$add(%_pad_top_%,2),$sub(%_tracknumber.w_%,6),%_wh_%,%_tracknumber_colour_%,hcenter top)

// artist
$if(%_artist_%,
    $puts(artist.w, $ifgreater(%_artist.w_%,%_free.w_%,%_free.w_%,%_artist.w_%))
    $font(%_txt_font_name_%, %_txt_font_size_%,)
    $drawtextex(%_artist_%,%_artist.x_%,$add(%_pad_top_%,1,$if($stricmp($ansi($upper(%_artist_%)),$upper(%_artist_%)),0,1)),$get(artist.w),%_wh_%,0-0-0,end_ellipsis)
    $drawtextex(%_artist_%,%_artist.x_%,$add(%_pad_top_%,$if($stricmp($ansi($upper(%_artist_%)),$upper(%_artist_%)),0,1)),$get(artist.w),%_wh_%,%_artist_colour_%,end_ellipsis)
,
    $puts(artist.w,0)
)

// title
$ifgreater($get(artist.w),%_free.w_%,,
    $puts(free.w,$sub(%_free.w_%, $get(artist.w)))
    $puts(title.x,$add(%_artist.x_%, $get(artist.w)))
    $puts(title.w,$ifgreater(%_title.w_%,$get(free.w),$get(free.w),%_title.w_%))
    $font(%_txt_font_name_%, %_txt_font_size_%,)
    $drawtextex(%_title_%,$get(title.x),$add(%_pad_top_%,1,$if($stricmp($ansi($upper(%_title_%)),$upper(%_title_%)),0,1)),$get(title.w),%_wh_%,0-0-0,end_ellipsis)
    $drawtextex(%_title_%,$get(title.x),$add(%_pad_top_%,$if($stricmp($ansi($upper(%_title_%)),$upper(%_title_%)),0,1)),$get(title.w),%_wh_%,%_title_colour_%,end_ellipsis)
)

$ifequal(%LASTFM_LOVED_DB%,1,$imageabs($sub(%el_width%,90),0,20,20,%images%\love_h_small.png,,,,),)


// duration
$font(%_txt_font_name_%, %_txt_font_size_%,)
$if(%el_isplaying%,,
$drawtextex($if2(%length%,0:00),%_duration.x_%,$add(%_pad_top_%,1),%_duration.w_%,%_wh_%,0-0-0,right)
$drawtextex($if2(%length%,0:00),%_duration.x_%,%_pad_top_%,%_duration.w_%,%_wh_%,%_duration_colour_%,right)
)

// rating
$if(%el_isplaying%,,
    $font(guifx v2 transports,12,)
    $drawtextex($repeat(b,5),$add(%_rating.x_%,05),$add(%_pad_top_%,1),%_rating.w_%,%_wh_%,00-00-05,)
    $drawtextex($repeat(b,5),$add(%_rating.x_%,05),$add(%_pad_top_%,3),%_rating.w_%,%_wh_%,35-35-40,)
    $drawtextex($repeat(b,5),$add(%_rating.x_%,05),$add(%_pad_top_%,2),%_rating.w_%,%_wh_%,20-20-25,)
    $font(guifx v2 transports,11,)
    $drawtextex($repeat(b,%_rating_%),$add(%_rating.x_%,05),$add(%_pad_top_%,3),%_rating.w_%,%_wh_%,0-0-0,)
    $drawtextex($repeat(b,%_rating_%),$add(%_rating.x_%,05),$add(%_pad_top_%,2),%_rating.w_%,%_wh_%,%_rating_colour_%,)
)

// playcounter
$if(%el_isplaying%,,
    $ifgreater(%_playcounter_%,0,
        $ifgreater(%_title.w_%,$get(free.w),
            $puts(playcounter.x,$sub(%_rating.x_%,%_playcounter.w_%))
        ,
            $puts(playcounter.x,$add($get(title.x),$get(title.w)))
        )
        $font(%_small_font_name_%, %_small_font_size_%,)
        $drawtextex(%_playcounter_%,$get(playcounter.x),%_pad_top_%,%_playcounter.w_%,%_wh_%,%_playcounter_colour_%,right)
    ,)
)

// icon select marker
$gradientrect(10,$add(%_pad_top_%,4),12,12,0-0-0,35-35-40,,)
$gradientrect(11,$add(%_pad_top_%,5),10,10,10-10-10,30-30-35,,)
$if($or(%el_selected%,%el_focused%),
    $font(Webdings,12,)
    $drawtextex('?',9,$add(%_pad_top_%,0),15,15,50-170-210,)
,)

)


Marc, I have a further question. I am very interesset in the foobar skin here: http://br3tt.deviantart.com/art/Xch4nge-216397917 (http://br3tt.deviantart.com/art/Xch4nge-216397917)
The big problem is that your excellent script would not work on this skin because it you the WHS Panel Mod Mod 1.4.2.

How complicated is it port a skin to the newer Version of WHS Panel Mod Mod?

Many thanks!

Andi
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-03-28 04:58:15
you can't update that skin to a newer version of WSH panel mod because it uses a 3rd party modification of the official component to allow aero glass effects. it hasn't been updated since 1.4.2 so there is nothing you can do about it.

as for the ELplaylist code, the first number $sub(%el_width%,90) is the x co-ordinate for the image. in this case it's 90px away from the right side. if you want it a fixed distance from the left side then you'd just put a number on it's own without using $sub. 0 is the y co-ordinate. you may need to tweak these values in your own script. this is how it looks in mine:

(http://dl.dropbox.com/u/22801321/elplaylist.png)

right click an item in the playlist>properties and check the properties tab to see if the correct entries exist under the custom database section.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Maeldun on 2012-04-01 08:21:59
Hello Marc,

Much love for you and your script which I now find absolutely indispensable.

It seems to have abruptly stopped working for me though:


Playcount sync: Contacting Last.fm....
Error: WSH Panel Mod (Playcount Sync by marc2003): msxml3.dll:
The download of the specified resource has failed.

File: C:\Users\Adi\AppData\Roaming\foobar2000\\marc2003\common.js
Ln: 170, Col: 2
<source text only available at compile time>


I've updated to the 1.5.2 version of the component (which component update was not able to pick up) and overwrote my appdata files using the http://dl.dropbox.com/u/22801321/playcount%20sync.zip (http://dl.dropbox.com/u/22801321/playcount%20sync.zip) link you posted earlier. This has not made any difference.

Any suggestions?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-04-01 08:33:05
you haven't imported the latest script in to your panel.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Maeldun on 2012-04-01 09:01:49
You mean importing the latest script code from the latest "playcount sync.txt" file, right?

Ok, I did that right now.. still doesn't work.

Quote
Playcount Sync: Contacting Last.fm....
Error: WSH Panel Mod (Playcount Sync by marc2003): msxml3.dll:
The download of the specified resource has failed.

File: C:\Users\Adi\AppData\Roaming\foobar2000\marc2003\common4.js
Ln: 162, Col: 2
<source text only available at compile time>


It seems I get an error on another line of code than before though.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-04-01 09:17:04
that error points to a line of code where it's trying to access the internet. you haven't got a firewall running that would block it? you haven't tried removing internet explorer (i believe it uses files from this to do it's work)

can you think of any other system changes you've made when it stopped working?? i must admit i don't really have any idea...
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Maeldun on 2012-04-01 11:33:47
Ok, got it working again.. although I'm not sure what I did exactly.

In the WSH panel that showed the "aww, crashed" error I right clicked -> edit and then apply, or something similar - and that apparently prompted foobar to re-parse the files related to the script. (I did not modify anything)

Quote
WSH Panel Mod (Playcount Sync by marc2003): Parsing file "C:\Users\Adi\AppData\Roaming\foobar2000\marc2003\common4.js"
WSH Panel Mod (Playcount Sync by marc2003): Parsing file "C:\Users\Adi\AppData\Roaming\foobar2000\marc2003\tooltip_buttons.js"
WSH Panel Mod (Playcount Sync by marc2003): initialized in 10 ms
WSH Panel Mod (Playcount Sync by marc2003): Parsing file "C:\Users\Adi\AppData\Roaming\foobar2000\marc2003\common4.js"
WSH Panel Mod (Playcount Sync by marc2003): Parsing file "C:\Users\Adi\AppData\Roaming\foobar2000\marc2003\tooltip_buttons.js"
WSH Panel Mod (Playcount Sync by marc2003): initialized in 5 ms


Maybe I should have done something like this after importing?

Now it's working again. Maybe this will be of some help to others. Thanks for the help.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: D.Sync on 2012-06-06 13:25:23
Thanks for the script marc. However I noticed that foobar will pause for a few seconds when I click on the LOVE icon or auto rating is used. I assumed that the delay is because the script is contacting the lastfm server? Is it possible to make it doing it on background?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-06-08 13:52:33
you mean the music is pausing? it shouldn't do that. 

the only thing i notice is a temporary freeze of visualisations if they're active.

-how big is your library (some people complain foo_customdb is slow if it's very big)
-does it pause when playing back normally. the script contacts last.fm in the same way to fetch updated playcounts half way through.
-does it pause when using foo_softplaylists manually from the context menu? you should find the love track option under the Last.fm submenu.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: D.Sync on 2012-06-09 06:49:34
Nope the music is still playing fine. What I meant is that the interface will freeze for 1-2 seconds (e.g. no interaction possible, visualizer freeze) while the script is contacting with last.fm server. And yes it does freeze when I love a track using the softplaylist.

My library is fairly large, around 2500 albums. I do not see this is a problem with foo_customdb because when I enter a custom tag in it, freezing does not occur.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ca5k on 2012-06-11 07:20:06
Everytime I go to use the WSH I get:

Code: [Select]
GUID: E348B0C4-8447-48A0-8A74-51C5C856CA5F, CODE: 0x80020101



I'm using CUI
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-06-11 10:10:17
@D.Sync

if it freezes when using foo_softplaylists then there is obviously nothing i can do about that. and to be honest, i can't even suggest anything about the script either. i've had instances where last.fm can take 5-10 seconds to reply and it doesn't cause foobar to become unresponsive because it runs in the background. and even i could reproduce the problem myself, there aren't any changes i know of that could fix it.

@ca5k

have you disabled safe mode in the wsh panel mod preferences like the readme says? if you have, then i have no idea...
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-06-19 14:47:10
@D.Sync, i've discovered my script can indeed foobar can go un-responsive when it's updating foo_customdb. i've never noticed running foobar on a normal pc but this week i'm running it from a slow USB stick and the delay is definitely there. it's not the network side at all because i've tested for that. you can tell what i'm going to say next... there's nothing i can do about it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: tyblazitar on 2012-08-02 23:50:06
I installed this on my laptop the other day, and got it to work fine, but I tried doing the same on my desktop, and for some reason I'm having a problem with play counts not showing. However, after playing a track and thus increasing the play count by 1, it will display the updated play count. I've tried using the Customdb refresh, but though it seems to be working and doing something, the play count is still blank. I've tried importing my library again several times, but it doesn't help. Any idea how I can fix this, or will I have to listen to every song I have once more to make them display properly?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-08-06 18:10:03
the reason why this happens is explained in the readme. i've emphasised the important bit in bold.

Quote
Limitations:
Unfortunately, I have no way to manipulate your foobar library. Instead I have to fetch your whole Last.fm library and import that into foo_customdb. So the database may well contain tracks that don’t exist in your foobar library. Also, the spelling and punctuation of your artist and title tags have to be an exact match to what is fetched from Last.fm (case isn’t important). This may be an issue for some because by default, Last.fm uses spelling correction on their website to “fix” any wrong tags you submit when scrobbling. When this happens you may well have blank entries in your playlists when displaying playcount data.
However, when doing background updates, it is possible fetch data for auto-corrected artist names and tie them to the correct track in your library.


If you don’t like Last.fm auto-correcting your submitted data, you can turn this off by visiting this page…
http://www.last.fm/settings/website (http://www.last.fm/settings/website)
If you do this, make sure you turn off the option found on this script’s context menu as well (Auto-updates>Use spelling correction).
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: tyblazitar on 2012-08-06 22:48:05
I doubt that's the problem, as I've had auto-correcting disabled on last.fm for a long time, and turned it off in the script as well. Also, this happens to every single track that hasn't been played since adding the script, and I doubt they're all tagged wrong. Also, what's not showing aren't the entries themselves, but the play count, though rather than "not showing" I should say that they're all at 0.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: BrutuZ on 2012-08-07 16:10:57
I doubt that's the problem, as I've had auto-correcting disabled on last.fm for a long time, and turned it off in the script as well. Also, this happens to every single track that hasn't been played since adding the script, and I doubt they're all tagged wrong. Also, what's not showing aren't the entries themselves, but the play count, though rather than "not showing" I should say that they're all at 0.

I have to ask: Are you sure the displayed column is using the foo_customdb value instead of the built-in playcount component?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: tyblazitar on 2012-08-07 17:37:55
I have to ask: Are you sure the displayed column is using the foo_customdb value instead of the built-in playcount component?

It's using "%LASTFM_PLAYCOUNT_DB%", yes, and if it was using the normal playcount component, I would notice many playcounts being very different. Also, that wouldn't explain the playcount suddenly changing to a completely different number once I play a track.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-08-09 13:03:02
so you haven't actually ran the import then? 

and try and please be more accurate with your reporting so i don't have to guess. you mention "0" in a previous post but it will never show that - entries without playcounts are blank. also, it's worth checking the foobar console found on the main view menu for messages.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: tyblazitar on 2012-08-10 13:48:58
I did run the import, as mentioned I tried several times with no different results. Everything seemed to work fine while doing the import, but the play counts still didn't update.

Yeah, sorry about that, they're blank. I imported again with the same result, but when starting Foobar again, I found this in the console:

Custom Database: Initialize
Custom Database: table quicktag already exists (1)
Custom Database: table database_version already exists (1)
Custom Database: index url_idx already exists (1)
Custom Database: Completed
WSH Panel Mod (Last.fm Playcount Sync by marc2003): initialized in 104 ms

Could this be related to the problem? Also, I should maybe mention that the first time I ran the import I forgot to close foobar for that last screen, could that have caused problems even after doing it again, correctly?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-08-11 12:09:53
so long as you imported it once correctly with foobar closed, it really shouldn't matter if it wasn't done properly before.

a few things to look at....

-can you check File>preferences>tools>custom database and then the database tab? the entries should probably be in the thousands depending on how many tracks you have.

-assuming the tracks are monitored as part of your foobar libraryuse the Library>search menu and enter this as the query...

%LASTFM_PLAYCOUNT_DB% PRESENT

are you getting numbers somewhere near the entries value? (it won't match if you have loved tracks because that would be part of the entries total)

if all this shows up ok then right click a track in the search window and select properties and then the properties tab. there should be a custom database section showing totals. if values appear here but not in your playlist then something is wrong with your playlist view???



Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: tyblazitar on 2012-08-11 13:53:41
It says there are 3884 entries in the database, which is a lot less than the number of tracks I have (and have listened to at least once), and a lot more than the number of tracks that currently show up with a play count. A library search shows that the playcount is present in 4130 tracks, so yeah, pretty close. I haven't loved any tracks though.

When checking the Properties - Properties tab, the tracks that won't display play count doesn't have a Custom Database section, so it doesn't seem to be a playlist view problem.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-08-13 13:23:51
assuming you use the same username here as you do on last.fm, i can see that account has 12490 different tracks in the library. if that is you then the import hasn't completed properly. try again and when the blue window pops up, check the foobar console for errors before closing it.

it shouldn't make any difference but you could start afresh by deleting the file named customdb_sqlite.db in your foobar profile folder while foobar is closed and before starting the import.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: tyblazitar on 2012-08-13 14:59:22
That's my account, yeah. I tried importing again after deleting the customdb_sqlite.db file, and it still doesn't work. The console said:

Completed page 125 of 125 (playcount)
Loved track page errors: 1 (200 records are lost for every page that fails.)
Playcount page errors: 0 (100 records are lost for every page that fails.)
Individual errors: 0

EDIT: Fixed my problem by copying over the db file from my laptop, so now I have my playcounts back at least. Still no idea what caused it though.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: dumdidum on 2012-08-20 18:42:54
finally got around to playing with this. works like a charm, thanks a lot

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: tagged on 2012-08-21 15:28:43
Works perfectly. Thanks!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: BrutuZ on 2012-08-30 00:08:53
Bumped into a small issue here.
If I have a track with multiple artists split in the tag %artist%, but scrobble and love this track with only the first artist (so that Last.fm won't tell me the artist is invalid or whatever) the script won't set the loved status on the DB.

For example: This song (Helena Noguerra - Fly Me To The Moon (∞ Climax Mix) (http://www.last.fm/user/BrutuZ/library/music/Helena+Noguerra/_/Fly+Me+To+The+Moon+%28%E2%88%9E+Climax+Mix%29) is loved on Last.fm, however the file's %artist% tag value is Helena Noguerra; Hiroshi Yamaguchi (note the semicolon splitting the multiple values) and since the names don't match the %LASTFM_LOVED_DB% isn't set correctly.
Any ideas on how to circumvent this?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-08-30 15:05:53
file>preferences>tools>custom database>fields tab

edit both custom entries...

Code: [Select]
$crc32($lower(%artist%%title%))


should become

Code: [Select]
$crc32($lower($meta(artist,0)%title%))


RESTART foobar now. foo_customdb is buggy if these changes are made without immediately restarting

now inside the panel for the script....

line 95 should become

Code: [Select]
artist = fb.TitleFormat("$meta(artist,0)").EvalWithMetadb(g_metadb);


line 100 should become

Code: [Select]
crc32 = fb.TitleFormat("$crc32($lower($meta(artist,0)%title%))").EvalWithMetadb(g_metadb);


i think that should do it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: BrutuZ on 2012-08-31 02:51:21
Thanks marc, I must be using quite an old version of the script because both the database and script code itself are significantly different. The lines you mentioned are around 50 here instead of 100, and the customdb values were different with LOVED_DB not using the crc32 function.

Anyway, I edited the corresponding settings and hopefully it'll work now, thanks again
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: sevenarts on 2012-09-12 17:34:36
Thanks for this script, it's great! I've got it working nicely and set it up so that when I rate a track 5, it's automatically loved. I also added a statement so that when a track that is currently loved is no longer rated 5, it gets unloved, both at last.fm and in the customdb.

The next step I can't quite figure out though: if I love a track from some other method besides rating it 5, I want to automatically update the rating (which is the rating field from Playback Statistics, not a tag).

Also, I know this was in previous versions of the script, and I'd love it if the "sync now" context menu option was restored. I know, I can just play the track for a few seconds but it's even more convenient to just click a menu command or, better yet, hit a shortcut key.

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: sevenarts on 2012-09-12 17:58:35
Sorry, one more question:

Is there some reason the auto-correct feature can't work on library import? I noticed that all tracks that were auto-corrected by last.fm were not updated on import, but will only update if I play them after the import. I have an annoying number of these and it would be nice if importing the library performed the auto-correct searches.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: gob on 2012-09-12 19:03:58
I understand that solution allows you to import your playback stats from last.fm into foobar2000, but is there a way to do this in reverse? My last fm stats have not been updated in over two years, so I'd like to basically overwrite them with my stats from foobar2000. Is this at all possible, even outside the scope of your solution here?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-09-13 10:38:10
as far as i know, last.fm only supports importing into new accounts when using their official client app with itunes, WMP or winamp.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zageron on 2012-09-13 17:15:36
foo_softplaylists: feed downloading: error
foo_softplaylists: failed to unlove track: authentication failed: empty reply
foo_softplaylists: failed to unlove track '[insert track here]' by '[artist]'

This is all I get when I try to use the un-love function. I have used this functionality successfully in the past, but for the last few weeks I haven't been able to.


My password in soft playlists was incorrect. What a tool.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: BrutuZ on 2012-09-14 03:12:24
as far as i know, last.fm only supports importing into new accounts when using their official client app with itunes, WMP or winamp.

That and mobile devices. For instance, I use Pocket Player on my Windows Mobile Pro 6.1 phone (a Samsung Omnia i900), and even though it is a third party software, it has it's own plugin that caches the played tracks and scrobble all of them when the phone connects to the internet with the player running.
Pretty much the same functionality foo_audioscrobbler has, caching played tracks and scrobbling when possible.

I don't think you could "cheat" the system to accept 2 whole years worth of scrobbles though.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: error on 2012-11-13 19:06:56
(http://puu.sh/1pQ2v.png)

is it normal for this to happen? i tried to update my plays count so i deleted my old customdb_sqlite.db then i right clicked >library import > create and import sql file but this has been happening for a long time now

i mainly did this because i had a problem where i would play a song and it would update to 1 play fine but when i played it again it wouldnt update at all why could that be?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: error on 2012-11-14 03:45:31
actually nevermind i got it fixed^^^

i would edit the post but i cant see/find the edit button
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: スラッシュ on 2012-11-18 06:16:30
Hey dude, I bought a new computer and decided to update to the latest version, it works fantastically well! I just have one suggestion that you can think about: For songs under 30 seconds, since last.fm doesn't keep track of those (which is laaaaaame), how about locally adding +1 to the LASTFM_PLAYCOUNT_DB, when they're done playing? I know you can't do anything about last.fm's stupid 30 second or less thing, but that way at least the playcount increases on new plays, so I don't get a playlist in which some tracks have 0 plays while everything else has 10+. It's not a big deal I guess but it would be neat!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: protospork on 2012-11-24 21:08:02
Every time I try to do a full library import, the script crashes after getting one page of loved tracks.

Code: [Select]
Last.fm Playcount Sync: Completed page 1 of 2 (loved tracks) 
Error: WSH Panel Mod (Last.fm Playcount Sync by marc2003): Microsoft JScript runtime error:
'page' is undefined
File: M:\foobar2000\marc2003\common6.js
Ln: 2116, Col: 4
<source text only available at compile time>


Since I only have 253 loved tracks, I "fixed" it by changing
Code: [Select]
"&method=user.getlovedtracks&limit=200&page="

on line 2079 to
Code: [Select]
"&method=user.getlovedtracks&limit=260&page="


Just thought you should know about the issue.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-11-26 10:16:15
thanks for spotting that. here's the proper fix.

line 2116

Code: [Select]
this.sync_loved(page);


should be

Code: [Select]
this.sync_loved(this.page);


now it should work regardless of how many results there are. i've updated the file hosted file as well. just the file common6.js inside the marc2003 folder needs extracting again and the panel needs to be reloaded to pick up the change if foobar is running.

edit: i did do major background updates about a week ago without announcing it so anyone using my script from before then won't have this problem. if people do update to this from the older version, they need to update the script in the panel as well.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ehrgeiz on 2012-11-27 21:57:38
since i got fed up with the trackdetail panel from columnsUI i tried to write my own on top of marcs scripts.
i guess it's written in a horrible way but it works for me  thx for all the stuff to play with!

(http://e600.betise.org/public/trackdetails/trackdetails1.png) (http://e600.betise.org/public/trackdetails/trackdetails2.png) (http://e600.betise.org/public/trackdetails/trackdetails3.png) (http://e600.betise.org/public/trackdetails/trackdetails4.png)


ah and i have one feature request for the 'now playing' script! it would be awesome if it could remember
which artist picture it was set too and not always return to the first one in the folder. writing a new config
file in the wsh_lastfm folder would be the way to go i think?

Code: [Select]
// ==PREPROCESSOR==
// @import "%fb2k_profile_path%marc2003\common6.js"
// @name "Trackdetails"
// @author "ehrgeiz dabbling on top of marc2003 scripts"
// @feature "v1.4"
// @feature "watch-metadb"
// ==/PREPROCESSOR==


//first argument is any arbitrary text to name the panel. it will use in the console and popup boxes.
//seconds argument is an array of features. it's mostly for handling right click menus.
var p = new panel("Track Details", ["remap"]);
//force the panel to always prefer the playing track regardless of selection
p.selection_mode = 1;

// adding some modified textfunction from common6.js since id dont like DT_VCENTER
p.right_text_ml = function(gr, text, font, colour, x, y, w, h) {
gr.GdiDrawText(text, font, colour, x, y, w, h, DT_RIGHT | DT_END_ELLIPSIS | DT_CALCRECT | DT_NOPREFIX);
}

//setup all metadata fields you want to display. if you change the font sizes, adjustments may need
//to be made to the positions in the on_paint function
var genre = {text: "", tf: "$if(%genre%,$lower(%genre%),[no genre set]$crlf())", font: gdi.Font("Segoe UI", 18, 1), colour: RGB(180, 180, 180)}
var style = {text: "", tf: "$if(%style%,$lower(%style%),)", font: gdi.Font("Segoe UI", 14, 2), colour: RGB(180, 180, 180)}

var comp_b = {text: "", tf: "$if(%composer%,composer,)", font: gdi.Font("Segoe UI", 10, 0), colour: RGB(180, 180, 180)}
var comp_c = {text: "", tf: "$if(%composer%,$meta_num(composer),)"}
var compo = {text: "", tf: "$if(%composer%,$meta_sep(composer,$crlf()),)", font: gdi.Font("Segoe UI", 10, 1), colour: RGB(180, 180, 180)}

var lyri_b = {text: "", tf: "$if(%lyricist%,lyricist,)", font: gdi.Font("Segoe UI", 10, 0), colour: RGB(180, 180, 180)}
var lyri_c = {text: "", tf: "$if(%lyricist%,$meta_num(lyricist),)"}
var lyric = {text: "", tf: "$if(%lyricist%,$meta_sep(lyricist,$crlf()),)", font: gdi.Font("Segoe UI", 10, 1), colour: RGB(180, 180, 180)}

var cond_b = {text: "", tf: "$if(%conductor%,conducter,)", font: gdi.Font("Segoe UI", 10, 0), colour: RGB(180, 180, 180)}
var cond_c = {text: "", tf: "$if(%conductor%,$meta_num(conductor),)"}
var condu = {text: "", tf: "$if(%conductor%,$meta_sep(conductor,$crlf()),)", font: gdi.Font("Segoe UI", 10, 1), colour: RGB(180, 180, 180)}

var perf_b = {text: "", tf: "$if(%performer%,performer,)", font: gdi.Font("Segoe UI", 10, 0), colour: RGB(180, 180, 180)}
var perf_c = {text: "", tf: "$if(%performer%,$meta_num(performer),)"}
var perfo = {text: "", tf: "$if(%performer%,$meta_sep(performer,$crlf()),)", font: gdi.Font("Segoe UI", 10, 1), colour: RGB(180, 180, 180)}

var engi_b = {text: "", tf: "$if(%engineer%,engineer,)", font: gdi.Font("Segoe UI", 10, 0), colour: RGB(180, 180, 180)}
var engi_c = {text: "", tf: "$if(%engineer%,$meta_num(engineer),)"}
var engin = {text: "", tf: "$if(%engineer%,$meta_sep(engineer,$crlf()),)", font: gdi.Font("Segoe UI", 10, 1), colour: RGB(180, 180, 180)}

var staf_b = {text: "", tf: "$if(%involvedpeople%,staff,)", font: gdi.Font("Segoe UI", 10, 0), colour: RGB(180, 180, 180)}
var staf_c = {text: "", tf: "$if(%involvedpeople%,$meta_num(involvedpeople),)"}
var staff = {text: "", tf: "$if(%involvedpeople%,$meta_sep(involvedpeople,$crlf()),)", font: gdi.Font("Segoe UI", 10, 1), colour: RGB(180, 180, 180)}

var publ_b = {text: "", tf: "$if(%publisher%,released by,)", font: gdi.Font("Segoe UI", 10, 0), colour: RGB(180, 180, 180)}
var publi = {text: "", tf: "$if(%publisher%,%publisher%,)$crlf()$if(%ORIGINAL RELEASE DATE%, $if($strcmp(%date%,%ORIGINAL RELEASE DATE%), ©$char(8471) %date%, © %date% $char(8471) %ORIGINAL RELEASE DATE% ), © %date%)", font: gdi.Font("Segoe UI", 10, 0), colour: RGB(180, 180, 180)}

var playc = {text: "", tf: "$if(%LASTFM_PLAYCOUNT_DB%,Track played$ifequal(%LASTFM_PLAYCOUNT_DB%,1, only once,$ifequal(%LASTFM_PLAYCOUNT_DB%,2, twice, %LASTFM_PLAYCOUNT_DB% times)),no plays)", font: gdi.Font("Segoe UI", 10, 0), colour: RGB(180, 180, 180)}

var dbtxt = {text: "", tf: "", font: gdi.Font("Segoe UI", 10, 0), colour: RGB(0, 0, 0)}

//startup
on_item_focus_change();

function on_size() {
//always call p.size to update the values of p.w and p.h
p.size();
}

function on_paint(gr) {
    //setup a variable for y-offset
    var cr = 40;
    //setup a variable for lineheight
    var lh = 12;
    //var debugvar = cond_c.text;
    //p.draw_background(gr);
    //background for trackdetails
gr.FillSolidRect(0, 0, p.w, p.h - 15, RGBA(0, 0, 0, 156));
//draw trackdetails
    //genre+style
    p.right_text(gr, genre.text, genre.font, genre.colour, 5, 4, p.w - 10, 18);
    p.right_text_ml(gr, style.text, style.font, style.colour, 5, 16, p.w - 10, 20);
    //composer
    if (comp_b.text.length != 0) {   
        p.left_text(gr, comp_b.text, comp_b.font, comp_b.colour, 5, cr, p.w - 10, 12);
        p.right_text_ml(gr, compo.text, compo.font, compo.colour, 5, cr += 10, p.w - 10, p.h - cr - 45);
        cr = cr + lh * comp_c.text;
    }
    //lyricist
    if (lyri_b.text.length != 0) {
        p.left_text(gr, lyri_b.text, lyri_b.font, lyri_b.colour, 5, cr, p.w - 10, 12);
        p.right_text_ml(gr, lyric.text, lyric.font, lyric.colour, 5, cr += 10, p.w - 10, p.h - cr - 45);
        cr = cr + lh * lyri_c.text;
    }
    //conductor
    if (cond_b.text.length != 0) {
        p.left_text(gr, cond_b.text, cond_b.font, cond_b.colour, 5, cr, p.w - 10, 12);
        p.right_text_ml(gr, condu.text, condu.font, condu.colour, 5, cr += 10, p.w - 10, p.h - cr - 45);
        cr = cr + lh * cond_c.text;
    }
    //performer
    if (perf_b.text.length != 0) {
        p.left_text(gr, perf_b.text, perf_b.font, perf_b.colour, 5, cr, p.w - 10, 12);
        p.right_text_ml(gr, perfo.text, perfo.font, perfo.colour, 5, cr += 10, p.w - 10, p.h - cr - 45);
        cr = cr + lh * perf_c.text;
    }
    //engineer
    if (engi_b.text.length != 0) {
        p.left_text(gr, engi_b.text, engi_b.font, engi_b.colour, 5, cr, p.w - 10, 12);
        p.right_text_ml(gr, engin.text, engin.font, engin.colour, 5, cr += 10, p.w - 10, p.h - cr - 45);
        cr = cr + lh * engi_c.text;
    }
    //involved people
    if (staf_b.text.length != 0) {
        p.left_text(gr, staf_b.text, staf_b.font, staf_b.colour, 5, cr, p.w - 10, 12);
        p.right_text_ml(gr, staff.text, staff.font, staff.colour, 5, cr += 10, p.w - 10, p.h - cr - 45);
        cr = cr + lh * staf_c.text;
    }
    //publisher/label
    //p.left_text(gr, publ_b.text, publ_b.font, publ_b.colour, 5, cr, p.w - 10, 12);
    p.right_text(gr, publi.text, publi.font, publi.colour, 5, p.h - 35, p.w - 10, 12);
    //lastfm.playcount
    //first draw background
    gr.FillSolidRect(0, p.h - 15, p.w, 15, RGBA(0, 0, 0, 116));
    p.centre_text(gr, playc.text, playc.font, playc.colour, 5, p.h - 14, p.w, 12);
//debug
    //gr.FillSolidRect(0, 0, 60, lh * perf_c.text, RGBA(255, 0, 0, 236));
    //p.left_text(gr, debugvar, dbtxt.font, dbtxt.colour, 0, 0, 60, 12);
}

function on_metadb_changed() {
//call these functions when selection changes/tag updates are made
if (p.metadb) {
        genre.text = p.eval(genre.tf);
        style.text = p.eval(style.tf);
       
        comp_b.text = p.eval(comp_b.tf);
        comp_c.text = p.eval(comp_c.tf);
        compo.text = p.eval(compo.tf);
       
        lyri_b.text = p.eval(lyri_b.tf);
        lyri_c.text = p.eval(lyri_c.tf);
        lyric.text = p.eval(lyric.tf);
       
        cond_b.text = p.eval(cond_b.tf);
        cond_c.text = p.eval(cond_c.tf);
        condu.text = p.eval(condu.tf);
       
        perf_b.text = p.eval(perf_b.tf);
        perf_c.text = p.eval(perf_c.tf);
        perfo.text = p.eval(perfo.tf);
       
        engi_b.text = p.eval(engi_b.tf);
        engi_c.text = p.eval(engi_c.tf);
        engin.text = p.eval(engin.tf);
       
        staf_b.text = p.eval(staf_b.tf);
        staf_c.text = p.eval(staf_c.tf);
        staff.text = p.eval(staff.tf);
       
        publ_b.text = p.eval(publ_b.tf);
        //publ_c.text = p.eval(publ_c.tf);
        publi.text = p.eval(publi.tf);
       
        playc.text = p.eval(playc.tf);
}
window.Repaint();
}

function on_playback_stop() {
on_item_focus_change();
// b.update();
}

function on_mouse_wheel(step) {
//scroll text
//if (t.wheel(step)) return;
//this scrolls through multiple images
//im.wheel(step);
}

function on_mouse_move(x, y) {
//we only need to call p.move if there elements in our panel which require scrollling as i need to track where the mouse is. do not return after it.
p.move(x, y);
}

function on_mouse_rbtn_up(x, y) {
//handles right click menu.
p.rbtn_up(x, y);
return true;
}
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: error on 2012-11-30 22:46:45
Why do i get this

Code: [Select]
Error: WSH Panel Mod (Last.fm Playcount Sync by marc2003): Parsing file "C:\Users\nand\Desktop\foobar2000\marc2003\common4.js": Failed to load
WSH Panel Mod (Last.fm Playcount Sync by marc2003): Parsing file "C:\Users\nand\Desktop\foobar2000\marc2003\tooltip_buttons.js"
Error: WSH Panel Mod (Last.fm Playcount Sync by marc2003): Microsoft JScript runtime error:
'settings_path' is undefined
File: <main>
Ln: 16, Col: 1
<source text only available at compile time>

i'm adding it to a panel stack splitter and everything is upto date
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-12-01 09:34:09
Quote
Error: WSH Panel Mod (Last.fm Playcount Sync by marc2003): Parsing file "C:\Users\nand\Desktop\foobar2000\marc2003\common4.js": Failed to load


the bit in bold means the file is not there meaning the files were not extracted correctly. also you're using a slightly outdated version. i recommend using the latest.

http://dl.dropbox.com/u/22801321/playcount%20sync.zip (http://dl.dropbox.com/u/22801321/playcount%20sync.zip)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zageron on 2012-12-08 06:13:26
Quote
Error: WSH Panel Mod (Last.fm Playcount Sync by marc2003): Parsing file "C:\Users\nand\Desktop\foobar2000\marc2003\common4.js": Failed to load


the bit in bold means the file is not there meaning the files were not extracted correctly. also you're using a slightly outdated version. i recommend using the latest.

http://dl.dropbox.com/u/22801321/playcount%20sync.zip (http://dl.dropbox.com/u/22801321/playcount%20sync.zip)


Thank you for the update!
The script loads almost 3 times faster now!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-12-08 10:05:29
^that's unlikely. you shouldn't even notice the script having an effect on foobar starting up. if you mean the library import is quicker than that depends on how busy last.fm's servers are. they're usually faster in the middle of the night UK time. also, your own connection could affect it to a lesser extent.

edit: i just realised i broke the import feature with an update i made on the 5th december. it's easy to tell if you're running it because there is an Online update option on the context menu. run this option to fix it.

full download: http://dl.dropbox.com/u/22801321/playcount%20sync.zip (http://dl.dropbox.com/u/22801321/playcount%20sync.zip)

files changed:
Code: [Select]
marc2003\common6.js
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ladiko on 2012-12-16 08:23:59
Hello Marc,

i just updated from an at least one year old version to your newest one and that happened:

Code: [Select]
WSH Panel Mod (Last.fm Playcount Sync v6.2012-12-05.01 by marc2003): Parsing file "C:\Users\Benutzername\AppData\Roaming\foobar2000\marc2003\common6.js"
Error: WSH Panel Mod (Last.fm Playcount Sync v6.2012-12-05.01 by marc2003): Laufzeitfehler in Microsoft JScript:
Das Objekt unterstützt diese Eigenschaft oder Methode nicht.
File: C:\Users\Benutzername\AppData\Roaming\foobar2000\marc2003\common6.js
Ln: 2306, Col: 2
<source text only available at compile time>

i double checked everything and read the readme.pfd twice. before i didn't use foo_softplaylists as it was only needed if you want to love/unlove tracks. is it mandatory now? but even when i installed it as descripted, it didn't help.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-12-17 09:51:39
i'm guessing you didn't update WSH panel mod? that line points to a function that doesn't exist in older versions. the readme says you need at least version 1.5.0 (current version is 1.5.6)

http://code.google.com/p/foo-wsh-panel-mod/downloads/list (http://code.google.com/p/foo-wsh-panel-mod/downloads/list)

like the previous version, it's not necessary to install foo_softplaylists if you don't want to love tracks.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ladiko on 2012-12-17 21:53:42
seems like you are right, even if i used your readme.pdf and followed every step and still remember that i downloaded the wsh panel. let me just blame the "enhanced" windows 8 copy gui! anyway, now it works, great! by the way, the readme still states "WSH panel mod (v1.5.0 or later)" which i had before, but i remember something like 1.5.0 alpha/beta... so it might not match the requirement.

I guess i can delete the file wsh_lastfm/test.sql while i have to keep wsh_lastfm/lastfm.sql!? and wsh_settings/{username|api_key} are also still needed?

thanks for your fast help and the time, work and afford you put into this addon!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-12-18 09:29:29
you can delete both the sql files. they are temporary files used once by the import function. all the permanent data is stored inside customdb_sqlite.db

you can delete the api key file as i now provide that in the script. username is still required so don't remove that.

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: screamingtrees on 2012-12-18 23:42:57
Is there a way to edit the values for %lastfm_playcount_db% by hand? I want to try and fix the songs that have the same titles/artists (like live albums) so that they don't both have the same play count.

Also, once I've done the initial last.fm transfer, which components are still needed? Which can I delete?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: BrutuZ on 2012-12-19 00:55:03
Is there a way to edit the values for %lastfm_playcount_db% by hand? I want to try and fix the songs that have the same titles/artists (like live albums) so that they don't both have the same play count.

Also, once I've done the initial last.fm transfer, which components are still needed? Which can I delete?
You can edit the values by hand, but once the track is played  the script will fetch the Last.fm value and overwrite your change.

A more reliable fix would require editing the script to include the album name in the md5 hashing process for the tracks in the DB.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: screamingtrees on 2012-12-19 02:32:23
A more reliable fix would require editing the script to include the album name in the md5 hashing process for the tracks in the DB.


Do you know how?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-12-19 09:33:13
Also, once I've done the initial last.fm transfer, which components are still needed? Which can I delete?


if you have no intention of loving/unloving tracks, you can remove the foo_softplaylists component. the button will turn into an exclamation mark warning you about this but the import/background updating of tracks still works fine.

A more reliable fix would require editing the script to include the album name in the md5 hashing process for the tracks in the DB.


not really. you need to take into account what you're scrobbling to last.fm in the first place. although foo_audioscrobbler does submit the album data to last.fm, it's "lost" as far as fetching info from the API is concerned. unless you modify the title tag of the track to add (live) or whatever, all tracks with the same artist/title will be bundled together as if from the same album even when the album tags are different.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: screamingtrees on 2012-12-19 13:48:46
not really. you need to take into account what you're scrobbling to last.fm in the first place. although foo_audioscrobbler does submit the album data to last.fm, it's "lost" as far as fetching info from the API is concerned. unless you modify the title tag of the track to add (live) or whatever, all tracks with the same artist/title will be bundled together as if from the same album even when the album tags are different.


Thank you. And also thanks for working on this for so long.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: BrutuZ on 2012-12-20 00:54:25
not really. you need to take into account what you're scrobbling to last.fm in the first place. although foo_audioscrobbler does submit the album data to last.fm, it's "lost" as far as fetching info from the API is concerned. unless you modify the title tag of the track to add (live) or whatever, all tracks with the same artist/title will be bundled together as if from the same album even when the album tags are different.

Shame on me, completely forgot the "album" wasn't retrievable. 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: icepopo on 2012-12-23 01:07:15
I'm getting some errors while importing script to WSH(version 1.5.6) panel, what's wrong?

Code: [Select]
WSH Panel Mod (Last.fm Playcount Sync v6.2012-12-05.01 by marc2003): Parsing file "C:\Users\icepopo\AppData\Roaming\foobar2000\marc2003\common6.js"
Error: WSH Panel Mod (Last.fm Playcount Sync v6.2012-12-05.01 by marc2003): Microsoft JScript runtime error:
Automation server can't create object
File: C:\Users\icepopo\AppData\Roaming\foobar2000\marc2003\common6.js
Ln: 962, Col: 2
<source text only available at compile time>
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-12-24 09:18:02
Quote
what's wrong?


you didn't follow the readme properly.

Quote
Automation server can't create object


that specifically tells me you missed step 5.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Kironide on 2012-12-27 22:23:30
I had your awesome script working before using default UI, but I switch to column UI. Now I get this error from your script.

Code: [Select]
WSH Panel Mod (Last.fm Playcount Sync v6.2012-12-05.01 by marc2003): Parsing file "C:\Users\jake\AppData\Roaming\foobar2000\marc2003\common6.js"
Error: WSH Panel Mod (Last.fm Playcount Sync v6.2012-12-05.01 by marc2003): Microsoft JScript runtime error:
Object doesn't support this property or method
Ln: 2387, Col: 2
<source text only available in compile time>


I've tried re installing everything, including components. Do you know how to fix this?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-12-28 09:50:19
looking at that particular line of code, i'm almost certain it's because you're using an outdated version of WSH panel mod. the readme does state it requires at least 1.5.0 (current is 1.5.6).

i'm guessing you were using an older version of script with default UI and then updated my script at the same time as you switched to columns?

you can get the current version here: http://code.google.com/p/foo-wsh-panel-mod/downloads/list (http://code.google.com/p/foo-wsh-panel-mod/downloads/list)

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Kironide on 2012-12-28 17:52:45
Oh thank you so much that works I totally thought I did that already.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2012-12-31 10:44:43
EDIT: sorry this doesn't work quite as expected yet. i'll fix it tomorrow. for now i've reverted the changes. 

script updated: auto loving of tracks based on title formatting now detects changes on the fly. previously it would only check after 3 seconds had played to see if conditions were met.

use the update option found on the right click menu. if you don't have any update option then you need the full download from here.

http://dl.dropbox.com/u/22801321/playcount%20sync.zip (http://dl.dropbox.com/u/22801321/playcount%20sync.zip)

extract the marc2003 folder again and import the new playcount sync.txt file as well. from now on, you should be able to update the script from the right click menu.


Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: iamthejeff on 2013-02-15 23:45:56
Thanks so much for this script. Worked amazingly first try.

I understand the difficulty in regards to inconsistencies between file tags and the last.fm DB, however I am wondering if it's possible to implement some kind of fuzzy string matching? I have a library with about 35,000 songs and there are 8,000 that remain without playcounts. I know I have scrobbled most of them at least once.

You've probably been asked this before, but without an official FAQ of sorts, it's a little hard to track that information down.

Also, I am wondering how it handles scrobbles of the same song/artist across different albums. For example, a live version vs. the album version (where live isn't specified in the track title). Do all instances of that song/artist combo get updated?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: jabberwocky_one on 2013-02-16 06:38:13
Also, I am wondering how it handles scrobbles of the same song/artist across different albums. For example, a live version vs. the album version (where live isn't specified in the track title). Do all instances of that song/artist combo get updated?


Yep. Unless if their song titles are not the same.

Eg:
"Artist" - "Album (Studio)" - "Track 1"
"Artist" - "Album (Live)" - "Track 1"
would get double scrobbled.

"Artist" - "Album" - "Track 1 (Studio)"
"Artist" - "Album" - "Track 1 (Live)"
would have a separate scrobble.


Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-02-16 09:23:27
however I am wondering if it's possible to implement some kind of fuzzy string matching?


nope. as i mentioned in the readme, there is no way for me to access/manipulate your foobar library at all. all i do i dump all last.fm data into a database provided by foo_customdb and if it matches what's in your library (or even playlists) then great... if it doesn't... tough.

those empty values would eventually get filled as you listen because it's possible to query last.fm with your (according to last.fm) wrong  tags and have them return their auto-corrected value.

and the post above describes exactly what happens when you have the same artist/title spread across multiple albums. if you log into the last.fm website and browse the track pages and view your playcounts, you'll run into exactly the same issue. album tags are not considered at all.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ABOO on 2013-02-19 02:51:27
Thank you. I tried this out with foobar2000, and recieved no issues. Only after implementing a skin and some components, I receive an issue.

The configuration I am using is this on here. (http://sinusoid.deviantart.com/art/Case-for-Columns-UI-166272429) Along with all of it's listed components.

When ever I configure a WSH panel with the playcount sync code, I run into this error

Code: [Select]
WSH Panel Mod (Last.fm Playcount Sync v6.2013-01-23.01 by marc2003): Parsing file "C:\Users\Admin\AppData\Roaming\foobar2000\marc2003\common6.js"
Error: WSH Panel Mod (Last.fm Playcount Sync v6.2013-01-23.01 by marc2003): Microsoft JScript runtime error:
Object required
File: C:\Users\Admin\AppData\Roaming\foobar2000\marc2003\common6.js
Ln: 87, Col: 3
<source text only available at compile time>


Ln: 87 seems to fall under this section.
Code: [Select]
[85]    this.get_font = function() {
[86]        this.font = this.dui ? window.GetFontDUI(0) : window.GetFontCUI(0);
[87]        this.font_name = this.font.Name;
[88]        this.title_font = gdi.Font(this.font_name, 16, 1);
.        this.normal_font = gdi.Font(this.font_name, 12);
..        this.list_font = gdi.Font(this.font_name, 11);
...        if (typeof t == "object") t.calc();
        window.Repaint();
    }


I am new to foobar, plus I have little knowledge on any of this, so I really am stumped. I hope you can help me out. Thank you for any help, and once again for this great utility.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Andreasvb on 2013-02-19 07:44:32
Try change this.font.Name to this.font_name if it could be wrong name.

Else, it's best to hear with the author as we don't support others' skins.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-02-19 09:33:31
your WSH panel mod component is out of date. my readme says it needs 1.5.0 or above (current version is 1.5.6 available here: http://code.google.com/p/foo-wsh-panel-mod/downloads/list) (http://code.google.com/p/foo-wsh-panel-mod/downloads/list))
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: juso on 2013-02-20 01:21:32
Hello,

I have been browsing this entire thread for the answer to an issue I have been experiencing but I can't seem to sort this out,

Error Received:

WSH Panel Mod (Last.fm Charts v6.2012-12-05.01 by marc2003): Parsing file "C:\Users\Justin\Documents\Foobar 2000\marc2003\common6.js"
Error: WSH Panel Mod (Last.fm Charts v6.2012-12-05.01 by marc2003): Microsoft JScript runtime error:
Object doesn't support this property or method
File: <main>
Ln: 15, Col: 1
<source text only available at compile time>


Corresponding Line:

function on_font_changed() {

------------------------------------------

- I'm using a portable version of foobar
- All components are fully updated
- I have unchecked safe mode

Any help would be much appreciated
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-02-20 09:13:19
first of all, this post is in the wrong thread. it should be in this one (http://www.hydrogenaudio.org/forums/index.php?showtopic=77883).

and i know i've not documented this, but this part of the error....

Code: [Select]
File: <main>


means line 15 of the script in the panel itself - not the common6.js file.

and from a glance i think it's related to a change i made a few weeks back. download the full samples.zip and import the last.fm charts.txt file again.

link: http://db.tt/BInQ3Abm (http://db.tt/BInQ3Abm)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: juso on 2013-02-20 09:58:30
Hello marc2003, thanks for the explanation - I have downloaded the full samples.zip and re added everything, I now get no error - but I still can't seem to display anything. I have posted the issues I'm experiencing in the other thread that you have mentioned,

Cheers, juso
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: iamthejeff on 2013-02-27 17:49:14
Sometimes (about 10-20% of the time) the LASTFM_PLAYCOUNT_DB field is increased twice during a single play. Did I configure something wrong? Last.fm shows I only scrobbled it once, but the field is updated twice.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-02-27 18:40:31
are you sure only one instance of the panel exists in your layout? and even if there were duplicate requests, it would not affect playcount data. this is because a scrobble does not count until the track has finished. so even if there were multiple queries, the result would always be the same - of course i add 1 to increment the playcount but no matter how many times this were to happen, it would not increment by more than 1.

please describe exactly what you are seeing.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: iamthejeff on 2013-02-27 18:55:17
are you sure only one instance of the panel exists in your layout? and even if there were duplicate requests, it would not affect playcount data. this is because a scrobble does not count until the track has finished. so even if there were multiple queries, the result would always be the same - of course i add 1 to increment the playcount but no matter how many times this were to happen, it would not increment by more than 1.

please describe exactly what you are seeing.

I've only noticed it happening with songs that initially have zero playcounts (new to my library, and have not been scrobbled before). It might be happening to other songs, but I haven't noticed yet. It doesn't happen to every song with zero playcounts, just some.

I play the song in foobar. It gets to 50% duration, and the playcount increases from 0 to 2 instantly.

Console outputs this:

Last.fm Playcount Sync: Contacting Last.fm....
Last.fm Playcount Sync: Last.fm responded 'OK'

If I play the same song again, it only increases once, to 3.

I am pretty certain I don't have multiple instances of the panel in my layout. I use the mnlt2 skin with the panel on it's own tab:

(http://i.imgur.com/tRlU8HX.png)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-02-27 19:15:12
Quote
and the playcount increases from 0 to 2 instantly.


sorry but i'm more inclined to think you are mistaken and last.fm already has a playcount of 1 stored for that track. login to the website and browse the Library section.

http://www.last.fm/user/YOU/library (http://www.last.fm/user/YOU/library)

browse for the artist/track and it will show the time and date of each individual scrobble.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: iamthejeff on 2013-02-27 19:20:59
Quote
and the playcount increases from 0 to 2 instantly.


sorry but i'm more inclined to think you are mistaken and last.fm already has a playcount of 1 stored for that track. login to the website and browse the Library section.

http://www.last.fm/user/YOU/library (http://www.last.fm/user/YOU/library)

browse for the artist/track and it will show the time and date of each individual scrobble.


This is the test track I played which I've previously never scrobbled

(http://i.imgur.com/IwphkJ1.png)

(http://i.imgur.com/d2O8mYw.png)

(http://i.imgur.com/CjQ6RFT.png)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-02-27 19:47:01
well i'm just more confused now. 

because it's not just screwing up on the first play but on subsequent plays as well. the fact that playcounts are out of whack after playback has finished is not good either and i can't explain it - well other than the scrobble failing and getting stuck in the cache.

i still can't get how my script would fail in this way.

it's just one line of code that handles this. although it might be a bit confusing, this is simply a shorthand if/or statement....

Code: [Select]
this.userplaycount = this.parsed_data.track.userplaycount > 0 ? ++this.parsed_data.track.userplaycount : 1;


i check if the playcount is more than 0 (has been played) and i increment it by 1 if it has. if it hasn't i don't increment 0 to 1 by adding - i set the value of 1 directly as can be seen by the 1 after the colon at the end. using this method, it's impossible to jump from 0 to 2 on the first play.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: iamthejeff on 2013-02-27 20:03:31
Is the only explanation that I might have it installed twice? Still doesn't explain why it happens to only some songs and not others. I still haven't confirmed if it only happens to new songs, or if it happens to existing ones as well.

Could it be a conflict with other components?

These are my installed components:

Core (2012-12-28 12:23:58 UTC)
    foobar2000 core 1.2
foo_abx.dll (2012-07-15 05:00:36 UTC)
    ABX Comparator 1.3.4
foo_ac3.dll (2012-11-01 14:01:38 UTC)
    AC3 decoder 0.9.7
foo_albumlist.dll (2012-12-28 12:22:20 UTC)
    Album List 4.5
foo_audioscrobbler.dll (2008-05-13 21:36:16 UTC)
    Audioscrobbler 2.3.1
foo_cdda.dll (2012-12-28 12:21:56 UTC)
    CD Audio Decoder 3.0
foo_comserver2.dll (2006-07-31 19:13:20 UTC)
    COM Automation server 0.7 alpha 6
foo_converter.dll (2012-12-28 12:22:04 UTC)
    Converter 1.5
foo_customdb.dll (2013-02-15 23:03:38 UTC)
    Custom Database 0.0.9a
foo_dsp_eq.dll (2012-12-28 12:22:34 UTC)
    Equalizer 1.0
foo_dsp_soundtouch.dll (2012-01-06 20:38:14 UTC)
    SoundTouch DSP 1.1
foo_dsp_std.dll (2012-12-28 12:22:18 UTC)
    Standard DSP Array 1.2
foo_fileops.dll (2012-12-28 12:21:36 UTC)
    File Operations 2.2
foo_freedb2.dll (2012-12-28 12:20:38 UTC)
    Online Tagger 0.7
foo_input_monkey.dll (2012-11-01 14:01:38 UTC)
    Monkey's Audio Decoder 2.1.6
foo_input_std.dll (2012-12-28 12:21:48 UTC)
    Standard Input Array 1.0
foo_jesus.dll (2010-12-30 03:05:26 UTC)
    Autosave & Autobackup 10
foo_masstag.dll (2009-09-18 16:01:36 UTC)
    Masstagger 1.8.4
foo_playcount.dll (2011-10-17 02:26:26 UTC)
    Playback Statistics 3.0.2
foo_playlist_revive.dll (2012-10-02 17:19:55 UTC)
    Playlist Revive 0.2
foo_quicksearch.dll (2012-11-01 14:01:38 UTC)
    Quick Search Toolbar 3.4
foo_rgscan.dll (2012-12-28 12:21:32 UTC)
    ReplayGain Scanner 2.1.2
foo_run.dll (2009-06-07 21:15:18 UTC)
    Run services 0.3.7
foo_softplaylists.dll (2013-02-15 23:02:40 UTC)
    Soft Playlists 2011-02-05
foo_texttools.dll (2010-09-01 22:39:37 UTC)
    Text Tools 1.0.5
foo_ui_columns.dll (2010-05-03 13:38:32 UTC)
    Columns UI 0.3.8.6
foo_ui_std.dll (2012-12-28 12:22:32 UTC)
    Default User Interface 0.9.5
foo_uie_albumart.dll (2007-10-24 05:39:18 UTC)
    Album Art Panel 0.2.7
foo_uie_albumlist.dll (2009-06-13 22:49:19 UTC)
    Album list panel 0.3.5
foo_uie_console.dll (2009-08-29 16:06:24 UTC)
    Console panel 0.4
foo_uie_elplaylist.dll (2010-10-23 05:05:52 UTC)
    ELPlaylist 0.6.9.1(beta)
foo_uie_panel_splitter.dll (2009-12-09 16:16:12 UTC)
    Panel Stack Splitter 0.3.8.3(alpha)
foo_uie_typefind.dll (2007-10-22 21:30:44 UTC)
    Typefind 0.2 beta 2
foo_uie_vis_peakmeter_spectrum.dll (2008-04-20 03:18:50 UTC)
    Peakmeter Spectrum Visualisation 0.2.0.0 beta
foo_uie_wsh_panel_mod.dll (2013-02-15 23:02:02 UTC)
    WSH Panel Mod 1.5.6
foo_unpack.dll (2012-12-28 12:21:06 UTC)
    ZIP/GZIP/RAR Reader 1.6
foo_upnp.dll (2013-02-15 23:01:30 UTC)
    UPnP/DLNA Renderer, Server, Control Point 0.99.45
foo_verifier.dll (2009-10-05 18:39:20 UTC)
    File Integrity Verifier 1.1
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-02-27 20:14:22
Quote
foo_audioscrobbler.dll (2008-05-13 21:36:16 UTC)
Audioscrobbler 2.3.1

well that's the official last.fm scrobbler. i blame them. perhaps they are submitting before the track has finished playing which goes against their own specifications (well not now it seems). ditch it and use this....

http://mp3tag.de/en/fb2k.html (http://mp3tag.de/en/fb2k.html)

edit: i'm sure they've relaxed their own guidelines because now it says.....

Quote
When is a scrobble a scrobble?

A track should only be scrobbled when the following conditions have been met:

    The track must be longer than 30 seconds.
    And the track has been played for at least half its duration, or for 4 minutes (whichever occurs earlier.)

As soon as these conditions have been met, the scrobble request may be sent at any time. It is often most convenient to send a scrobble request when a track has finished playing.

i'm sure that wasn't the case before and it certainly conflicts with the way my script works.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: iamthejeff on 2013-02-27 20:20:58
Edit: ^^ okay, makes sense. There's definitely a conflict then.

The official scrobbler scrobbles at 50% of the track's duration by default, doesn't it?

(http://i.imgur.com/KCAayEs.png)

Shouldn't your script be compatible with the official scrobbler?

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-02-27 20:39:12
Shouldn't your script be compatible with the official scrobbler?


nope, everyone around here uses Florian's component. you're the first with this complaint.

if i did add support i'd have to complicate things by telling people not to touch that slider. i'm kind of reluctant really but i can tell you how to edit your own script. it'll have to be later on as i'm about to watch something on TV.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: iamthejeff on 2013-02-27 20:46:14
Shouldn't your script be compatible with the official scrobbler?


nope, everyone around here uses Florian's component. you're the first with this complaint.

if i did add support i'd have to complicate things by telling people not to touch that slider. i'm kind of reluctant really but i can tell you how to edit your own script. it'll have to be later on as i'm about to watch something on TV.


Okay, I'm fluent with javascript so if you could give me some modifications later, that'd be great. Thanks.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-02-27 20:55:59
just about got time now. use a text editor with line numbering support and open your foobar profile\marc2003 folder and open common6.js

find line 2134...

change it to...

Code: [Select]
this.target_time = 5 + Math.min(Math.floor(fb.PlaybackLength / 2), 240);


this tells my script when to run - i'm just adding a few seconds to let the scrobbler do it's thing.

line 2202 should become

Code: [Select]
this.userplaycount = this.parsed_data.track.userplaycount;


i'm not sure this is enough to withstand errors so let me know how you get on. after saving the file, make sure you reload the panel so it picks up the changes.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: kelmorn on 2013-02-27 23:52:28
Just had the same problem with last.fm playcount increasing by 2.

As above appears to be linked to use of last.fm's 'official' scrobbler. I've always set it to submit at 70% but this afternoon knocked it down to 50% and the problem started. It's back up at 70% now so I'm ok

And while I'm posting, thanks for creating this tool.

(Just spotted I've been a member for nearly six years and this is my first post  )
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-02-28 00:01:53
heh, such a simple workaround. i really should have thought of that.

i'll update the readme incase anyone else wants to use the official scrobbler.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: iamthejeff on 2013-02-28 17:41:31
Thanks for the update. I also changed my scrobbler to scrobble at 70% and it appears fixed.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-02-28 17:58:17
don't change the code AND increase the slider. that will have the side effect of not incrementing the playcount at all. the track won't get scrobbled until after my script has run and the modification writes the current (soon to be old) value into the database.

do one or the other. i think reverting the code change and increasing the slider is the best bet.

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: iamthejeff on 2013-03-01 02:34:09
i think reverting the code change and increasing the slider is the best bet.

that's what I did. And it means I'll be able to use future versions of the script without having to re-implement the hack
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: joelzhao on 2013-03-04 08:21:26
@marc2003:
Recently I found console says "Obsolete: Please use AppendTo() method to create sub menu instead of AppendMenuItem()", it used in common6.js. Would you have any plan to update it?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-03-04 08:49:48
i already did that..... in october 2011. 

https://dl.dropbox.com/u/22801321/playcount%20sync.zip (https://dl.dropbox.com/u/22801321/playcount%20sync.zip)

make sure you extract the marc2003 folder again AND import the new script.

EDIT: you should quickly check your settings on the context menu as i've changed a few things since then. and if it crashes, right click on the panel and select properties>clear. all your existing playcount data will be untouched as that hasn't changed.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: crshd on 2013-03-10 10:25:52
Everything worked fine until yesterday, and all of a sudden the panel keeps crashing. I didn't change anything, but just to make sure I set everything up from scratch, re-installed components, made sure I used the newest version of the script... 

Quote
WSH Panel Mod (Last.fm Playcount Sync v6.2013-01-23.01 by marc2003): Parsing file "C:\Program Files (x86)\foobar2000\marc2003\common6.js"
Error: WSH Panel Mod (Last.fm Playcount Sync v6.2013-01-23.01 by marc2003): Microsoft JScript runtime error:
Object required
File: C:\Program Files (x86)\foobar2000\marc2003\common6.js
Ln: 87, Col: 3
<source text only available at compile time>


EDIT Applied one of my infamous duct-tape style fixes - commented line 87. Seems to work for now.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-03-10 10:32:46
when you updated the script, you didn't update WSH panel mod at the same time. that line of code points to a feature that doesn't exist in older versions.

get the latest here: http://code.google.com/p/foo-wsh-panel-mod/downloads/list (http://code.google.com/p/foo-wsh-panel-mod/downloads/list)

the readme does state what version of WSH panel mod is required but i guess only new users would check that. i'll have to put an extra notice in the zip.

edit: the new file is in the zip and it reads as follows:

Quote
The current script requires WSH panel mod version 1.5.0 or above.

The latest version 1.5.6 is available here:

http://code.google.com/p/foo-wsh-panel-mod/downloads/list (http://code.google.com/p/foo-wsh-panel-mod/downloads/list)

You can check your component version by looking at
File>Preferences>Components>WSH panel mod.

Also, if you've made any changes to the default settings, check
the right-click menu to see if they're all intact. Some settings
may be lost during the upgrade as I've changed the way some
of them are stored.

Your username will still be intact and of course all playcount
data will remain exactly the same as before. There have been
no changes as far as that is concerned.

And from now on, you can check for the latest version simply
by right clicking the button and selecting "Update script".
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: jabberwocky_one on 2013-03-10 11:48:16
Everything worked fine until yesterday, and all of a sudden the panel keeps crashing. I didn't change anything, but just to make sure I set everything up from scratch, re-installed components, made sure I used the newest version of the script... 

Quote
WSH Panel Mod (Last.fm Playcount Sync v6.2013-01-23.01 by marc2003): Parsing file "C:\Program Files (x86)\foobar2000\marc2003\common6.js"
Error: WSH Panel Mod (Last.fm Playcount Sync v6.2013-01-23.01 by marc2003): Microsoft JScript runtime error:
Object required
File: C:\Program Files (x86)\foobar2000\marc2003\common6.js
Ln: 87, Col: 3
<source text only available at compile time>


EDIT Applied one of my infamous duct-tape style fixes - commented line 87. Seems to work for now.


bump, same issue. Updated WSH to 1.5.6 but error persists. Duct tape fix works for now. Was upgrading from playcount sync.zip dated 2012-03-02.

Edit: Am running foobar with applocale + CUI with "Small Font 7pt". (since line 87 references some fonts, I thought I should give it a mention)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-03-10 12:07:37
heh, your font is the culprit. if you look again, you'll see the error is different from before.

Object required tells me the component is out of date

but now it will say...

Unable to get value of the property 'Name': object is null or undefined

all i can do is "catch" this error and default to using another font instead. this doesn't even affect this script because it doesn't use fonts - it's just a shared function with all my other scripts that do.

edit: Now fixed. Use Update script on the right click menu and restart foobar when prompted. the console will report when it detects font names it can't read. it defaults to Segoe UI instead. i'll try and investigate further as to why this happens.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: nickdc on 2013-03-22 17:30:05
This plugin is really nice and works well. But what if i want to edit that love icon with a 16x16 icon? I've just replaced the pngs, but the new icon in foobar looks really stretched. Check this pic out:

(http://i46.tinypic.com/5ppljl.jpg)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-03-22 17:48:08
my latest version has support for switching between 2 images (right click>icon>tango is 32, silk is 20). if you still don't like that, edit line 18

Code: [Select]
b.buttons.ps = new button(0, 0, ps.size, ps.size, {normal: ps.n, hover: ps.h}, ps.func, ps.tooltip);


replace both instances of ps.size with 16.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: nickdc on 2013-03-23 10:41:27
Thanks, it works.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Nadeko on 2013-03-25 22:17:26
Hi, sorry if this has been posted before but I read the last 5 or so pages and didn't see anything about the issue I have so I was wondering if you could help me. I have my account credentials set up in soft playlists and last.fm radio and everything but when I click the heart button I only get this:

(http://i.imgur.com/5cxjaW3.png)
The auto love isn't working also.
(http://i.imgur.com/7IeUAxG.png)
I was wondering if you could help me figure out why?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Andreasvb on 2013-03-25 23:11:02
Did you forget a % in %rating%?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Nadeko on 2013-03-25 23:17:47
Did you forget a % in %rating%?


Silly me. Fixed that and it *looks* like it loved the track but checking last.fm says otherwise.
(http://i.imgur.com/H0b6W8C.png)
Also, the love button still doesn't work.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-03-26 09:28:01
whether foo_softplaylists succeeds or fails, it will always displays a message in the console and it should appear after

Code: [Select]
Automatically loving this track...


but before

Code: [Select]
Contacting Last.fm...


the fact it's not showing means one of two things.

a) it's not installed
b) you have its context menu items hidden and you're using an old version of my script which cannot handle that. the current version does.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Nadeko on 2013-03-26 15:18:05
whether foo_softplaylists succeeds or fails, it will always displays a message in the console and it should appear after

Code: [Select]
Automatically loving this track...


but before

Code: [Select]
Contacting Last.fm...


the fact it's not showing means one of two things.

a) it's not installed
b) you have its context menu items hidden and you're using an old version of my script which cannot handle that. the current version does.

The context menu isn't hidden
(http://i.imgur.com/bD6Y3Qg.png)
Soft Playlists
(http://i.imgur.com/tCv8oty.png)
and I am using the latest version of the script.
(http://i.imgur.com/S2Cg5hJ.png)
I am so confused.


Figured it out. The culprit was an outdated softplaylists.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-03-27 09:58:26
Figured it out. The culprit was an outdated softplaylists.


heh, even the current version is over 2 years old yet you still managed to run something older.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: kelmorn on 2013-03-30 22:53:25
I've been using this for a while and something has recently gone wrong.

When I run foobar the first played track is successfully synced, but from then on the sync fails.

The console shows the following
(first track played)
Last.fm Playcount Sync: Contacting Last.fm....
Last.fm Playcount Sync: Last.fm responded 'OK'
(second and subsequent tracks)
Last.fm Playcount Sync: Contacting Last.fm....
Last.fm Playcount Sync: HTTP error: 12030

Haven't a clue what causing the problem. WSH is up to date.
Any idea what is causing this problem?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-03-30 23:22:28
unfortunately i have no idea what that error means. i had a quick google and found this....

Code: [Select]
   12030       ERROR_INTERNET_CONNECTION_ABORTED
               The connection with the server has been terminated.


the script is doing all it can by reporting it but that's as far as it can go. sometimes last.fm can play up but they have a status page (http://status.last.fm/) that is usually good with current info and that's not reporting any problems and it's also fine for me at the moment. is your internet otherwise reliable? if it is, i suppose that points to a pc problem your end but i have no idea how to even begin troubleshooting it. sorry.

perhaps it was a recent software or windows update? but i really am clutching at straws as this stuff is way beyond my limited knowledge.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: kelmorn on 2013-03-31 11:30:26
Thanks. I'll have a look at a few things (next week) and see if I can find the problem. If I do I'll post something here.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: kelmorn on 2013-04-03 22:55:46
After a lot of searching I've got things working, but still not 100% sure where the problem is.

I worked through a list. eg Reinstalled old version of foobar with old version of this plugin, checked firewall etc etc. Eventually found that syncing worked when I turned off a program called Networx [link (http://www.softperfect.com/products/networx/)]. Eventually I tried installing an old version of Networx and that version works with this plugin. So everything is ok.

But... the version of Networx that causes the problem is from December 2012, and as this plugin was working a few weeks ago its suggests something else on my computer is causing the problem.

Anyway its working for now.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-04-03 23:38:36
that is very strange. i just tried the portable version on that page and it didn't affect my script at all. like you say, there must be yet something else causing a conflict??? 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Andreasvb on 2013-04-04 09:59:21
I also use NetWorx, portable. No problem here.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-04-04 11:06:32
i should mention that the Update script option found on recent versions of this script no longer works (you'll see an 404 page not found error from dropbox in your console).

this is because i've done another overhaul of all my other scripts and they all user a shared file, including this one. there are no functional changes but if people want support in the future i would ask that they use this latest version.

full download: https://dl.dropbox.com/u/22801321/playcount%20sync.zip (https://dl.dropbox.com/u/22801321/playcount%20sync.zip)

existing users just need to extract the marc2003 folder, overwriting the previous content and also import the new playcount sync.txt file into their panel.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Andreasvb on 2013-04-04 11:40:01
I think I use an old version, only for tag writing. Don't think it uses an online shared file.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-04-04 11:44:13
^heh, that is very, very old. i stopped writing tags years ago.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Kougeru on 2013-04-18 23:17:29
This is a godsend. I have slight autism that causes me to be very anal with my plays and Foobar has a tedencary to randomly reset them so I've been using last.fm since it came out for more accurate play data.

Sorry if this has been asked before, but is it possible to display the date of the last played via last.fm or is that beyond the capabilities of this? Not a major thing, just curious.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-04-18 23:33:42
not possible i'm afraid. although the full website pages display the last played date, this information is not available via the API.

as this data isn't quite so important as playcounts, perhaps you could leave foo_playcount installed to do it. that keeps track of first/last played dates.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Kougeru on 2013-04-19 03:54:07
Thanks, it's not a big deal. I was only asking because that is also affected when foobar randomly deletes my playback data, so I guess I can't completely move away from it just yet.

Another thing, it seems some songs were skipped during the scan. Nothing similar between them that I can tell, just randomly skipped some songs. They list the lastfm playcount as "?" so I checked last.fm itself and there's definitely plays listed on the site. I did the scan twice originally and again a little bit ago and it skipped them again.Should I keep doing re-scanning or is there something else I can do to resolve this?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-04-19 06:50:25
i do cover that in quite a large section at the beginning of the readme.

Quote
Limitations:

Unfortunately, I have no way to manipulate your foobar2000 library. Instead I have to fetch your whole Last.fm library and import that into foo_customdb. So the database may well contain tracks that don’t exist in your foobar2000 library. Also, the spelling and punctuation of your artist and title tags have to be an exact match to what is fetched from Last.fm (case isn’t important). This may be an issue for some because by default, Last.fm uses spelling correction on their website to “fix” any wrong tags you submit when scrobbling. When this happens you may well have blank entries in your playlists when displaying playcount data.

However, when doing background updates, it is possible fetch data for auto-corrected artist names and tie them to the correct track in your library.


If you don’t like Last.fm auto-correcting your submitted data, you can turn this off by visiting this page…

http://www.last.fm/settings/website (http://www.last.fm/settings/website)

If you do this, make sure you turn off the option found on this script’s context menu as well (Auto-updates>Last.fm auto-correct).


also i mention you should use this when displaying playcount data....

Code: [Select]
[%LASTFM_PLAYCOUNT_DB%]


the square brackets stops it showing a ? - the field will be left blank. if you'd prefer it to display a 0 instead, you can do this.

Code: [Select]
$if2(%LASTFM_PLAYCOUNT_DB%,0)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Kougeru on 2013-04-19 07:04:53
Originally I had auto-correct disabled on both the client and on my last.fm profile. I turned them both on to see if it would fix it, but it didn't.The exact same files are listed as "?" when autocorrect is disabled and when it is enabled. I'd say it's around 10% of the files, just randomly. The song data is exactly the same on both my last.fm library and on my playlist so everything seems to be proper based on the readme and such. It's very strange because it's just random songs that have nothing wrong at all.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-04-19 07:20:15
Quote
Originally I had auto-correct disabled on both the client and on my last.fm profile.


sorry if my readme isn't clear but i don't think changing this setting would affect past scrobbles. but if you did this from the very beginning, you shouldn't have any issues.

Quote
The song data is exactly the same on both my last.fm library and on my playlist


i'm not sure about that. i suppose there is a chance it could be my script at fault but i think a discrepancy in the spelling somewhere is the more likely culprit.

i can check this if you send me a foobar playlist file containing your entire collection. add all tracks to a playlist. use file>save playlist and send the .fpl file to <email address removed> (or host it on a website where i can download it. don't use anything with timers/adverts because i won't use it)
also, i'd need your last.fm username as well.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Kougeru on 2013-04-19 07:51:00
Alright, I'm stupid. I figured it out. Apparently either the artist name had a space after it, or the song had a space after it. Last.fm automatically ignores this space when scrobbling so I never noticed the spaces. Luckily it's not a huge number of songs so it should be an easy fix. Thanks for your stop and sorry for wasting it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-04-19 10:44:02
Apparently either the artist name had a space after it


heh, you're not quite as anal as you thought. you can select files in your playlist>right click>properties and right click various fields and select clean up. this will remove any leading/trailing whitespace.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Kougeru on 2013-04-20 00:06:27
Apparently either the artist name had a space after it


heh, you're not quite as anal as you thought. you can select files in your playlist>right click>properties and right click various fields and select clean up. this will remove any leading/trailing whitespace.


XD Very true, it seems. As long as I don't notice it =P.  Also, thank you for this tip! This will save me A LOT of time. Thank you very much for both this plugin and all the help you've given.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ALuserX on 2013-04-24 22:30:26
Dear Marc,
thank you so much for creating this script+manual, that does almost exactly what I wanted and works like a charm.

One thing I want you to ask is if it could be possible to do the same with radio streams.
I listen to an internet radio pretty often and it would be awesome if I could "love" the tracks I like, so that later I could check out the list of loved tracks to get the whole album or something like that. foo_audioscrobbler manages to scrobble tracks from the radio-stream that I added to the playlist with "Add location...", but when I try to like a song that's playing at the moment it sais:

Last.fm Playcount Sync: Contacting Last.fm....
Last.fm Playcount Sync: Artist / track not found.

It's not like it's a must-have-feature or many people would need this, but I hope that if there will be a new version of your script one day, that would be to add a useful feature like this one (if it's even possible).

Thank you once more!
Cheers,
Alex
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-04-25 09:39:06
i think you missed out the important part of the console output. it's the foo_softplaylists component that actually "loves" tracks and i don't think that works with dynamic titles in streams.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: VlaKor on 2013-04-27 19:39:36
Hi? help please
"Automatically love tracks" $ifequal(%rating%,5,1,0) don't work!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-04-27 19:46:30
maybe you have foo_playcount installed but you want to use ratings that exist in your file tags? if that is the case, you should use

Code: [Select]
$ifequal($meta(rating),5,1,0)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: VlaKor on 2013-04-27 20:07:24
foo_playcount  - installed
I use rating not in the tags
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: VlaKor on 2013-04-27 20:23:14
Understood.
First, you put a rating of 5 and then play the track.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-04-27 20:23:29
well the original should work then. i have foo_playcount installed and this is how i can tell it works from looking in the console.

(https://dl.dropboxusercontent.com/u/22801321/2013/april/auto%20love.png)

a track has to be playing for 3 seconds for it to trigger.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: VlaKor on 2013-04-27 20:42:13
Thank you
It Did not work because I play  track, and then put the rating.
We must first set the rating, and then play track )))
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-04-27 20:54:14
i'll have to think about triggering it when a rating is updated during playback. i think someone asked for this before but i forgot about it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-04-28 00:28:13
script updated. https://dl.dropboxusercontent.com/u/2280132...ount%20sync.zip (https://dl.dropboxusercontent.com/u/22801321/playcount%20sync.zip)

if enabled, the auto-love feature now triggers if title formatting changes to meet the required condition during playback. previously it would only check on playback start.

files changed:
Code: [Select]
marc2003\common7.js
playcount sync readme\playcount sync.txt
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: VlaKor on 2013-04-28 09:54:40
Great!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: VlaKor on 2013-04-28 09:57:04
And it is possible in the opposite direction?
Love tracks > 5 rayting?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-04-28 10:59:53
i won't be adding it to my script but here's a workaround to go in your panel. on line 63, replace this....

Code: [Select]
b.lbtn_up(x, y);


with

Code: [Select]
if (b.buttons.ps.trace(x, y) && ps.old_userloved == 0) fb.RunContextCommandWithMetadb("Rating/5", p.metadb);
b.lbtn_up(x, y);


Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: VlaKor on 2013-04-28 17:01:27
Great!
All Love tracks > 5 rayting? It is possible to synchronize?

For earlier thanks.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-04-28 17:18:54
you can find all loved tracks by using main menu>library>search.

Code: [Select]
%LASTFM_LOVED_DB% IS 1


then right click the results>playback statistics>rating>5
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: VlaKor on 2013-04-28 17:33:36
Genius!!!
Autoplaylist created )))
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-04-30 04:51:35
updated: right click>Update script will work for anyone who has updated since the 2nd april. otherwise full download is here: https://dl.dropboxusercontent.com/u/2280132...ount%20sync.zip (https://dl.dropboxusercontent.com/u/22801321/playcount%20sync.zip)
i've created a changelog    https://dl.dropboxusercontent.com/u/2280132...e/changelog.txt (https://dl.dropboxusercontent.com/u/22801321/wsh/playcount%20sync%20readme/changelog.txt)

Code: [Select]
7.2013.04.30.01

Script no longer requires foo_softplaylists to love tracks.
Right click the panel to set your password. Although you
enter it in plain text, it's not saved anywhere. It's just
used temporarily to authenticate once with Last.fm.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-05-01 02:51:50
another update: https://dl.dropboxusercontent.com/u/2280132...e/changelog.txt (https://dl.dropboxusercontent.com/u/22801321/wsh/playcount%20sync%20readme/changelog.txt)

Code: [Select]
7.2013.05.01.01

Now supports artist field remapping for loving/unloving
tracks and auto-updates. This might be handy if you want to
submit just the first value of a multi-value tag eg:
$meta(artist,0). For best results it should match what you set
in the foo_audioscrobbler preferences.


for existing users, right click>Update script should work but there will be an additional step to take after the restart. just follow the dialog box.

full download:  https://dl.dropboxusercontent.com/u/2280132...ount%20sync.zip (https://dl.dropboxusercontent.com/u/22801321/playcount%20sync.zip)

files changed:
Code: [Select]
marc2003\common7.js
playcount sync readme\playcount sync.txt
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-05-01 16:26:59
could a kind moderator please replace the entire contents of the first post with this....


this isn't a proper component but a script which utilises 2 other components (WSH panel mod & foo_customdb) to do the following:

-it can import the playcount/loved tracks from your entire last.fm library into foobar. it uses foo_customdb so your files are not touched.
-after doing the library import it will automatically update in the background as you listen.
-it can love/unlove tracks on last.fm via a button.
-it can automatically love tracks when they are played based on title formatting (for example, it can be set to automatically love tracks with a RATING of 5)
-you can display/filter the data in any custom columns, library viewers, display panels, etc using these simple tags:

Code: [Select]
%LASTFM_PLAYCOUNT_DB%
%LASTFM_LOVED_DB% //has a value of 1 for loved tracks


full instructions can be found here: https://dl.dropboxusercontent.com/u/2280132...ount%20sync.zip (https://dl.dropboxusercontent.com/u/22801321/wsh/playcount%20sync.zip)
changelog: https://dl.dropboxusercontent.com/u/2280132...e/changelog.txt (https://dl.dropboxusercontent.com/u/22801321/wsh/playcount%20sync%20readme/changelog.txt)

updated 30/04/13: no longer requires foo_softplaylists meaning artist field remapping is supported for loving tracks and background updates.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-05-07 11:40:25
if anybody has been following the other WSH script thread or looks at deviantart, you may have noticed falstaff/br3tt has created a new fully featured playlist in WSH panel mod. it has customisable columns which means you can change it to display your last.fm info but the best part is that it allows you to click a "heart" icon to set the "mood" for any track. by default this tags your files but with his permission i've created a modification that allows it to love/unlove any playlist item on last.fm regardless of what is now playing.

here is what you need to do:

-you must be running the very latest version of my script in this thread. existing users should check inside the panel and look at line 10. it should read:

Code: [Select]
p.version = "7.2013-05-01.01";


if it doesn't, you need to re-download the full zip (https://dl.dropboxusercontent.com/u/22801321/wsh/playcount%20sync.zip), extract the marc2003 folder and import the new playcount sync.txt file. then right click the panel to set your password as it no longer uses foo_softplaylists to love tracks. it does it natively now.

-if your panel version is already current, you should right click>Update script to make sure the background file is up to date as well.

-you need version 0.0.7 of falstaff's script and make sure you install the guifx v2 transports font on his page as well.

http://browse.deviantart.com/art/WSH-Playl...0-0-7-368997689 (http://browse.deviantart.com/art/WSH-Playlist-2013-v0-0-7-368997689)

-now you need to download my modified file from here. https://dl.dropboxusercontent.com/u/2280132.../WSHplaylist.js (https://dl.dropboxusercontent.com/u/22801321/wsh/temp/WSHplaylist.js)

-it needs to be saved in your profile folder\wsh_br3tt\js folder, over writing the file that is already there. make sure foobar is closed while you do this.

-with your playlist now installed, you can customise the "mood" column to display your last.fm loved status instead. right click the column>edit this column>pattern

Code: [Select]
$ifequal(%LASTFM_LOVED_DB%,1,1,0)


-there is no plays column by default, so right click any column header>columns>plays to add it.

-now right click the Plays header>edit this column>pattern and enter

Code: [Select]
[%LASTFM_PLAYCOUNT_DB%]


you should now have something that looks like this:

(https://dl.dropboxusercontent.com/u/22801321/2013/may/wsh%20playlist.png)

now you can click the "heart" of any playlist item and it will love/unlove the track depending on the current value and it should update the playlist almost immediately. check the foobar console for success/failure messages.

you may want to hide my "button" out of the way somewhere but it must be active in your layout. it "listens" for notifications from the playlist to do the communication with last.fm.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ubercow on 2013-05-19 14:37:28
Hi, thanks for the script I absolutely love it.

I'm having trouble with tracks with an ampersand in the artist or title field. When I try to love them with your button, the console shows:

Last.fm Playcount Sync: Invalid method signature supplied


and the track is not loved, in the library or on last.fm. Is this a bug or have I done something wrong?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-05-19 15:54:14
oh fudge. i could have sworn i had this working during testing. i know i had to make changes late on with the md5 hasher i used so i obviously didn't go back and test again. it should be fixed now.

existing users: right click>Update script.
full download: https://dl.dropboxusercontent.com/u/2280132...ount%20sync.zip (https://dl.dropboxusercontent.com/u/22801321/wsh/playcount%20sync.zip)
changelog: https://dl.dropboxusercontent.com/u/2280132...e/changelog.txt (https://dl.dropboxusercontent.com/u/22801321/wsh/playcount%20sync%20readme/changelog.txt)

thanks for spotting my mistake. 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ubercow on 2013-05-19 16:01:36
Well that was quick, thanks very much marc, it works perfectly now!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: salamich on 2013-05-21 17:22:11
Thanks for this great script! Is it supposed to fetch scrobbles from other devices automatically in the background or do I have to do a full reimport each time? Didn't seem to catch them the first time i tried.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-05-21 17:35:15
if you the import right now then all the data is current.
then if you subsequently scrobble from other devices then of course the playcounts will be out of sync.
the background updates only work when you play the track again and listen to enough of it to count for another scrobble. it then fetches the new value including the scrobble(s) from other devices. but of course this only happens on a track by track basis and you might not even play tracks in foobar that you've recently scrobbled from another device.

either deal with it or run the full import on a semi-regular basis.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: salamich on 2013-05-21 18:03:33
OK thanks for the feedback

Would it be possible to cache the last imported scrobble and allow incremental updates from there? I'm using lastfm2itunes (https://code.google.com/p/perl-lastfm-2-itunes/source/browse/trunk/lastfm2itunes.pl) to get the scrobbles into iTunes and these incremental updates work pretty well.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-05-21 21:30:51
i remember rejecting the request last time it was asked.

if i can figure out how to increment values in sqlite, it might be doable.... well actually i already know to increment values if they exist but i don't know how to combine this with writing a new record with a playcount of 1 if it doesn't.

edit: thinking about it some more, i'm not sure if i can really implement this properly. when i do i generate the timestamp to go back to? if it's from the last scrobble performed inside foobar, it could miss earlier scrobbles from other devices. or if it's from the last full import time, there would could be scrobbles since that will be artificially inflated by counting them again. at least with feeds i use, i'm getting actual values from last.fm rather than incrementing current db values by one for each play which is what that itunes thing does. i'm having serious doubts over how useful it can be.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: salamich on 2013-05-22 17:10:44
Ah I see, I thought you were already using the same full scrobble feeds (which would take a LOT longer during the initial import). The only safe way I can think of would be a second value for each track with the amount of times the play count was  increased by the dynamic update, then deduct this from the new total and set it to 0 again after each incremental update. Sounds like a lot of work though so no worries, I'll just do a full re-import occasionally. Or bug you again if a better idea ever pops into my head

Anyway, thanks again!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: D.Sync on 2013-05-24 11:03:08
Hi marc, once again thanks for your continuous effort for this wonderful script.

As I had been away from foobar2k scene for some time now and was just updating all my plugins. I realized that the loved track and scrobbling feature no longer works. When clicking the loved icon, the following was displayed from the console:

Last.fm Playcount Sync: Attempting to love "JUICY" by "Koda Kumi"
Last.fm Playcount Sync: Contacting Last.fm....
Last.fm Playcount Sync: Track loved successfully.

But the fact is nothing seemed to be updated in last.fm.

I'm currently using WSH v.1.5.6
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-05-24 11:20:07
the scrobbling has nothing to do with me. you need foo_audioscrobbler for that.

the track loved successfully message is only shown when you get a very specific response from the last.fm servers saying that everything went ok.

how are you checking it? if the track has been recently scrobbled, you should see a heart icon next to it under recently listened tracks on your profile page. it should also appear under recent activity - also on your profile page. and when signed into last.fm, it should also show on the track page.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: D.Sync on 2013-05-24 14:20:10
the scrobbling has nothing to do with me. you need foo_audioscrobbler for that.

the track loved successfully message is only shown when you get a very specific response from the last.fm servers saying that everything went ok.

how are you checking it? if the track has been recently scrobbled, you should see a heart icon next to it under recently listened tracks on your profile page. it should also appear under recent activity - also on your profile page. and when signed into last.fm, it should also show on the track page.


I see. Finally I found the problem. It turned out that I removed the _DB in the foo_customdb very long time ago. So instead of %LASTFM_LOVED_DB% I was using %LASTFM_LOVED%. Changing the name in the common7.js and matching the Action name with 'Customdb ...' make everything works now. Sorry for such silly question.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-05-24 15:00:14
of course doing all that only affects what happens to the display in foobar and not on the website which is what you originally stated. 

unless you really meant inside foobar when you said this?

Quote
But the fact is nothing seemed to be updated in last.fm.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zageron on 2013-05-31 07:43:34
Hey, how do albums like this work using sync?
(http://www.zageron.com/img/20130531064305301.png)

They are all loaded with full musicbrainz information, and the songs are all actually called [untitled].
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-05-31 08:31:17
are they scrobbled? if you see them on your profile, the script should fetch them but they will all be counted as one because the script only uses the artist and title.

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zageron on 2013-05-31 19:08:21
are they scrobbled? if you see them on your profile, the script should fetch them but they will all be counted as one because the script only uses the artist and title.


Any chance of adding the option of using more information, [mbid, trackid, length?] for building the playcount database?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-05-31 19:30:12
although you can submit the album and MB trackid when using foo_audioscrobbler, there really is nothing to differentiate this information when fetching it back from them. like i said, it's limited to artist/title.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zageron on 2013-05-31 19:54:25
although you can submit the album and MB trackid when using foo_audioscrobbler, there really is nothing to differentiate this information when fetching info back from them. like i said, it's limited to artist/title.


Okay, just thought I'd ask. Thanks.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Calebzor on 2013-05-31 22:18:23
Do I get this right, this plugin does not work with defaul UI, right?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-06-01 05:41:12
if you click back on your browser, you'll see it says something under the main thread title.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Calebzor on 2013-06-01 10:41:24
Is there a way to love a song with a keyboard shortcut and have it automatically show up in foobar when you loved something?

So far I can either love a song in foobar and foo_softplaylists will send that to last.fm, but I have no way of displaying the love icon for this process in foobar

OR

I can set the custom DB LASTFM_LOVED_DB to 1, then I can display the little heart icon, but doing so won't send the info that I loved a track to last.fm.

Edit: I know that when playcount is updated so is the LASTFM_LVOED_DB, but that does not feel reliable at all.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-06-01 10:57:33
Quote
Edit: I know that when playcount is updated so is the LASTFM_LVOED_DB, but that does not feel reliable at all.


make sure you love the track before half of it is played. 

someone else ran into the same problem a page or two back and their solution was to create 2 keyboard shortcuts. i don't have anything better to suggest.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zageron on 2013-06-09 22:41:06
I cannot find a consistent reason as to why, but the local playcount fails to update on my system 100% of the time.

Some tracks work, patterns arise and fall, and then tracks that were working stop working.

All I can say is that:
"Last.fm Playcount Sync: Contacting Last.fm...." only get's the "Last.fm Playcount Sync: Playcount updated successfully." once in a while, in no particular pattern.

I have no internet intense applications running, I'm not downloading anything.

I though that it had something to do with the length of path/file, but after 10 minutes of testing it failed to be consistent.


Is there anything I can do to supply information that might help?
I had written up a large post of filepath comparisons, but it turned out to have nothing to do with it.

I looked into the update_track function and saw that it only makes 3 attempts. Since last.fm takes a fair amount of time to initially load on my machine, could this be the problem?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-06-10 00:03:12
Since last.fm takes a fair amount of time to initially load on my machine, could this be the problem?


not really sure what you mean by this? are you using the official last.fm scrobbler? if you are, you should pay attention to what i've put in the the readme.

Quote
1)   For scrobbling, I recommend Florian’s foo_audioscrobbler component found here:

http://www.mp3tag.de/en/fb2k.html (http://www.mp3tag.de/en/fb2k.html)

If you prefer the official Last.fm software, you need to access the Tools>Options>Scrobbling page and change it to at least 60%. The default of 50% conflicts with the way my script works. It’s far easier for people to change this setting than it is for me to implement support for both versions.


edit: are you using the stock foo_customdb .cfg file that i supply in the zip or do you have your own custom fields/actions as well?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zageron on 2013-06-10 00:46:27
I'm using foo_audioscrobbler 1.4.7.
I use your defaults for everything.

What I mean, when I say that last.fm takes a fair amount of time to load, is that when I load my home screen "http://www.last.fm/user/Zageron" it takes from 2-4 seconds before the page starts to load.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-06-10 08:23:09
i've updated the script to give a better of idea where it's failing. it now tells if the server response is ok but the update fails. it you still see no message then it means last.fm is not responding in a timely manner.

right click>Update script to get the latest version.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zageron on 2013-06-11 06:25:46
Last.fm Playcount Sync: Contacting Last.fm....
Last.fm Playcount Sync: Last.fm responded ok. Attempting to update playcount...
Last.fm Playcount Sync: Database error. Playcount not updated.

Haha.

What files should I delete in order to fix this.
I have done a redownload of my statistics numerous times, and this doesn't seem to fix it. So perhaps just completely delete your plugin from foobar and do a fresh drag-and-drop??

Thanks so much!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-06-11 08:52:37
i must admit i don't know why that is happening. you haven't modified any files inside the marc2003 folder?

as i have no way to update the playcount cleanly from within foobar itself, i bundle an executable file called sqlite.exe (it's the official command line tool for working with sqlite databases which is what foo_customdb is based on). you mentioned earlier that it makes 3 attempts to run the command which updates the playcount. the reason it does this is because very occasionally the database goes get locked and it takes a 2nd attempt for it to work. during my own testing, i never saw it take more than 2 attempts which is why i set the limit to 3 just to be on the safe side. no one else has reported any problems so something else on your system might be interfering and blocking write access to the file but what that could be, i have no idea??? 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zageron on 2013-06-11 10:54:26
Well, I installed a fresh installation of foobar and reintegrated all of my components in a nice clean fashion.
The installation is fast and clean, and the customdb/wsh/sync components are all fresh downloads from their sources.
I imported the playcounts from the web, and I've successfully updated 5 songs in a row so far.

If I run into the problem again, I have a feeling it might possibly have something to do with my foobar installation being within my dropbox folder.
I'll let you know if I run into the problem again.

Thanks very much for the debug.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ubercow on 2013-06-24 08:43:21
Hi marc

Could you elaborate on something please...if I love a track from the last.fm interface and then want the track's loved status to be updated in my library to reflect this, when exactly does this happen? If I play the song, will the loved status be fetched from the website and overwrite whatever status the track has in my database? At what point does this happen on playing the song, at the beginning or in the middle when the track would be scrobbled?

I have a feature request too, would it be possible to have separate menu options for just fetching the loved tracks again from the site, and the playcounts, and both? Playcount fetching takes quite a while and it would be nice to update just my loved tracks when I think they are out of sync, as the exact value of playcounts somehow seems less important to keep strictly up to date.

Thanks!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-06-24 10:37:02
Quote
If I play the song, will the loved status be fetched from the website and overwrite whatever status the track has in my database?


yes. but it would only get the new loved status when enough of it has been played to count for a scrobble.

if you know you've loved tracks via the website, you can update the local database by right clicking track(s) in the playlist and selecting Legacy Commands (unsorted)>Customdb Love 1.

i can split the import to let you get just the loved tracks. i'll post an update later.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ubercow on 2013-06-24 12:23:30
yes. but it would only get the new loved status when enough of it has been played to count for a scrobble.

i can split the import to let you get just the loved tracks. i'll post an update later.


Okay I thought so. Is this because the process is tied to the scrobbling process in any way or is it just so that the playcount is updated to include the current scrobble after it happens?

That's super thank you very much! 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-06-24 12:25:17
right, there are now 2 options under Library import. there is now loved tracks and playcount which works the same as before. and there is now loved tracks only. i didn't think there was much point making a playcount only option.

right click>Update script.

edit: to answer your post which wasn't there when i started typing....it's just the way my script works. it could fetch the loved status at the beginning of a track. i just choose to update when enough of the track has been played for a scrobble. this is because i generally don't use anything external to foobar for scrobbling/loving tracks.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ubercow on 2013-06-24 12:41:39
Works wonderfully, thank you.

I was just unsure what it was necessary to do after loving a track elsewhere but that makes perfect sense, seems like the best way to do it. It's nice and quick to update everything anyway now if I am unsure everything is synced
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Shizukasm on 2013-06-27 02:59:28
First of all thanks a lot for your wonderful script and for your continued support, seriously! I have playback statistics configured here to always save statistics to file after changing them (so, for instance, if I rate the song it will add this in metadata form to the mp3, it also updates PLAYCOUNT with each play). What I would like to do is write %LASTFM_PLAYCOUNT_DB% to the metadata instead, is it possible?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-06-27 12:59:36
it used to be fairly easy to make that change with older versions of my script but i don't keep those any more. with all my recent changes, it's a lot more messy now and it's not so easy to modify. 

edit: i have found an older backup which should be easier to modify. i'll post that up later on.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Shizukasm on 2013-06-29 20:31:55
it used to be fairly easy to make that change with older versions of my script but i don't keep those any more. with all my recent changes, it's a lot more messy now and it's not so easy to modify. 

edit: i have found an older backup which should be easier to modify. i'll post that up later on.

Ahh great news! Thanks a lot.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-06-29 20:35:13
do you need it to love tracks as well or are you only interested in playcount?

i would have done it before now but i've been "busy" watching wimbledon all week.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Shizukasm on 2013-06-29 21:10:38
do you need it to love tracks as well or are you only interested in playcount?

i would have done it before now but i've been "busy" watching wimbledon all week.


I'm only interested in playcount.

Haha, don't worry too much, I'm grateful enough that you did the script already! Do it whenever you have time =)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-06-29 21:16:37
that makes it much easier for me and there is no play tomorrow so i'll do it then.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-06-30 11:39:21
here you go: https://dl.dropboxusercontent.com/u/2280132...count%20tag.txt (https://dl.dropboxusercontent.com/u/22801321/wsh/temp/playcount%20tag.txt)

just stick that in a panel. there is nothing to click so it's just a grey background to match the default splitter colour. there are a few options on the right click menu. once you've done that, you can resize it to hide it.

to give yourself, a head start, you can transfer all values already in foo_customdb in to your file tags. simply select a bunch of files>right click>properties. now right click the playcount tag you want to store values in and then format from other fields. in the pattern dialog, enter

Code: [Select]
[%LASTFM_PLAYCOUNT_DB%]
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Shizukasm on 2013-06-30 14:06:00
here you go: https://dl.dropboxusercontent.com/u/2280132...count%20tag.txt (https://dl.dropboxusercontent.com/u/22801321/wsh/temp/playcount%20tag.txt)

just stick that in a panel. there is nothing to click so it's just a grey background to match the default splitter colour. there are a few options on the right click menu. once you've done that, you can resize it to hide it.

to give yourself, a head start, you can transfer all values already in foo_customdb in to your file tags. simply select a bunch of files>right click>properties. now right click the playcount tag you want to store values in and then format from other fields. in the pattern dialog, enter

Code: [Select]
[%LASTFM_PLAYCOUNT_DB%]


Hugeee thanks Marc, works perfectly
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: flvinny521 on 2013-07-01 23:10:00
Instead of importing my loved tracks from last.fm, can I do a batch export?  Let's say I want to love all the tracks from three albums, but I don't have the time to listen to them all so they're scrobbled.  Instead, I play a few seconds of each track, and love them all using your script.  How can I update last.fm with these new tracks?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-07-01 23:56:18
not really sure what you mean? if you love a track, it will appear in your last.fm library. you don't have to scrobble it for it to show. it just won't have any plays attached it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: flvinny521 on 2013-07-02 04:30:59
not really sure what you mean? if you love a track, it will appear in your last.fm library. you don't have to scrobble it for it to show. it just won't have any plays attached it.


I tested this with a track that I had verified was not loved on last.fm.  I played it very briefly and loved it using your script.  Then I played it again, in full, so that it would be scrobbled, and as soon as it was, the loved status disappeared. 

I'd like to be able to love a large number of tracks locally and then have that information synced to last.fm, but it seems that the last.fm status overrides any change I make locally.  Does that make sense, or am I not explaining myself correctly?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-07-02 07:35:21
I played it very briefly and loved it using your script.


this should update last.fm immediately and the local database only updates when you get a successful response from last.fm. you should see success/failure messages in the console. also, right click a track in the playlist>properties>properties tab. you should see a Custom database section under the tech info.

if you wanted to love numerous tracks quickly then the best bet would be to actually stop playback. select a track, love it, wait for response. select another track, love it, wait and so on. (and when i say wait - it may take a second or 2 at most)

Quote
Then I played it again, in full, so that it would be scrobbled, and as soon as it was, the loved status disappeared.


i don't see how this could happen. the loved status would not update locally if there was no success response from last.fm. then when you play the track, the only way the loved status could disappear is if the response during the auto-update was that the track is not loved????

are you using the latest version of my script downloaded from this thread? it's not some modified version you found elsewhere? you can also check to see tracks that are loved on the recent activity section of your last.fm profile. you'll find this on the top right of your profile page.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: flvinny521 on 2013-07-02 15:29:25
Yes, I am using the script from this thread, and yesterday I updated it from within foobar.  I tried doing another import of both loved tracks and playcounts, hoping to start fresh, but there are still some tracks that show they are loved in foobar which are not present on last.fm.  How can I clear the local database so when I perform a sync, there should be no discrepancies?

Edit - Also, I think the issue began when I started using a global hotkey to love and unlove tracks.  I see in the console that using the hotkey, while it does apparently set the "customdblove" value to 1, there is actually no communication to last.fm  However, if I click on the heart icon, the request is sent to last.fm correctly.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-07-02 15:46:00
well you've discovered the problem by yourself. those context menu items are only there for my script to update the local database. they are only supposed to be triggered by my script when loving/unloving tracks via the button or during playback when enough of the track has played to count for a scrobble.

triggering them via hotkeys only updates the local database and bypasses my script completely.

the database file is named customdb_sqlite.db in your foobar2000 profile folder if you want to delete it and start again.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: flvinny521 on 2013-07-02 19:16:19
well you've discovered the problem by yourself. those context menu items are only there for my script to update the local database. they are only supposed to be triggered by my script when loving/unloving tracks via the button or during playback when enough of the track has played to count for a scrobble.

triggering them via hotkeys only updates the local database and bypasses my script completely.

the database file is named customdb_sqlite.db in your foobar2000 profile folder if you want to delete it and start again.


Thanks for your help; seems like everything is working as it should.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Kanapka on 2013-08-02 12:51:49
It's probably stupid question, but... Where I can find Library import? :|
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-08-02 14:07:30
you need to right click the actual heart icon to get the full menu.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Kanapka on 2013-08-03 09:42:11
Thanks. Now I've got another problem. Why this script doesn't synchronizes all of my ~20000 plays, but reaches ~4200, and then stops? Example of problem:
(http://img90.imageshack.us/img90/847/y15.png)

Console after finished syncing:
(http://img132.imageshack.us/img132/8248/pke.png)

Thanks in advance, and sorry for my English. I know it's terrible.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: aztec_mystic on 2013-08-03 09:44:31
Thanks. Now I've got another problem. Why this script doesn't synchronizes all of my ~20000 plays, but reaches ~4200, and then stops? Example of problem

Looks as if it synced everything. Some tracks were played multiple times.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Kanapka on 2013-08-03 10:40:56
Thanks. Now I've got another problem. Why this script doesn't synchronizes all of my ~20000 plays, but reaches ~4200, and then stops? Example of problem

Looks as if it synced everything. Some tracks were played multiple times.



Some of albums, that I don't listened to in a long time, are synchronizing only when I scrobble them. Example:
(http://img90.imageshack.us/img90/847/y15.png)
(before listening to whole album)

(http://img822.imageshack.us/img822/6694/g92.png)
(after)

EDIT:
It's probably because of last.fm who corrects artist tag from "Snoop Doggy Dogg" to "Snoop Dogg". I'm sorry, my fault
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-08-03 14:51:46
Quote
It's probably because of last.fm who corrects artist tag from "Snoop Doggy Dogg" to "Snoop Dogg". I'm sorry, my fault


indeed. this is covered in the readme. although it might look like a wall of text that makes your eyes glaze over, it does cover some important points.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: kennethkee93 on 2013-08-03 17:20:38
Hi, I'm having trouble to get the script running on my foobar UI,

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: kennethkee93 on 2013-08-04 07:58:17
Ok, solved my problem, I copied the file wrongly. Works fine now. 

P/s - I can't edit my post above..
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: DeVinel on 2013-08-14 01:59:35
Hey Guys,
It seems like i copy it wrongly too. I got the same error and im getting frustrated. I just copy pasted playcountsync into the wsh mod by clicking configure. Can somebody give me a hint ?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-08-14 05:56:44
check the instructions in the bundled readme.pdf file. it's important that you follow all the steps.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: aztec_mystic on 2013-08-15 16:04:32
Just wanted to install this script on a new box. There's a problem, though. It seems the site which hosted foo_customdb was taken down for good.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-08-15 16:25:49
here you go: https://dl.dropboxusercontent.com/u/2280132...oo_customdb.zip (https://dl.dropboxusercontent.com/u/22801321/wsh/foo_customdb.zip)

i've also updated the link in the readme.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: aztec_mystic on 2013-08-15 18:22:13
Thanks, marc!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: nickdc on 2013-08-15 21:26:26
hi marc, im using your lastfm love button, what i would like to do now is paint in red the title of all the lastfm loved songs, which script should i use?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-08-16 03:31:23
you need to be using a playlist viewer that supports $rgb. either EsPlaylist or NGplaylist in columns UI. you can customise a column something like....

Code: [Select]
$ifequal(%LASTFM_LOVED_DB%,1,$rgb(255,0,0),)%title%
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: nickdc on 2013-08-16 12:32:41
works, thanks
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: DVS on 2013-11-11 02:53:54
I have often crashes foobar.
Quote
Problem caused by: foo_customdb.dll: Custom Database
Known buggy component.

Does anyone know, whether the update of this plugin?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-11-11 03:16:36
there is no update.

however, i've never seen or heard of it crash using the configuration file i provide. i mention in the readme that if you don't use foo_customdb for anything else then you should use the configuration folder that i bundle in the zip.

but if you manually configured the entries into an existing foo_customdb setup, it's very likely that the original settings are at fault - at least that's what i found with my testing. i found it crashed quite often which is why i supply my "stripped down" setup.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: DVS on 2013-11-15 22:23:56
marc2003, i'm use exactly your configuration file from the zip archive.
crc32: f090008d
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-11-16 00:33:02
well the obvious thing to try is removing the component. if it stops crashing after that then it looks like it is to blame. you used the word "often" so you shouldn't have to wait long to find out.

if it really is the cause then i'm sorry but i can't do anything about it.




Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: RuKuKi on 2013-11-20 14:30:31
Thank you for your wonderful work.

foo_customdb keeps crashing with foobar 1.3b5 (with your config+customdb_sqlite.db is 1.2mb+there is column with %LASTFM_PLAYCOUNT_DB%)
The log messages are something like 'Custom Database: library routine called out of sequence (21)'

If I start the same config+the same .db with smaller library everything works fine. And anyway 1.2.9 works flawless.

Also is there any way to trigger last.fm sync on foo_uPnP track changes with foobar acting as server?

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-11-20 16:35:52
perhaps the db file got corrupted? you could close foobar and deleting the db file and re-importing. try Library Import>from file first as the previously downloaded data should still exist. it might be out of date depending on how many tracks you've played since. failing that, doing an import from the website again would be the next step. of course if was the same file that worked on 1.2.9 then it probably isn't this. i just don't know what else to suggest.

if you like, i can test your last.fm userid if you let me know what it is. either here or via PM would be fine.

as for your upnp question, i have no idea how that works. my script relies on it being notified of a new track starting by the foobar2000 core. i think it's impossible to detect what any 3rd party component might be doing.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: RuKuKi on 2013-11-21 10:02:44
Thanks for the answer. I've done a deeper research: re-imported whole library from last.fm (~650 pages)), removed all playlists and got 1.3 working fine.

So I've found autoplaylist causing crashes:
(%PLAY_COUNT% GREATER 0 AND %length% LESS 00:09:00 AND %length% GREATER 00:01:30) ~ 19030 works fine
comparing to
(%LASTFM_PLAYCOUNT_DB% GREATER 0 AND %PLAY_COUNT% GREATER 0 AND %length% LESS 00:09:00 AND %length% GREATER 00:01:30)
causing crashes and a lot of 'Custom Database: library routine called out of sequence (21)' messages

Well, I believe its a matter of new 1.3  playlists engine and there is nothing we can do =(

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-11-21 10:23:15
i'm kind of surprised it's working with that many tracks. i know i've had people complain in the past when they've had 10's of thousands of tracks saying foo_customdb slows down foobar too much. but it seems you have 65,000 odd?? 

i have less than 2000 tracks which is why i never have any issues myself. 

i have no idea why changes in 1.3 would affect this as i thought it was only for longer fields only. the max length you'll see in my database is 3 digits for playcounts in the hundreds. or 4 if you've listened to a track over a thousand times but that's not likely.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: vanhoivanbinh on 2013-11-25 05:02:42
Dear Sir
I am really appreciated your work
Now I want to enlarge the Love button in WSH panel. I try to replace the icon with larger image with the same name but it keeps same small size
I think I need to change something in the script
PLEASE ADVISE ME FOR THIS THING
THANK YOU VERY MUCH
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-11-25 07:51:38
right click panel>configure. line 19 is this:

Code: [Select]
b.buttons.ps = new button(0, 0, ps.size, ps.size, {normal: ps.n, hover: ps.h}, ps.func, ps.tooltip);


replace ps.size with your image dimensions (width then height)

line 22 is

Code: [Select]
window.RepaintRect(b.buttons.ps.x, b.buttons.ps.y, 32, 32);


you need to replace both instances of 32 only if your image is bigger. (again it's width first, then height)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: vanhoivanbinh on 2013-11-26 03:26:27
right click panel>configure. line 19 is this:

Code: [Select]
b.buttons.ps = new button(0, 0, ps.size, ps.size, {normal: ps.n, hover: ps.h}, ps.func, ps.tooltip);


replace ps.size with your image dimensions (width then height)

line 22 is

Code: [Select]
window.RepaintRect(b.buttons.ps.x, b.buttons.ps.y, 32, 32);


you need to replace both instances of 32 only if your image is bigger. (again it's width first, then height)

AWESOME!!!! SIR!!!
THANK YOU SO MUCH
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: スラッシュ on 2013-12-07 12:41:15
I recently updated my computer and the added date problem reared its ugly head again for DADA scores and so on (I might edit it to disregard added date since it's causing so much trouble). Anyway, when searching about any updated info for last.fm "first played" date in the API, I came across this:

http://www.last.fm/group/Last.fm+Web+Servi...21604/_/2218628 (http://www.last.fm/group/Last.fm+Web+Services/forum/21604/_/2218628)

Is that usable in any way, you think?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-12-07 15:06:35
that's only the first played date per artist. i don't see how that is useful.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: スラッシュ on 2013-12-08 08:56:23
Oh yeah I see, I didn't read it properly. That sucks  So frustrating when websites keep information to themselves like that.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-12-08 09:43:26
you can request your entire scrobbling history on this page....

http://www.last.fm/settings/dataexporter (http://www.last.fm/settings/dataexporter)

as it's in JSON format, i might be able to do something with it. i've put in my own request and i'm waiting -it says it can take up to 7 days.

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-12-08 18:59:33
i've got my data from last.fm. even though i reset my account in 2011, it has all my scrobbles from 2006 till now. the files are 69MB in size containing 143,000 scrobbles. when i read all the data into a WSH panel, it hangs foobar for a good 8 seconds and uses over 900MB of ram.   

now to have a go at parsing them all to make something useful....
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: スラッシュ on 2013-12-08 20:03:02
Whoa... I requested mine also!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-12-08 21:03:28
i've made a quick and dirty script that adds first played to foo_customdb (%FIRST_PLAYED_DB%)

you need this updated foo_customdb.dll.cfg file saved in your configuration folder. https://dl.dropboxusercontent.com/u/2280132...ustomdb.dll.cfg (https://dl.dropboxusercontent.com/u/22801321/wsh/temp/export/foo_customdb.dll.cfg) (make sure foobar is closed before you add it)
then you paste this script into a new WSH panel. https://dl.dropboxusercontent.com/u/2280132...port/export.txt (https://dl.dropboxusercontent.com/u/22801321/wsh/temp/export/export.txt)

when you get your download from last.fm, you should extract the json folder somewhere.

the panel itself has no UI. but if you double click the panel, a folder browser should popup and you can browse for the scrobbles folder (this will be inside the json folder you extracted above)
foobar will be go unresponsive for a few seconds.

when it's complete, the console will open to report a few stats and you should see a blue popup window instructing you to close foobar manually BEFORE pressing a key.

end result:

(https://dl.dropboxusercontent.com/u/22801321/wsh/temp/export/img.png)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: スラッシュ on 2013-12-09 08:56:42
Amazing! As soon as the export shows up (seems to be taking a little longer than with you) I'll be sure to give this a spin and pass on any feedback. Very exciting!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-12-09 09:19:09
i just realised that one of the tracks in my screenshot has a first played date way out of sync with the rest. i'd just like to point out it's not a bug in my script - it's different because i edited the tag of that track which was spelled incorrectly. 

edit: that's not to say it's bug free. who knows? i can only test on my own dataset.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: スラッシュ on 2013-12-10 08:04:42
It worked! It's perfect! I used $if2(%FIRST_PLAYED_DB%,%added%) so that I don't have to import the database anymore after this...

(http://i.imgur.com/g8pBS2P.png)

(The "last played" column is weirdly empty because of the loss of my playback statistics but that's neither here nor there.)

Thanks for this so much!

Looking at this, I probably need to adjust DADA to not value new tracks so much, since my library goes back to 2006 now... Haha...
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-12-10 16:12:32
getting last played would be fairly trivial to add. let me know if you're interested. obviously it wouldn't be entirely accurate given your download is a day or 2 old by now.

edit: i've added the feature anyway. it's off by default but i've included 2 variables at the top of the script that allow you to use whichever option you want...

Code: [Select]
var first_played = true;
var last_played = false;


new foo_customdb.dll.cfg required: https://dl.dropboxusercontent.com/u/2280132...ustomdb.dll.cfg (https://dl.dropboxusercontent.com/u/22801321/wsh/temp/export/foo_customdb.dll.cfg)
link to script: https://dl.dropboxusercontent.com/u/2280132...port/export.txt (https://dl.dropboxusercontent.com/u/22801321/wsh/temp/export/export.txt)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: スラッシュ on 2013-12-10 20:27:19
Wow, this is so friggin' awesome! That can populate my last played column nicely. I'll just override the last.fm export value with foobar's own last played value when it exists. Thanks again for this!

Quick picture with some explanation of what the values you see are:

(http://i.imgur.com/onxAKHe.png)

Of course the "first played" and DADA score calculation columns are just there for testing purposes. But yeah, it works!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: スラッシュ on 2013-12-13 14:26:41
Hey dude, sorry for being such a pain, but do you think there's any way to make your script give playcounts to tracks shorter than 30 seconds? I know last.fm doesn't count them (which is really lame), but perhaps you can simply +1 it locally when the track is less than the required length to be scrobbled?

(If it's not possible or just too annoying to do, I can figure out a way to revert to the local playcount for songs shorter than 30 seconds, but yeah...)

EDIT: Nevermind, I made a playcount dynamic field that uses the playcount statistics for songs 30 seconds or shorter. Of course, it can't hurt... But yeah I'm happy again
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Daeron on 2013-12-13 19:46:13
If the tracks have been played all the way the playcount component should tag them by default regardless of their length.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-12-13 20:38:52
If the tracks have been played all the way the playcount component should tag them by default regardless of their length.


of course the playcount component does. 

but read the thread title - the whole point of this thread is a script that updates foo_customdb with playcounts from last.fm. last.fm do not accept submissions for tracks shorter than 30 seconds and you can end up with results like this...

(https://dl.dropboxusercontent.com/u/22801321/2013/december/short.png)

@?????, presumably you're using something like...

Code: [Select]
$if2(%LASTFM_PLAYCOUNT_DB%,[%PLAY_COUNT%])


or

Code: [Select]
$ifgreater(%LENGTH_SECONDS%,30,[%LASTFM_PLAYCOUNT_DB%],[%PLAY_COUNT%])


these would have been my suggestions because i really didn't want to update foo_customdb with values not from last.fm.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Daeron on 2013-12-13 20:58:41
I see, wasn't paying attention, my bad.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: スラッシュ on 2013-12-14 07:20:34
Code: [Select]
$ifgreater(%LENGTH_SECONDS%,30,[%LASTFM_PLAYCOUNT_DB%],[%PLAY_COUNT%])

Yeah this is what I did. At first I made a dynfil field for it but it seemingly had trouble keeping up (since I was using a dynamic field inside another dynamic field, I guess), so I ended up just writing that above line every time I wanted the playcount. I basically complained before thinking it through
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-12-14 08:46:57
if you really want to, you can increment values in foo_customdb yourself.

file>preferences>tools>custom database>action>add

display: Customdb Add 1
field: LASTFM_PLAYCOUNT_DB
update: context menu
set value: $add(1,$if2(%LASTFM_PLAYCOUNT_DB%,0))

restart foobar.

then in the script on line 29, you'll find this...

Code: [Select]
function on_playback_time() {
    ps.playback_time();
}


edit it to become...

Code: [Select]
function on_playback_time() {
    ps.playback_time();
    if (fb.PlaybackLength < 30 && ps.time_elapsed == Math.round(fb.PlaybackLength / 2)) fb.RunContextCommandWithMetadb("Customdb Add 1", p.metadb, 8);
}
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: WaltzForZizi on 2013-12-24 02:29:26
Hi there,

I'm not sure if this is the correct place to ask, but it seems the best place.

Before applying this (marc's lastfm sync script) I wanted to know if it's possible to first automate the overwriting of the metadata for every track's metadata with "playcount" using Playback Statistics plugin (without using cutom db).

I have requested my lastfm history and just downloaded the .zip they emailed me.

In Foobar you can right click on a track then do "Playback Statistics -> Import Statistics from file tags" which uses the tag that looks like: "<PLAY_COUNT>". Similarly there is one for "<RATING>"

Is it possible, using the last.fm data, to automate adding and updating the <PLAY_COUNT> and <RATING> tags to my library? So, for every "Loved" track, have it as <RATING> = 5, and similarly <PLAY_COUNT> = last.fm data playcount.

Can anyone point me in the direction on how best to go about doing this either through foobar itself, or with an external script (Python?). So it could go through the last.fm data, and match exact Artist + Title, do the update. Then for any inconsistent match, just keep them and I can update them manually.

Hope that made sense lol; any help would be greatly appreciated!

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2013-12-24 10:48:15
you can download the zip from the first post and do a full import as if you were going to use foo_customdb.

when that is all setup, you can use Library>Search

Code: [Select]
%LASTFM_LOVED_DB% IS 1


you can select all the results and right click>rating>5

then create a new search

Code: [Select]
%LASTFM_PLAYCOUNT_DB% PRESENT


select all the results, right click properties. if PLAY_COUNT is not already showing, right click a blank area>add new field>PLAY_COUNT

now right click PLAY_COUNT>format from other fields. enter %LASTFM_PLAYCOUNT_DB% as the pattern and the counts should now be in your file tags. lastly you can then import that into playback statistics.

you can then remove foo_customdb/WSH panel mod if you have no need for them.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: WaltzForZizi on 2013-12-26 10:20:26
Thank you Marc!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: vanhoivanbinh on 2014-01-03 03:53:51
well it is already documented what you need to do...

Code: [Select]
//automatically love tracks based on titleformatting below. turned off by default. set to 1 to enable.
var auto_love = 0;
//basic example of title formatting to use. this will automatically "love" all tracks with a rating of 5
//of course you can use anything you like. result must be 1 in conjunction with the above option
//being set for it to trigger
var auto_love_condition = fb.TitleFormat("$ifequal(%rating%,5,1,0)");


but in your case you can remove the "fb.TitleFormat" bit altogether.

Code: [Select]
var auto_love_condition = 1;


Hello MARC2003, where to find those codes?
I just want to automatic love my track if it rating is set to 5
Thank you in advance!!!!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-01-03 04:20:33
the information in that 4 year old post is obsolete.

now you just right click the heart icon and you'll find the option to enable the automatic loving of tracks. make sure you set the condition as well.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: vanhoivanbinh on 2014-01-03 05:25:37
Hello Marc2003
Excuse me for the very old question
Since my library is huge, I hope that I do not need to press love track if the track is rating 5 stars.
I means it is automatically love function.
I know you have embedded it in the latest script. But I cannot find the way how to change it.
I search your script and found this one. But dont know how to use it . Sorry I am a noob
===================
case 1106:
            ps.auto_love_tf = this.InputBox("The result of the title formatting set here must equal 1 for a track to be automatically loved.\n\nExample:\n\n$ifequal(%rating%,5,1,0)", this.name, ps.auto_love_tf);
            window.SetProperty("playcount_sync_auto_love_tf", ps.auto_love_tf);
            break;
===================
Please let me know where and how to enable this automatic love function

Thank you so so much
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-01-03 12:45:42
read my post again. where does it say anything about editing the script? 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: vanhoivanbinh on 2014-01-06 02:32:02
read my post again. where does it say anything about editing the script? 

Thank you thank you very much, I have done it. Just right click in the love panel.
May I ask about another function
Since I want to sync the last.fm play-count and love data simultaneously from my computer, my smart phone etc.
For example, I have foobar on my PC with your script.
I have an android phone, a tablet, with last.fm autoscrobber.

I have one same song in my main PC as well as my phone, tablet.

I want wherever I  play that song (on my phone, tablet) its play-count and love database can be update automatically and silently between last.fm and the data in my PC (even I do not need to click the play the song in my PC)


This function will be like the SYNC function in itunes between i-devices. I HAVE wait to FOOBAR to have this but it seem only your script can do that.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-01-06 11:59:43
what you're asking isn't possible. either play the track or run the full import on a regular basis.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: vanhoivanbinh on 2014-01-07 01:54:46
what you're asking isn't possible. either play the track or run the full import on a regular basis.

Yeah, I know what you mean but we still need to play the track, of manual update the database.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: aztec_mystic on 2014-01-11 11:31:39
I have a (naive) question: Is it possible to hide the WSH panel that I have to add to my layout in order to use the script? My setup consists of the DUI without any tabs.

I love this script, but I don't feel the panel with the heart icon fits into my current layout aesthetically. It was a different story while I was still on CUI. Back then, I simply added the WSH panel to the toolbar. The heart icon didn't bother me in the toolbar location.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: mjm716 on 2014-01-11 14:05:17
when you get your download from last.fm, you should extract the json folder somewhere.



Does this method (downloaded json) replace the original, or is this supplemental? e.g. when I import the downloaded data with the script, does it import all fastfm stats or only some such as firstplayed?

I haven't yet sync'd my stats, and would prefer to do it only once from the downloaded dataset.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-01-11 15:45:28
Is it possible to hide the WSH panel that I have to add to my layout in order to use the script?


yup. just resize the panel as small as it will go. in this example it's at the bottom between the playlist and status bar. i've changed the background by right clicking>background>splitter.

(http://i.imgur.com/Yf97yVX.png)

Does this method (downloaded json) replace the original, or is this supplemental?


that is supplemental and only imports first played and/or last played. that's configured by altering two variables at the start of the script to true or false. it requires files provided by the original script so that must be setup first.

obviously these values will constantly change in the future so it's probably best used in conjunction with foo_playcount. eg

Code: [Select]
$if2(%LAST_PLAYED%,[%LAST_PLAYED_DB%]) //preferable to get last played from foo_playcount
$if2(%FIRST_PLAYED_DB%,[%FIRST_PLAYED%]) //first played would probably be better from last.fm
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: aztec_mystic on 2014-01-12 08:12:58
Is it possible to hide the WSH panel
i've changed the background by right clicking>background>splitter.

Thanks! The minimization of the panel works. I can't seem to change the color of the splitter (no option "background" shows in the context menu) but that's fine. Thanks again.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-01-12 09:09:07
perhaps you're missing the panel when you right click?

(https://dl.dropboxusercontent.com/u/22801321/2014/january/click.png)

you can always make the panel larger again to make it easier.

edit: most of the right click options are only available by right clicking on the heart icon itself so you might want to double check those before hiding it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: aztec_mystic on 2014-01-12 10:16:58
Got it -- great!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ubercow on 2014-01-30 07:11:24
hi marc, I'm getting json parse errors in the console for all your last.fm scripts since some time in the last few days..did something change? I might have accidentally done something myself but I'm not sure!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-01-30 08:34:14
everything is working fine here and there have been no outages reported on the last.fm status page.

make sure you're running the latest version of my script. right click one of the panels>Update script. if the update fails, you download this file (https://dl.dropboxusercontent.com/u/22801321/wsh/marc2003/common7.js) and save it inside your foobar profile\marc2003 folder. do this while foobar is closed. if you get any kind of script errors on startup, the scripts in your panels might be out of date in which case you'll need to import the latest from the full download (https://dl.dropboxusercontent.com/u/22801321/wsh/samples.zip).

also, you can try opening internet explorer, going in to internet options>browsing history>delete>temporary internet files.

if all this does nothing, try a new panel and import either the musicbrainz or discogs script into it. these scripts also use JSON feeds and it might help determine if the problem is just last.fm related or not.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ubercow on 2014-01-30 19:24:40
that's weird, I tried the internet explorer thing and it's working now. Not sure if that's what did it. Thanks very much anyway !
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: xska on 2014-02-08 14:02:41
I am trying to import via the last.fm data export (aka from file), but the option is greyed out in the menu. How do I activate it?

edit: That is, if such import is possible at all? The reason I'm trying this instead of via webservices is that my library is HUUGE. So it pretty much always fails around after about 100 requests

Last.fm Playcount Sync: Playcount: completed page 119 of 572
And then...
Error screenshot (https://www.dropbox.com/s/vofs5mdmu9bdksd/Screenshot%202014-02-08%2014.14.48.png)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-02-08 14:37:11
the main script from the first post doesn't do anything with the exported data files you have.

i've just modified the recent script i made for parsing the exported files here: https://dl.dropboxusercontent.com/u/2280132...port/export.txt (https://dl.dropboxusercontent.com/u/22801321/wsh/temp/export/export.txt)

put it in a new panel and take care to edit the first 3 variables as you like. it's a plain white panel - just double click to run it.

if you're only interested in the playcount, the original .cfg file supplied in my original zip will be fine. if you want to import first played/last played, you'd need to use this updated foo_customdb.dll.cfg file to go in your configuration folder: https://dl.dropboxusercontent.com/u/2280132...ustomdb.dll.cfg (https://dl.dropboxusercontent.com/u/22801321/wsh/temp/export/foo_customdb.dll.cfg)

i've not been able to test this as i deleted all my files from last.fm but hopefully it will work.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: xska on 2014-02-08 18:27:23
Awesome! Worked like a charm. Thank you very much

Code: [Select]
It took 3 seconds to open 89 JSON files and read 130500 scrobbles. 
130500 scrobbles took 1 seconds to process.
Last.fm library contains 57535 tracks.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Emerelle on 2014-02-14 14:41:31
I have a very weird problem.....while all is working fine with this script on all files, there is one album I cannot love any file. I took a look at the console and the command to love the track seemed to be transferred to the website, but I cannot see it reflected on my foobar (I have a column with the loved symbol that works with all loved tracks but these).
I checked if the files are read only but their not or at least that didnt solve the problem; I am stumped and dont even know where to begin to search for the problem. Anyone experience something similar? Its no big deal but I am scratching my head over it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-02-14 15:28:48
as the script uses foo_customdb, it doesn't touch your files so being read-only would be irrelevant.

can you hold shift and right click a problematic track in the playlist and select Legacy commands (unsorted)>Customdb Love 1. if that makes a loved symbol appear, there's no reason why it shouldn't work via the script.

also, can you post a full example of what the console displays when you love a track via the button.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Emerelle on 2014-02-14 17:27:02
Believe it or not, but the right click command did make the love symbol appear. Once I try via the script button, I get this in the console.....
Quote
Opening track for playback: "C:\Users\****\Music\Extize - FallOut_Nation-2009\13_extize-poser_(fabrikc_remix).mp3"
foo_softplaylists: successfully loved track 'Poser (FabrikC Remix)' by 'Ext!ze'
Last.fm Playcount Sync: Contacting Last.fm....
Last.fm Playcount Sync: Last.fm responded 'OK'
Last.fm submission: Now playing... OK
WSH Panel Mod: Warning: Obsolete: Please use AppendTo() method to create sub menu instead of AppendMenuItem()
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-02-14 18:08:09
you're using a pretty old version there. try the latest version from the first post.

https://dl.dropboxusercontent.com/u/2280132...ount%20sync.zip (https://dl.dropboxusercontent.com/u/22801321/wsh/playcount%20sync.zip)

-extract the marc2003 folder and overwrite any files if prompted
-import the new playcount sync.txt file into the panel
-right click the panel to set your last.fm password. this is required because i no longer use foo_softplaylists - my script loves tracks natively now.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Emerelle on 2014-02-14 18:21:12
That solved it, many many thanks for your help and patience!!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: vanhoivanbinh on 2014-02-15 08:08:11
Dear Mar2000
Please help me to solve this problem
I am trying to create a rating panel for Playing Song with WSH panel mod
I try to use the scrip from here (which originally from you,
then someone modified it with the gramma $meta(.....) - sorry i am noob in programming -


THE separated RATING PANEL SCRIPT using WSH PANEL mod IS HERE
http://www.hydrogenaudio.org/forums/index....rt=#entry840125 (http://www.hydrogenaudio.org/forums/index.php?showtopic=99752&pid=840125&mode=threaded&start=#entry840125)

The problem is, with the updated script from the link above, I can rate the song I am listening easily but the Rating is updated only in metadata of the file.
While your Last.fm script using data from foo_customdb

I realize that now I have two rating database
1/ Original on the file
2/ From Foo_customdb database

Can you help me of point out how to modify the script of the Rating Panel so it can write to Customdb database. SO the LAST.FM script and This RATING PANEL can cooperate

THANK YOU SO SO MUCH!!!!!!!!!!!!!!!!!!!!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: foobarhelp on 2014-02-15 10:09:34
I don't mean to be a burden, but I've recently gotten back into foobar skins, after quickly being discouraged the last time I tried, and just as I thought I'd completed a successful installation an error: "Scripting Engine Initialization Failed (Playcount Sync by marc2003, CODE: 0x80020101)
Check the console for more information (Always caused by unexcepted script error)."

Though I've looked for hours online for a solution, none have really solved my problem. It's for the foo_ncmpcpp_mod skin, and here's the readme that I've been referring to for the installation: https://gist.github.com/twnsnd/2000446 (https://gist.github.com/twnsnd/2000446).

Debug and safe mode are unchecked. I unpacked the component folders to the foobar directory. All the fonts are installed, too.

The only instruction there that I didn't follow was removing the user_profiles_enabled file because when I did that another error came up. Perhaps I need this only works for an older version of foobar? It doesn't say anything about needing the portable version.

Anyway, I know this is a really old issue but I'd really appreciate any help you guys can give me.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-02-15 15:36:44
Can you help me of point out how to modify the script of the Rating Panel so it can write to Customdb database.


why? you can just use my original script (https://dl.dropboxusercontent.com/u/22801321/wsh/samples.zip) and foo_playcount which uses its own database.

@foobarhelp, i'm not providing support for old scripts that other people have bundled with their themes. try using my original script from the first post. minimum requirements are foobar v1.1 and WSH panel mod 1.5.0. full instructions are inside the zip.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Majestic12 on 2014-02-16 02:29:57
After installing this mod every time I click a left button on the playlist to select a track every graphical element in my config repaints itself. I use this config. (http://br3tt.deviantart.com/art/Xchange-360-130750625) I can live with that but is there a way to disable it? I think it behaves like this to refresh the status of the icon even if there isn't any track playing but the icon could just refresh itself after we start playing the chosen track.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-02-16 03:07:34
i'm fairly certain a selection change wouldn't cause my script to force a redraw of the whole layout. i think it's more likely to panel stack splitter causing that.

my script might force a redraw once per track when the playcount changes because i force an update of foo_customdb. you can mimic this behaviour by holding shift and right clicking a track in the playlist>legacy commands (unsorted)>customdb refresh. if that causes a flicker, then so be it.

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Majestic12 on 2014-02-16 22:05:13
i'm fairly certain a selection change wouldn't cause my script to force a redraw of the whole layout. i think it's more likely to panel stack splitter causing that.

my script might force a redraw once per track when the playcount changes because i force an update of foo_customdb. you can mimic this behaviour by holding shift and right clicking a track in the playlist>legacy commands (unsorted)>customdb refresh. if that causes a flicker, then so be it.

When I use that command there isn't any repainting. So as you said PSS might cause that...
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: vanhoivanbinh on 2014-02-17 03:13:15
Can you help me of point out how to modify the script of the Rating Panel so it can write to Customdb database.


why? you can just use my original script (https://dl.dropboxusercontent.com/u/22801321/wsh/samples.zip) and foo_playcount which uses its own database.

@foobarhelp, i'm not providing support for old scripts that other people have bundled with their themes. try using my original script from the first post. minimum requirements are foobar v1.1 and WSH panel mod 1.5.0. full instructions are inside the zip.


I did it!!! You are genius Mar2000!!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: vanhoivanbinh on 2014-02-17 03:34:55
Again, a noob question
How to export the play-count database from foobar2000 to my last.fm database?
Since some tracks in my lib has last.fm playcount smaller than its own database playcount
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-02-17 09:18:22
short answer: not possible with an existing last.fm account/foobar
slightly longer answer: you can import playcounts from WMP, winamp or itunes into a brand new last.fm account using the official software http://www.last.fm/help/faq?category=93#235 (http://www.last.fm/help/faq?category=93#235)

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Kougeru on 2014-02-25 03:33:26
Lately it's not syncing my plays properly, even after doing a manual update. It's always a few plays behind for some reason. The exception is when I get a new song. It updates from 0 to 1, and sometimes to 2. But after 2 it pretty much stays at 2 plays on lastfm playcount despite lastfm itself showing 5+, and foo_playcount is updating properly as well. Right-clicking and using "customdb refresh" turns it into "?" until I highlight it, in which it turns back to the same incorrect number it was displaying prior. Any idea? I checked for updates on each component and the script as well, everything is Gold. Out of 15 new tracks I got, one of them is displaying properly. Older songs are 5-10 plays behind.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-02-25 04:07:54
what does the foobar console say? (view menu>console) when working, it should report this...

Code: [Select]
Last.fm Playcount Sync: Contacting Last.fm.... 
Last.fm Playcount Sync: Last.fm responded ok. Attempting to update playcount...
Last.fm Playcount Sync: Playcount updated successfully.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Godly on 2014-03-04 14:29:15
I've been having similar problems to Kougeru. This is the error I get from the console:

Code: [Select]
Last.fm Playcount Sync: Contacting Last.fm.... 
Last.fm Playcount Sync: Last.fm responded ok. Attempting to update playcount...
Last.fm Playcount Sync: Database error. Playcount not updated.



an example of the problem I'm having: http://i.imgur.com/5bcpgTD.png (http://i.imgur.com/5bcpgTD.png)



Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-03-04 15:25:11
Code: [Select]
Last.fm Playcount Sync: Database error. Playcount not updated.


ok.... a few questions...

is this happening on everything now or is it intermittent?
does it happen on certain tracks only or is it random?
are you using foo_customdb for anything else apart from this script?

i've not changed any functionality but i've added some extra logging into this script. save this in your marc2003 folder while foobar is closed...

https://dl.dropboxusercontent.com/u/2280132...0log/common7.js (https://dl.dropboxusercontent.com/u/22801321/wsh/temp/playcount%20sync%20log/common7.js)

it should output something like this...

Code: [Select]
Last.fm Playcount Sync: Contacting Last.fm.... 
Last.fm Playcount Sync: Last.fm responded ok. Attempting to update playcount...
Last.fm Playcount Sync: Old value: 17
Last.fm Playcount Sync: New value: 18
Last.fm Playcount Sync: Attempt: 1
Last.fm Playcount Sync: Attempt: 2
Last.fm Playcount Sync: Playcount updated successfully.


Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Godly on 2014-03-04 16:18:48
-It was happening on everything. I'm not sure how long it had been like that though.
- ^
- I don't use customdb for anything else besides this.

I've downloaded your new file and put it in the folder. I've since tested 5 tracks (including the one I mentioned above) and all of them were succesfully updated. This is the code I got from the above track:


Code: [Select]
Last.fm Playcount Sync: Contacting Last.fm.... 
Last.fm Playcount Sync: Last.fm responded ok. Attempting to update playcount...
Last.fm Playcount Sync: Old value: 3
Last.fm Playcount Sync: New value: 12
Last.fm Playcount Sync: Attempt: 1
Last.fm Playcount Sync: Playcount updated successfully.


It is also now updating other tracks that it previously hadn't been. Seems to be fixed. Thanks.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-03-04 16:39:39
i did make a change to the code after i posted that i thought might help and it looks like it's working. therefore i've put the fix in my main script. anyone can right click their panel>Update script. the extra logging has been removed because there's no need to spam the console with it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Kougeru on 2014-03-04 18:06:09
i did make a change to the code after i posted that i thought might help and it looks like it's working. therefore i've put the fix in my main script. anyone can right click their panel>Update script. the extra logging has been removed because there's no need to spam the console with it.


Code: [Select]
Last.fm Playcount Sync: Contacting Last.fm.... 
Last.fm Playcount Sync: Last.fm responded ok. Attempting to update playcount...
Last.fm Playcount Sync: Database error. Playcount not updated.
Last.fm Playcount Sync: Automatically loving this track....
Last.fm Playcount Sync: Attempting to love "Cupid (So Far...ver)" by "LAMA"
Last.fm Playcount Sync: Contacting Last.fm....
Last.fm Playcount Sync: Track loved successfully.


I did what you said, to no avail. Does that other script still work with the extra logging? I didn't get a chance to try it because hydrogen only emailed me for the post I just quoted.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-03-04 18:59:27
if you right clicked your panel and it updated ok after my last post then you have the supposedly "fixed" script.

if you're still getting this error...

Code: [Select]
Last.fm Playcount Sync: Database error. Playcount not updated.


all you're missing is the attempt 1, 2, 3, 4, 5 in the console. it means the playcount is fetched ok but something is preventing my script from updating foo_customdb. it's always been bit of a hack job because i do it "outside" of foobar using a command line tool called sqlite. i've set it to try 5 times before it gives up. in my own testing i've seen it take 2 attempts but it's mostly 1. i made it 5 just for good luck.

are you using foo_customdb for anything else or just this script? is it now failing on everything that has an existing last.fm playcount?

edit: the logging code is still in the script - you can un-comment lines 2799, 2800 and 2806 but it shouldn't make any difference.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-03-04 20:27:35
i've now updated the script with an Extended logging option and this is found under the Auto-updates menu.

(https://dl.dropboxusercontent.com/u/22801321/2014/march/logging.png)

it's off by default because it spams the console but if you want to see the old/new values and how many attempts it takes, you can enable it.

right click panel>Update script. restart foobar when prompted.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: DustMagnet on 2014-03-04 22:42:22
Interesting. The update fixes a problem I didn't even realize I had until I read the last few posts. 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Kougeru on 2014-03-04 22:50:07
edit: Alright I figured it , I think. I reinstalled the plugin and it's working now. I think it might've broke when I removed the custom DB Action "Delete Playcount" because it sounded scary. Coding is beyond my field of knowledge, so I guess I shouldn't mess with it. Thanks for your time and help.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-03-04 23:20:38
think it might've broke when I removed the custom DB Action "Delete Playcount" because it sounded scary.


yes, that most definitely did break it. it's not possible to update a playcount in place so i have to delete the old one first. hopefully it will be ok now. 

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: whitewidow on 2014-03-05 14:33:47
I want to make the switch from last.fm to libre.fm. I figured out how to make all my players -- including foobar2000 -- scrobble to libre.fm. Specifically, for foobar this entails entering 149.20.54.250 (http://turtle.libre.fm) as a proxy in Preferences -> Networking.

Can this plugin/script be made compatible with libre.fm?

(I think I could possibly test this myself. But I don't want to screw up my current config so I'm hoping somebody who reads this post knows.)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-03-05 15:21:18
at first glance, i'd have to say no. their API doesn't offer the feeds that this script uses.

http://bugs.foocorp.net/projects/librefm/w...efm_API_methods (http://bugs.foocorp.net/projects/librefm/wiki/Librefm_API_methods)

i need these...

track.getInfo (http://www.last.fm/api/show/track.getInfo) - needed for the background playcount/loved track updates
library.getTracks (http://www.last.fm/api/show/library.getTracks) - needed for importing playcount

there appears to be support for loving/unloving tracks and fetching all loved tracks but that's about it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Godly on 2014-03-05 19:24:18
I'm having trouble again. It won't update the playcount on any of my tracks now.

Code: [Select]
Last.fm Playcount Sync: Contacting Last.fm.... 
Last.fm Playcount Sync: Last.fm responded ok. Attempting to update playcount...
Last.fm Playcount Sync: Old value: 12
Last.fm Playcount Sync: New value: 13
Last.fm Playcount Sync: Attempt: 1
Last.fm Playcount Sync: Attempt: 2
Last.fm Playcount Sync: Attempt: 3
Last.fm Playcount Sync: Attempt: 4
Last.fm Playcount Sync: Attempt: 5
Last.fm Playcount Sync: Database error. Playcount not updated.


I've updated the script to the latest version but it's still the same
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-03-05 22:57:48
well i have no idea what else it could be. try a clean portable install? make sure you copy files from the latest zip and not your current install.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-03-06 15:16:40
if anyone has updated since the 4th (2 days ago), they should update again as i introduced a silly bug with my spring cleaning. it would set a playcount of 1 for tracks if the track length is not acceptable by last.fm (less than 30 seconds or more than 3 hours).

right click panel>Update script.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Der Internet on 2014-03-10 11:53:30
Heyho!

i have to import ~750 pages and i'm always getting problems with the last.fm web service.. maybe they are blocking me because of the many requests? Any way to slow down the process? hank you for your great script! mostly it's around page 240  here's a screenie

https://www.dropbox.com/s/6u78ppvrrkj1hqj/S...%2013.03.45.png (https://www.dropbox.com/s/6u78ppvrrkj1hqj/Screenshot%202014-03-10%2013.03.45.png)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-03-10 12:07:40
if it was being blocked, i think the error would say so. also, we're allowed 5 requests per second which this script will never be in danger of passing.

as you have a fairly large library, you could try downloading your entire scrobbling history from this page: http://www.last.fm/settings/dataexporter (http://www.last.fm/settings/dataexporter)

then you can run this entirely separate script on it: https://dl.dropboxusercontent.com/u/2280132...port/export.txt (https://dl.dropboxusercontent.com/u/22801321/wsh/temp/export/export.txt)

having my original script in place means you should already have the files it needs. it may take a day or so to get the data from last.fm. also, you should edit the first 3 lines of code so that only the play_count option is set to true.

edit: if you what you say it failing at the same point each time is true, i really ought to have my script skip that page and trying to continue rather than aborting. i'll look at updating that as well.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Der Internet on 2014-03-10 12:11:39
if it was being blocked, i think the error would say so. also, we're allowed 5 requests per second which this script will never be in danger of passing.

as you have a fairly large library, you could try downloading your entire scrobbling history from this page: http://www.last.fm/settings/dataexporter (http://www.last.fm/settings/dataexporter)

then you can run this entirely separate script on it: https://dl.dropboxusercontent.com/u/2280132...port/export.txt (https://dl.dropboxusercontent.com/u/22801321/wsh/temp/export/export.txt)

having my original script in place means you should already have the files it needs. it may take a day or so to get the data from last.fm. also, you should edit the first 3 lines of code so that only the play_count option is set to true.


Thank you for your ultrafast repsonse  sadly , i'm not as good as computer stuff as i pretend to be  where do i have to put that file/insert the script?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-03-10 12:21:41
when you get the data from last.fm, it will arrive as a zip. you just need to extract the files somewhere. as for that script above, i did actually forget to tell you how it works.  it goes in a new panel and then you close the editor. it's just a plain white panel with no interface. just double click to run it and a file browser will popup and you need to browse to a folder called scrobbles. this will be inside the folder than you extracted from the last.fm zip file. it takes a second or 2 to run and then make sure you follow the prompt from the popup window when it's done.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-03-10 14:29:20
edit: if you what you say it failing at the same point each time is true, i really ought to have my script skip that page and trying to continue rather than aborting. i'll look at updating that as well.


i've updated the script to skip all problematic pages instead of aborting. it keeps track of how many pages have errors and will report that when it's finished.

right click>Update script.

full download: https://dl.dropboxusercontent.com/u/2280132...ount%20sync.zip (https://dl.dropboxusercontent.com/u/22801321/wsh/playcount%20sync.zip)

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Der Internet on 2014-03-11 01:27:55
Nice... now it worked! Thanx a lot, may your offspring be countless like grains of sand 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zageron on 2014-03-19 03:17:07
I'm not sure if this has been reported before, and I'm not sure if this is something you are able to fix.
However,

Code: [Select]
Custom Database: library routine called out of sequence (21)
Custom Database: library routine called out of sequence (21)
Custom Database: library routine called out of sequence (21)
Custom Database: library routine called out of sequence (21)
Custom Database: library routine called out of sequence (21)
Custom Database: library routine called out of sequence (21)
Custom Database: library routine called out of sequence (21)
Custom Database: unknown error (21)


This occurs when I sort on Plays.
The playlist is populated by 4872 songs. Though the other playlists I have, 22140 and 15853, unsurprisingly react the same way.

Additionally, while when I sort on any other tag the sort is generally instant if I sort on heart or play there is a significant delay of between half a second to a few seconds depending on the size of the playlist.

This is most definitely caused by the custom database plugin, but I'm wondering if anyone else has experienced this and if it's possible to fix from your end.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-03-19 03:29:47
this looks to be a limitation of the component and obviously nothing can be done about it. i don't think the developer ever posted here and even the site it was hosted on is totally gone now.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Majestic12 on 2014-04-01 02:51:43
i'm fairly certain a selection change wouldn't cause my script to force a redraw of the whole layout. i think it's more likely to panel stack splitter causing that.


You were right, I've finally found the cause of the flicker - somehow the option named "titleformat mode on startup" in PSS was changed from "now playing" to "follow cursor". I must've changed that accidentally because I don't even know what is its purpose.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Odinos on 2014-04-20 15:44:10
Hey marc, thanks for the great script. ive been using it for a while but there is one thing i cant seem to get working. when i love a track on lastfm it syncs to my library but it does not work the other way around. when i "customdb love 1" a track in my library it doesnt carry over to lastfm. i checked the console but it doesnt say anything (playcount works fine).

edit: When i play a song that has love status in my library but not on lastfm it removes the love again.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-04-20 17:54:42
you're not supposed to use the context menu on tracks in the playlist. they exist only because the script needs them to work.

you love/unlove tracks by clicking the heart icon on the panel itself and the context menu options are then triggered on a successful response from last.fm's servers.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Odinos on 2014-04-21 15:02:05
oh right, i bound my buttons to the wrong command. how do i bind a button in my playback toolbar to the heart icon?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-04-21 19:26:52
that's not possible. if it was, i would have mentioned it in the readme...

Quote
Loving/unloving tracks

Just click the heart icon to love a track. The local database is only updated on a successful response from Last.fm. Check the foobar2000 console for confirmation or errors. If a track is already loved, clicking the button will simply unlove the track. Tooltips indicate what will happen before you click the button.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: MrShmoo on 2014-04-29 06:27:38
Hey - thanks a lot for this tool. After searching far and wide this seemed to be the only thing available that could easily copy my iTunes playcounts into Foobar (via LastFM) - I even tried writing a python script to modify my iTunes Library XML file by copying the playcounts into the comments field but that didn't work. Quick question though - the playcount syncing didn't seem to grab everything for me. It got a good number of items in my library but for others it doesn't seem to get the playcount until I successfully scrobble the track and then it syncs - i.e. it goes from 0 to 10 upon playing the track. I should also mention I'm using the default LastFM desktop app for scrobbling. Any ideas what's going on? Obviously I wouldn't like to have to play everything to get all my playcounts

edit: whoops, think I figured it out. Turned off last fm auto correct in Foobar and on the website settings, re-synced and it looks like it grabbed everything. Annoying, but I guess I can turn it back on now and be good to go yeah?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-04-29 07:41:21
edit: whoops, think I figured it out. Turned off last fm auto correct in Foobar and on the website settings, re-synced and it looks like it grabbed everything. Annoying, but I guess I can turn it back on now and be good to go yeah?


i'm pretty sure changing this setting does not affect previous scrobbles so it shouldn't have made any difference?? 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: MrShmoo on 2014-04-29 13:58:10
i'm pretty sure changing this setting does not affect previous scrobbles so it shouldn't have made any difference?? 


Here's the problem in a nutshell: I had tracks by "Above and Beyond". Last FM classified these as "Above & Beyond". When I tried to Library Import, the LASTFM_PLAYCOUNT_DB was unknown for my "Above and Beyond" tracks, but when I played them in full it would go from unknown to 6 or whatever. I think this was because upon playing it would sync with the Above & Beyond scrobbles it DID have. But obviously I didn't want to have to play all the tracks where I had differences vs Last FM autocorrect just to get the correct playcount stats. Turning off the autocorrect told last FM the scrobbles were actually "Above and Beyond", taking care of all the "unknown" tracks.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: bananabm on 2014-05-09 00:11:26
everything is working fine here and there have been no outages reported on the last.fm status page.

make sure you're running the latest version of my script. right click one of the panels>Update script. if the update fails, you download this file (https://dl.dropboxusercontent.com/u/22801321/wsh/marc2003/common7.js) and save it inside your foobar profile\marc2003 folder. do this while foobar is closed. if you get any kind of script errors on startup, the scripts in your panels might be out of date in which case you'll need to import the latest from the full download (https://dl.dropboxusercontent.com/u/22801321/wsh/samples.zip).

also, you can try opening internet explorer, going in to internet options>browsing history>delete>temporary internet files.

if all this does nothing, try a new panel and import either the musicbrainz or discogs script into it. these scripts also use JSON feeds and it might help determine if the problem is just last.fm related or not.



Hi marc

I've also been getting json errors, I've done all the steps you just mentioned (checked update, made sure I've done it properly), and the discogs and musicbrainz scripts seem to work fine


My last.fm username is bbm-ng and I'll get a console output that looks like the following: http://pastebin.com/RJFsF2Kr (http://pastebin.com/RJFsF2Kr)

I do have a huge last.fm profile (300k+ plays), could it be that the json is just too big to parse or something? It doesn't always fail at 1200, sometimes it's 1400 for example.


Any suggestions?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-05-09 00:57:11
i tested your username and it worked ok - i got 1 page error but the rest was fine. i've uploaded the database file here... https://dl.dropboxusercontent.com/u/2280132...tomdb_sqlite.db (https://dl.dropboxusercontent.com/u/22801321/wsh/temp/customdb_sqlite.db)

make sure foobar is closed and then save this in your foobar profile folder making sure you overwrite the existing file.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: bananabm on 2014-05-09 08:51:28
i tested your username and it worked ok - i got 1 page error but the rest was fine. i've uploaded the database file here... https://dl.dropboxusercontent.com/u/2280132...tomdb_sqlite.db (https://dl.dropboxusercontent.com/u/22801321/wsh/temp/customdb_sqlite.db)

make sure foobar is closed and then save this in your foobar profile folder making sure you overwrite the existing file.


Cool, seems to have worked fine.

Cheers!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Odinos on 2014-06-09 01:46:54
edit: whoops, think I figured it out. Turned off last fm auto correct in Foobar and on the website settings, re-synced and it looks like it grabbed everything. Annoying, but I guess I can turn it back on now and be good to go yeah?


thanks! I had the same problem. your solution added playcounts to over 2000 tracks which hadnt any yet.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zageron on 2014-06-19 18:31:04
Hey marc,

I'm looking to revert back to using tags for my playcounts.
Is there any existing way to convert your db to a playcount tag on each file?

Thanks,
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-06-19 19:09:32
Library menu>search

Code: [Select]
%LASTFM_PLAYCOUNT_DB% PRESENT


select all results>right click>properties>right click playcount tag>format from other fields>enter %LASTFM_PLAYCOUNT_DB% as the pattern

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zageron on 2014-06-19 19:14:51
Library menu>search

Code: [Select]
%LASTFM_PLAYCOUNT_DB% PRESENT


select all results>right click>properties>right click playcount tag>format from other fields>enter %LASTFM_PLAYCOUNT_DB% as the pattern


Ah, should have thought of this.

Thank you so much!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: NokTham on 2014-07-04 16:36:42
Afternoon all, I could use some help on this issue, I've been having some crashes on FB2K, now, I do not know if it's related to foo_customdb or this script.

Crash Report: http://pastebin.com/aJbRF6GB (http://pastebin.com/aJbRF6GB)

I have noticed that it happens, not everytime, but sometimes when the Song Length reaches 50%.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Zageron on 2014-07-04 19:47:37
Afternoon all, I could use some help on this issue, I've been having some crashes on FB2K, now, I do not know if it's related to foo_customdb or this script.

Crash Report: http://pastebin.com/aJbRF6GB (http://pastebin.com/aJbRF6GB)

I have noticed that it happens, not everytime, but sometimes when the Song Length reaches 50%.


In the mean time, I would suggest create a portable installation of foobar beside your current one. Pull your library file over if it's very large, but slowly re-install each component and attempt to simulate the error each time. If you hit Online Troubleshooter in the help menu, it will be one of those components that is causing the issue. You have many components that seem to have something to do with playback, so it is definitely one of those. Check for new updates for each of those components too, many components are not a part of the auto-update system and can update without warning. (Though more likely they haven't, because foobar components seem to be dying out except for those maintained by koda.)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-07-04 22:34:14
are you using the foo_customdb.dll.cfg that i supply with the download? with that, the component has been perfectly stable for me - and i think everyone else.

if you edit the database settings manually so you can use foo_customdb for other things, it may well be that. foo_customdb is notoriously unstable if you use the default settings.

but rather than try and troubleshoot by removing other components, i'd just remove foo_customdb and see how you get on.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ladiko on 2014-07-26 09:15:55
I bought a new computer and foobar just wont start with foo_customdb.dll. If i start it in compatibility mode for Windows7 or before, it just works without any hassle.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: adamf9898 on 2014-09-15 08:52:26
very nice job on this, i like it alot!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-09-15 12:36:44
I bought a new computer and foobar just wont start with foo_customdb.dll. If i start it in compatibility mode for Windows7 or before, it just works without any hassle.


i guess i must have missed this post before but my old computer was running windows8.1update1 and i'd not had any issues like that. it just worked. i've not been able to try any newer versions of windows because i'm currently stuck with a piece of junk only capable of running windows XP. 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: faemir on 2014-09-19 22:40:47
Forgive me if this has been answered already, but is there any way for the playcount grabbed from last.fm to be combined with/transferred the foo_playcount (aka playback statistics) component?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-09-20 10:35:27
i think the only way you can do that is by manually transferring the foo_customdb values in to the play_count tags inside the files. then you can import from the files into foo_playcount.

assuming all your tracks are monitored as part of foobar's library, you can use the Library menu>Search

Code: [Select]
%LASTFM_PLAYCOUNT_DB% PRESENT


then select all the results>right click>properties. create a new tag play_count tag>right click>format from other fields and use %LASTFM_PLAYCOUNT_DB% as the pattern.

click ok to close the properties dialog. then with all the files still highlighted, you should find some import option for foo_playcount on the right click menu.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: NokTham on 2014-09-29 15:21:37
Afternoon all, I could use some help on this issue, I've been having some crashes on FB2K, now, I do not know if it's related to foo_customdb or this script.

Crash Report: http://pastebin.com/aJbRF6GB (http://pastebin.com/aJbRF6GB)

I have noticed that it happens, not everytime, but sometimes when the Song Length reaches 50%.


Regarding this problem, I have re-installed the custom db, and so far had no issues, thank you for the tips
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Cak3 on 2014-10-03 11:32:15
Hello! So, I've been using your artwork panel and last.fm biography scripts for a while now, and decided to try this one out since it seemed promising. The problem is, though, I can't get it to stop crashing. It launches all right, but after a few minutes, it's down (The script itself, not foobar). This is what pops into the console when it does:

Code: [Select]
Last.fm Playcount Sync: Contacting Last.fm.... 
Last.fm Playcount Sync: Last.fm responded ok. Attempting to update playcount...
Error: WSH Panel Mod Plus (Last.fm Playcount Sync by marc2003): The system cannot find the file specified.  File: E:\Cak3's Stuff\foobar2000\marc2003\common7.js
Ln: 2805, Col: 7
<source text only available at compile time>

Now, I have no experience at all with JScript, but I decided to look at the line it was referring to in the common7.js file. Using only what I can observe, yes, I do have "sqlite3.exe" in the marc2003 folder and "customdb_sqlite.db" in my foobar root folder. If more information helps, I'm running a portable installation of foobar on my external drive and am currently on Windows 8.1. The script says it's up to date. And, I don't know if this fact is related, but when I try importing my last.fm library, the console doesn't show any error, but the %LASTFM_LOVED_DB% tag doesn't seem to update or show any change, it only shows a song is one of my favorites if I add it through the interface itself. But it usually crashes not soon after, so I don't have time to wait to see if the favorites would just appear if I waited.

Well, sorry for the long-ish message. Anyways, any help would be appreciated
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-10-07 12:56:51
sorry i didn't reply sooner, i completely missed your post. 

can you try replacing the line of code 2805 which is this...

Code: [Select]
p.WshShell.Run(p.fso.GetFile(p.script_path + "sqlite3.exe").ShortPath + " " + p.fso.GetFile(fb.ProfilePath + "customdb_sqlite.db").ShortPath + " " + query1, 0, true);


try this instead....

Code: [Select]
try {p.console(p.fso.GetFile(p.script_path + "sqlite3.exe").ShortPath);}catch(e){p.console("ShortPath fail on " + p.script_path + "sqlite3.exe");}
try {p.console(p.fso.GetFile(fb.ProfilePath + "customdb_sqlite.db").ShortPath);}catch(e){p.console("ShortPath fail on " + fb.ProfilePath + "customdb_sqlite.db");}
p.WshShell.Run(p.script_path + "sqlite3.exe" + " " + fb.ProfilePath + "customdb_sqlite.db" + " " + query1, 0, true);


post what the console says. for example, mine says this...

Code: [Select]
Last.fm Playcount Sync: Contacting Last.fm.... 
Last.fm Playcount Sync: Last.fm responded ok. Attempting to update playcount...
Last.fm Playcount Sync: E:\FOOBAR~1\marc2003\sqlite3.exe
Last.fm Playcount Sync: E:\FOOBAR~1\CUSTOM~1.DB
Last.fm Playcount Sync: Playcount updated successfully.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Cak3 on 2014-10-11 04:22:41
Thanks for responding  Well, after replacing that line like you said, it now outputs this (It still crashes):

Code: [Select]
Last.fm Playcount Sync: Contacting Last.fm.... 
Last.fm Playcount Sync: Last.fm responded ok. Attempting to update playcount...
Last.fm Playcount Sync: Old value: ?
Last.fm Playcount Sync: New value: 11
Last.fm Playcount Sync: Attempt: 1
Last.fm Playcount Sync: E:\Cak3's Stuff\foobar2000\marc2003\sqlite3.exe
Last.fm Playcount Sync: E:\Cak3's Stuff\foobar2000\customdb_sqlite.db
Error: WSH Panel Mod Plus (Last.fm Playcount Sync by marc2003): The system cannot find the file specified.  File: E:\Cak3's Stuff\foobar2000\marc2003\common7.js
Ln: 2807, Col: 7
<source text only available at compile time>
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-10-11 08:09:34
Code: [Select]
Last.fm Playcount Sync: E:\Cak3's Stuff\foobar2000\marc2003\sqlite3.exe 
Last.fm Playcount Sync: E:\Cak3's Stuff\foobar2000\customdb_sqlite.db


i'm confused by this. it should read like this or given an error about ShortPath. 

Code: [Select]
Last.fm Playcount Sync: E:\CAK3'S~1\FOOBAR~1\marc2003\sqlite3.exe 
Last.fm Playcount Sync: E:\CAK3'S~1\FOOBAR~1\CUSTOM~1.DB


i also realised i made an error with that last line of code. i forgot to use quotes around paths with spaces in. try this line instead...

Code: [Select]
p.WshShell.Run("\"" + p.script_path + "sqlite3.exe" + "\" \"" + fb.ProfilePath + "customdb_sqlite.db" + "\" " + query1, 0, true);


you can remove those 2 lines before it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: malouito on 2014-10-11 11:39:02
I have a number of tracks that don't get their playcount updated even if the track is effectively scrobbled on Last.fm
Is there an issue? Is it possible to update playcounts for individual tracks? I dont know what Customdb refresh does but that doesn't seem to work (it removes the playcount)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-10-11 12:01:22
first of all, you should ignore the context menu items. they're not meant to be triggered manually - only by the script.

individual tracks should be updated as you play them - but nothing happens until you've played enough of it for it to count as a a scrobble.

you can view the foobar console to see what is going on as all success/failures are reported. you can even right click the heart icon>auto-updates>extended logging which shows more info.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: malouito on 2014-10-16 15:49:12
first of all, you should ignore the context menu items. they're not meant to be triggered manually - only by the script.

individual tracks should be updated as you play them - but nothing happens until you've played enough of it for it to count as a a scrobble.

you can view the foobar console to see what is going on as all success/failures are reported. you can even right click the heart icon>auto-updates>extended logging which shows more info.

I know I have to wait for 50% of the track to have been played but the problem doesn't seem to happen anymore, I don't know if I changed something.
I missed the extended logging options (didn't expect it to be where it was) thank you for pointing it out.

Another question: would it be possible to consider these 2 characters as the same: ' and ’ (single quote and apostrophe)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-10-16 17:06:23
Another question: would it be possible to consider these 2 characters as the same: ' and ’ (single quote and apostrophe)


i don't think there is any need for this. all you need to do is make sure you synchronise the Spelling correction (http://www.last.fm/settings/website) settings on the last.fm website with the Last.fm auto-correct setting found under the auto-updates menu on my panel.

most people probably won't have changed their setting (the default is on) on the last.fm website so that's why it's on by default in my script. but if you have turned this option off on the website, then you do need to turn it off in the script as well.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: malouito on 2014-10-16 17:19:53
most people probably won't have changed their setting (the default is on) on the last.fm website so that's why it's on by default in my script. but if you have turned this option off on the website, then you do need to turn it off in the script as well.

I had turned it off on both last.fm and your script. That's why I'd like some old scrobbles to be recognized because ’ is the correct punctuation but ' is quite widely used.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-10-17 19:51:44
That's why I'd like some old scrobbles to be recognized


this is the problem. when you have spelling correction turned off on the website and in the script, everything has to be an exact match. if you start messing around with character replacement, it's all or nothing. the chances are that trying to pick a few tracks that you've since changed the tags of, you're going to break the lookups for everything else with an apostrophe. i just don't think it's feasible.

with the set of options you've chosen, you can either update your tags to match what's on the last.fm website  - but this could mean not being able to retrieve "new" scrobbles.

really, if you have combinations of the same tracks with different punctuation, i'd delete one of them completely. you can browse your library on the last.fm website to do this.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: malouito on 2014-10-17 21:15:56
I don't really mind.
I'll keep the correct version, auto-correct has an history of correcting things that are right.
Thank you for your answers.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Cak3 on 2014-10-18 04:08:42
Well, it's been a while since I responded. It seemed to fix the error on that line, but another error popped out. Although, I seem to have found the solution. I realized that since it seemed to have a problem looking up the directory of the file(s), it probably had to do with the way the directory was formatted. If you look at the first folder, it's "Cak3's Stuff". When I remove foobar out of that directory and into the root of my hard drive, the script works 100%. This is only my guess, but it probably had some kind of syntax problems with the apostrophe and/or space in the folder name. Also, just for reference, this is the error I got before moving the foobar directory:

Code: [Select]
Last.fm Playcount Sync: Contacting Last.fm.... 
Last.fm Playcount Sync: Last.fm responded ok. Attempting to update playcount...
Last.fm Playcount Sync: Old value: ?
Last.fm Playcount Sync: New value: 1
Last.fm Playcount Sync: Attempt: 1
Error: WSH Panel Mod Plus (Last.fm Playcount Sync by marc2003): The system cannot find the file specified.  File: E:\Cak3's Stuff\foobar2000\marc2003\common7.js
Ln: 2789, Col: 7

Anyways, thanks for your help! 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-10-18 04:57:36
one of my previous posts shows i re-created your folder structure exactly and it still works for me without changing any code that's been working for years.

...but with your last post i just noticed this...

Quote
Error: WSH Panel Mod Plus


this looks like some modified component so i'm going to point the finger at that. Cak3's Stuff should work if you use the original component here...

https://code.google.com/p/foo-wsh-panel-mod/downloads/list (https://code.google.com/p/foo-wsh-panel-mod/downloads/list)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: elia_is_me on 2014-10-22 14:59:17
one of my previous posts shows i re-created your folder structure exactly and it still works for me without changing any code that's been working for years.

...but with your last post i just noticed this...

Quote
Error: WSH Panel Mod Plus


this looks like some modified component so i'm going to point the finger at that. Cak3's Stuff should work if you use the original component here...

https://code.google.com/p/foo-wsh-panel-mod/downloads/list (https://code.google.com/p/foo-wsh-panel-mod/downloads/list)


I tried it with wsh-panel-mod-plus and it works fine so it would not be wshmp's fault.
By the way wshmp should be compatible with wshm 's scripts.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: D.Sync on 2014-10-22 16:04:30
Hello there marc, it's been over 1 year since I last in the foobar2k modding community. Recently I've been thinking to revise my Nocturne skin here (http://dsync89.deviantart.com/art/Nocturne-for-foobar2k-351633398) and decided to implement this WSH script of yours instead of modding the ones from musickarte.

So far everything looks good, both manual and auto love track. But I do noticed some errors as shown in the console log below while the script is trying to update the play count. Not sure what it means by database error as I put all the fields correctly as written in the README file.

Code: [Select]
Last.fm Playcount Sync: Contacting Last.fm.... 
Last.fm Playcount Sync: Last.fm responded ok. Attempting to update playcount...
Last.fm Playcount Sync: Old value:  
Last.fm Playcount Sync: New value: 2
Last.fm Playcount Sync: Attempt: 1
Last.fm Playcount Sync: C:\FOOBAR~1\marc2003\sqlite3.exe
Last.fm Playcount Sync: Attempt: 2
Last.fm Playcount Sync: C:\FOOBAR~1\marc2003\sqlite3.exe
Last.fm Playcount Sync: Attempt: 3
Last.fm Playcount Sync: C:\FOOBAR~1\marc2003\sqlite3.exe
Last.fm Playcount Sync: Attempt: 4
Last.fm Playcount Sync: C:\FOOBAR~1\marc2003\sqlite3.exe
Last.fm Playcount Sync: Attempt: 5
Last.fm Playcount Sync: C:\FOOBAR~1\marc2003\sqlite3.exe
Last.fm Playcount Sync: Database error. Playcount not updated.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-10-22 18:02:57
I tried it with wsh-panel-mod-plus and it works fine so it would not be wshmp's fault.
By the way wshmp should be compatible with wshm 's scripts.


you're probably right. i'd just run out of things to blame. i've never seen this error before and this same code has been working for everyone else for nearly 5 years.

Not sure what it means by database error as I put all the fields correctly as written in the README file.


so you're using foo_customdb for other things and you performed the manual steps to enter all the data fields/actions yourself?? i must admit, i've never really tested how nicely it plays when other foo_customdb values are present because everyone usually uses the "bare" .cfg file i've provided. if you could browse your profile\configuration folder and put your foo_customdb.dll.cfg file online, i'll take a look at it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: D.Sync on 2014-10-22 18:12:17
Wow that was fast marc  Appreciate it.

I've uploaded the foo_customdb.dll.cfg file on Google Drive as requested here (https://drive.google.com/file/d/0B1VWcDiekmQpZjRYajljcFF5czA/view?usp=sharing). Hope you can take a look at it. It's a very strange problem indeed.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-10-22 18:34:56
well, i've discovered the problem quite quickly. my script simply does not play nice with foo_customdb when other values are present. i have an idea of how to get around it but i'll need to do some testing.

all that stuff in my manual about entering stuff manually is nonsense and i'm sorry to have wasted your time with that. 


Wrong conclusion, please see below!

[!--sizeo:1--][span style=\"font-size:8pt;line-height:100%\"][!--/sizeo--]moderation: edited at author's request.[/size]
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: D.Sync on 2014-10-22 18:51:31
That's alright marc. It's impressive that you are still actively supporting this amazing plugin of yours. From the project that I've involved in, some developers would have discontinue supporting after few months or years, such as the MusicCabinet mod for Subsonic web streaming client. Well in my case, I've abandoned supporting my skin after the initial release but have decided to revise it since some people are interested with it :-)

Looking forward to hear your updates :-)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-10-22 20:40:37
actually i was wrong, my script does work ok with other customdb values. it's a typo in your entries that causes the errors. 

on the fields page for LASTFM_PLAYCOUNT_DB and LASTFM_LOVED DB there is no space between %artist%%title%

Code: [Select]
$crc32($lower(%artist%%title%))


i just double checked my pdf was right and it is so you must have typed rather than copy/paste.

edit: could a moderator put a strike through the text on post 1043 and add something like "see below" at the end of it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: D.Sync on 2014-10-23 03:18:28
actually i was wrong, my script does work ok with other customdb values. it's a typo in your entries that causes the errors. 

on the fields page for LASTFM_PLAYCOUNT_DB and LASTFM_LOVED DB there is no space between %artist%%title%

Code: [Select]
$crc32($lower(%artist%%title%))


i just double checked my pdf was right and it is so you must have typed rather than copy/paste.

edit: could a moderator put a strike through the text on post 1043 and add something like "see below" at the end of it.


Hey there marc. Now that was a typical programming mistake to made. I must have overlooked it when I manually typed it. It works flawlessly now :-)

Code: [Select]
Last.fm Playcount Sync: Contacting Last.fm.... 
Last.fm Playcount Sync: Last.fm responded ok. Attempting to update playcount...
Last.fm Playcount Sync: Old value: 3
Last.fm Playcount Sync: New value: 4
Last.fm Playcount Sync: Attempt: 1
Last.fm Playcount Sync: C:\FOOBAR~1\marc2003\sqlite3.exe
Last.fm Playcount Sync: [b]Playcount updated successfully[/b].
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: kornkid5622 on 2014-10-29 12:03:40
I'm trying to use this script and it appears to get my library successfully from last.fm (gets 105 pages, then the blue box pops up, i close foobar and a few seconds later foobar reopens) i set the playcount column to use "[%LASTFM_PLAYCOUNT_DB%]" and after doing this only the first track in my library is showing that it has any plays (it shows 10) every other track shows 0... i tried copying all the components/etc over again to make sure i didn't miss anything but i get the same result, any idea what could be causing this?

after some more investigation i see that my database only has 4 entries so it doesn't appear to be writing the data to the database, but it does show that its grabbing it in the console

after more testing i've noticed that when i play songs it does properly sync the database with last.fm, for example a song that had no plays goes to 5 plays after 1 play when there were already 4 plays on lasrt.fm, not sure if this helps at all.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-10-30 09:19:19
can you browse your foobar profile folder and look inside the wsh_lastfm folder. there should be a file named lastfm.sql - open it in wordpad or decent text editor (windows notepad won't show the line breaks). if there are thousands of entries, i can at least determine that the fetched data was saved ok but the problem is with the import. if you can confirm either way, i'll see what we can try next.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: malouito on 2014-11-08 15:33:38
Would it be possible to update the play count only for a couple of tracks? (If I listened to them on another device) I'd love to see the updated count in fb2k.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-11-08 17:52:38
not really. my script doesn't work with the recent scrobbles feed because it doesn't supply real playcount data - only the fact it has been played at a certain time. also, knowing how far to go back is another headache i don't really want to think about.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: malouito on 2014-11-08 17:55:04
I wasn't thinking about getting recent scrobbles but rather right-clicking a bunch of tracks and retrieve play counts for these.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-11-08 18:25:48
i guess that's possible but you'd have to do a separate request per track which is just horrible. also, it could easily be abused and get my API key in trouble.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Cutter on 2014-11-10 12:19:12
Hi,

Is it possible to update the stats provided by foo_playcount?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-11-10 12:47:39
if you're talking about background updates as you listen then no.

if you want to do a one-off transfer of the data from the customdb database into playback statistics then you can. but there is a big BUT. and that is that you have to temporarily  transfer the values into your files which means updating tags and wiping any last_modified stamps which i know some people can be fussy about. only continue with these steps if you don't mind that.

first use library search>%LASTFM_PLAYCOUNT_DB% PRESENT
select all results>right click>properties. create a PLAY_COUNT tag if it doesn't already exist.
now right click the PLAY_COUNT tag and select format from other fields.
enter %LASTFM_PLAYCOUNT_DB% as the pattern and click ok.
click ok again to actually write the tags and close the properties dialog.
now with all the results in your search window still highlighted, right click>playback statistics>import statistics from file tags.
you may now go back and remove the PLAY_COUNT tag if you want to

optionally, you can do another search for %LASTM_LOVED_DB% IS 1. you can right click all results and use playback statistics to set the rating to 5.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Cutter on 2014-11-11 19:02:24
Thanks Marc. I have a problem with multiple artists: no playcount/loved information is displayed for albums with multiple artists. I've tried what you said in this post but the script seems to have changed since then. I can't find the line you said to replace. Help appreciated.
file>preferences>tools>custom database>fields tab

edit both custom entries...

Code: [Select]
$crc32($lower(%artist%%title%))


should become

Code: [Select]
$crc32($lower($meta(artist,0)%title%))


RESTART foobar now. foo_customdb is buggy if these changes are made without immediately restarting

now inside the panel for the script....

line 95 should become

Code: [Select]
artist = fb.TitleFormat("$meta(artist,0)").EvalWithMetadb(g_metadb);


line 100 should become

Code: [Select]
crc32 = fb.TitleFormat("$crc32($lower($meta(artist,0)%title%))").EvalWithMetadb(g_metadb);


i think that should do it.

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-11-11 19:13:28
you can right click the button and select artist field remapping. just enter $meta(artist,0) in that dialog box. i assume you've still edited the database options and configured foo_audioscrobbler to only submit that as well?

edit: i only think it's necessary to adjust the db settings if you want the library import to work. if you only use the background updates option, leaving the database settings alone should work. i probably should test it before making such statements.

edit2: i actually have a question for anyone who uses last.fm. if you have an artist with multiple values, do you submit it as-is or do you use $meta(artist,0). i checked the official client app and you don't get a choice with that - it simply submits the first value which is probably the most sensible choice. but i'm sure most people here use florian's foo_audioscrobbler component and that does actually submit %artist% by default. as all my artists only have single artists (i prefer feat. XXX as part of the title), i'm just wondering what other people do with this?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Cutter on 2014-11-11 19:58:52
you can right click the button and select artist field remapping. just enter $meta(artist,0) in that dialog box. i assume you've still edited the database options and configured foo_audioscrobbler to only submit that as well?

edit: i only think it's necessary to adjust the db settings if you want the library import to work. if you only use the background updates option, leaving the database settings alone should work. i probably should test it before making such statements.

No, audioscrobbler always had the default setting: [%artist%].

If that is relevant, here's how one of my scrobbles looks like to last.fm (as in the scrobbles.tsv from my last.fm data file):
artist name: Adam Skorupa & Krzysztof Wierzynkiewicz
uncorrected artist name: Adam Skorupa, Krzysztof Wierzynkiewicz
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-11-11 20:18:58
right, lets forget everything about changing settings and put everything back to default. that means closing foobar and extracting the configuration folder from the zip and putting it in your profile folder (assuming you don't use foo_customdb for anything else??). then reset the artist field remapping dialog in the script to %artist%.

can you confirm:

1) you're not seeing the playcount/loved status for multi value artists after doing a library import
2) playing enough of the track to count as a scrobble does actually update the playcount successfully?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Cutter on 2014-11-11 20:31:28
right, lets forget everything about changing settings and put everything back to default. that means closing foobar and extracting the configuration folder from the zip and putting it in your profile folder (assuming you don't use foo_customdb for anything else??). then reset the artist field remapping dialog in the script to %artist%.

can you confirm:

1) you're not seeing the playcount/loved status for multi value artists after doing a library import
2) playing enough of the track to count as a scrobble does actually update the playcount successfully?

1. Yes.
2. Yes.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-11-11 20:51:01
go to this page while logged in... http://www.last.fm/settings/website (http://www.last.fm/settings/website)

uncheck the setting for spelling correction. don't play anything because it might ruin future results when you change this setting back in a minute.

now run the full import again and all your results should match up. now go back to that last.fm webpage and turn the setting back on again.

assuming this works, i'll need to update the documentation. there was a time when changing this setting did not affect scrobbles made in the past but it appears to now which is why i'm hopeful it will work.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Cutter on 2014-11-11 21:04:10
It works! Thank you very much.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-11-11 21:23:03
that's good news! really this should be a parameter i could supply when fetching the results rather than getting the user to change the website setttings. i might put in a request on the last.fm forums but i won't hold my breath.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: audiophool on 2014-11-13 17:03:00
Marc,

I'm a big fan of your script. And it has been running smoothly for quite some time now. Recently, the auto-update doesn't work anymore (right-click -> "Update Script").

I get this error message:
Quote
The script reports that the update file has not been found. It could be a temporary problem with dropbox but if this error persists then it is most likely due to support stopping for this version. Check the hydrogenaudio thread or the full zip for updates.

http://www.hydrogenaud.io/forums/index.php?showtopic=77883 (http://www.hydrogenaud.io/forums/index.php?showtopic=77883)
https://dl.dropboxusercontent.com/u/22801321/wsh/samples.zip (https://dl.dropboxusercontent.com/u/22801321/wsh/samples.zip)


foobar version is 1.3.5, WSH Panel Mod version is 1.5.6.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-11-13 17:14:37
i forgot that error message would apply to this script and not just my other scripts. the part about stopping support for the old version is absolutely right. i've updated all the backend code but there really isn't anything new for this script except new images. it's also easier to use your own images because i've described in detail what you need to do to change them.

if you're happy with the old images, then there really isn't any need to update because i can't imagine anything ever changing at last.fm that will break it.

but if you do want to run the newest version, you can download the full zip from the first post. make sure you extract the whole marc2003 folder and then import the new .txt file into your panel. last.fm credentials will be remembered but all other settings set via the right click menu will need to be configured again. nothing has changed with the database settings so you will still see all your existing data.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: audiophool on 2014-11-14 06:53:15
^^^ Thank you, the manual update worked just fine.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-11-14 09:33:10
i forgot to mention, the new script does have one minor new feature - it comes bundled with a newer version of sqlite. i'm now able to detect when they have been errors during the library import. it will report this in the blue popup window if problems are found.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: audiophool on 2014-12-07 10:09:45
i've updated all the backend code but there really isn't anything new for this script except new images. it's also easier to use your own images because i've described in detail what you need to do to change them.
This may be a stupid question, but I cannot find where you described how to change the images. Could you point me in the right direction?

I've updated to the largestlatest version of the script. The images are now too large in the DUI. I've located the image files in .png format. I tried to simply resize those to 32x32. It didn't do the trick. The icons in fb2k are the same size as before, although they look different (it seems they're now upscaled; also, the background color is different).
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-12-07 10:28:20
the notes are inside the script itself. you should have seen them when putting it in the panel. although the images are larger, they are actually resized to 32x32 by this first line of code. you can edit that if you want it smaller.

Code: [Select]
//function takes 3 values: x, y, size. see on_size function if you want to update these relative to panel width/height
var ps = new playcount_sync(3, 0, 32);
//if you want to change the images, uncomment these lines below and modify the paths accordingly
//do not use fb.FoobarPath here as fb.ProfilePath already points to the same location if using portable mode
//ps.cross_img = gdi.Image(fb.ProfilePath + "my_theme\\images\\cross.png");
//ps.loved_img = gdi.Image(fb.ProfilePath + "my_theme\\images\\loved.png");
//ps.unloved_img = gdi.Image(fb.ProfilePath + "my_theme\\images\\unloved.png");


Quote
also, the background color is different


just like the old script, it uses your UI settings by default - but you can over ride this by using the right click menu>Background.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: audiophool on 2014-12-07 10:49:53
the notes are inside the script itself.

Oops, I should've checked there. Anyways, thank you very much for the instant answer. Setting size to 16 did exactly what I wanted.

Quote
Quote
also, the background color is different


just like the old script, it uses your UI settings by default - but you can over ride this by using the right click menu>Background.

No, that was the first thing I checked. Maybe MS Paint changed the background color or something. In any case, it doesn't matter, as changing the size in the script and going back to the original images provided by you did the trick.

---

One more question, unrelated to the previous one: it is still not possible to add the "love" button to the toolbar in DUI, correct? I use CUI on a different Windows box and I like that I can add the script to the toolbar buttons there.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2014-12-07 11:13:15
it is still not possible to add the "love" button to the toolbar in DUI, correct?


correct. no 3rd party components are allowed to do that.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Kalnoc on 2015-01-12 01:37:33
When I try to download the playcount sync.zip file from http://marc2003.x10host.com/lastfm-playcount-sync (http://marc2003.x10host.com/lastfm-playcount-sync) Chrome prevents me from downloading it, claiming it is a malicious file. I had downloaded the file earlier with Internet Explorer without any issues, and scanned it with my Antivirus (Nod32) and it passed. I just wanted to give you a heads up in case you were not aware of this issue.

Is the download safe to use? I ask because I do give it my Last.fm credentials (as expected).

Thank you, it is a great Foobar2000 script

I tried to send this via PM, but it said you couldn't get messages.

- Ben
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-01-12 09:16:50
i just tested with chrome and see the same issue. but if use the link from the first post in this thread, it works fine. both links point towards the same file on my dropbox space so it would seem google chrome has a problem with my web space as the referring page. it's a free web host so perhaps that's why it might not be trusted?? i'll try and investigate but i doubt i'll get very far.

i hope you do trust my code not to be malicious. it's just javascript so anyone can read it. also, i've been supporting this script for over 5 years now.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: zeremy on 2015-01-12 09:40:14
i just tested with chrome and see the same issue. but if use the link from the first post in this thread, it works fine. both links point towards the same file on my dropbox space so it would seem google chrome has a problem with my web space as the referring page. it's a free web host so perhaps that's why it might not be trusted?? i'll try and investigate but i doubt i'll get very far.

i hope you do trust my code not to be malicious. it's just javascript so anyone can read it. also, i've been supporting this script for over 5 years now.



I can also support that marc2003 code is not malicious.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Kalnoc on 2015-01-12 15:08:06
i just tested with chrome and see the same issue. but if use the link from the first post in this thread, it works fine. both links point towards the same file on my dropbox space so it would seem google chrome has a problem with my web space as the referring page. it's a free web host so perhaps that's why it might not be trusted?? i'll try and investigate but i doubt i'll get very far.

i hope you do trust my code not to be malicious. it's just javascript so anyone can read it. also, i've been supporting this script for over 5 years now.


Thank you for the quick reply. I certainly trust your code not to be malicious. I just wanted to be sure the file it was trying to download was in fact your code and not something that had been compromised or somehow uploaded by a less trustworthy source. Guess its just the former IT guy in me being overly paranoid.

If the link from the first post in this thread will work, I will use that.

Thanks again.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Odinos on 2015-01-17 19:33:40
the script has stopped working for me recently, it does not synchronize play counts. the log displays this message: Last.fm Playcount Sync: {"error":26,"message":"Suspended API key - Access for your account has been suspended, please contact Last.fm","links":[]}
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Andreasvb on 2015-01-17 19:47:04
And have you checked why your API key is suspended?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Odinos on 2015-01-17 20:09:05
I thought the api key was bound to the application or the developer?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: firewater on 2015-01-18 05:40:14
First time trying this. I was super excited, but then I realized the API is not working... please fix it, this is an incredible script!!!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: DVS on 2015-01-18 08:13:23
I have the same message
Last.fm Playcount Sync: Contacting Last.fm....
Last.fm Playcount Sync: {"error":26,"message":"Suspended API key - Access for your account has been suspended, please contact Last.fm","links":[]}
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Andreasvb on 2015-01-18 12:28:16
Ah, I'm using the old file-based version, where you use your own key.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: CGGB on 2015-01-18 12:31:53
to All, change in common8.js in strings 1813&1814 api-key&secret to your own, get it http://www.last.fm/api/account/create (http://www.last.fm/api/account/create)
Code: [Select]
1813    this.api_key = "56d9e050cc2d6b36102c8b4a5fe6152d";
1814    this.secret = "9f1f4346ce3ba206390074ff8cb4c6ce";

Marc, please add ability to change api-key&secret through your wsh script and maybe take out them from common#.js to external file for correct updates.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: eviltoast on 2015-01-18 12:49:22
I have the same issue since yesterday - playcount doesn't sync and when trying to "like" a song (using password field in WSH panel I get the following message:

http://puu.sh/eGvgt/dec3e0a4ed.png (http://puu.sh/eGvgt/dec3e0a4ed.png)

Quote
to All, change in common8.js in strings 1813&1814 api-key&secret to your own, get it http://www.last.fm/api/account/create (http://www.last.fm/api/account/create)
CODE

where is common8.js located at?

edit: ok I've found the file in \Foobar2000\marc2003\common7.js , lines 1895

go to http://www.last.fm/api/account/create (http://www.last.fm/api/account/create) , input something in fields and you get the new keys
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Odinos on 2015-01-18 12:56:08
I have the same issue since yesterday - playcount doesn't sync and when trying to "like" a song (using password field in WSH panel I get the following message:

http://puu.sh/eGvgt/dec3e0a4ed.png (http://puu.sh/eGvgt/dec3e0a4ed.png)

Quote
to All, change in common8.js in strings 1813&1814 api-key&secret to your own, get it http://www.last.fm/api/account/create (http://www.last.fm/api/account/create)
CODE

where is common8.js located at?


C:\Users\USERNAME\AppData\Roaming\foobar2000\marc2003
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: eviltoast on 2015-01-18 13:03:22
thank you all, CGGB's solution helped and now the playcount is synced and "love' works again.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: jbercx on 2015-01-18 13:25:56
Hi I have done this, now I got following message:
{"error":26,"message":"Suspended API key - Access for your account has been suspended, please contact Last.fm","links":[]}

what to do?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: jbercx on 2015-01-18 14:38:07


Edit: now it is working


My Settings:
this.api_key = "new key";
   this.secret = "new key";
   this.ua = "foobar2000_wsh_panel_mod_lastfm";

Important when creating a new key, to use as application name "foobar2000_wsh_panel_mod_lastfm", otherwise it will not work.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Kalnoc on 2015-01-18 20:18:42
The initial library import worked perfectly for me a few days ago, but today I ran it again so it would import some plays scrobbled from my phone. When I run the import I see the following in the console:

Last.fm Playcount Sync: Starting import...
Last.fm Playcount Sync: Nothing found to import.
Last.fm Playcount Sync: Contacting Last.fm....
Last.fm Playcount Sync: {"error":26,"message":"Suspended API key - Access for your account has been suspended, please contact Last.fm","links":[]}

Previous posts suggest creating an API key using the page http://www.last.fm/api/account/create (http://www.last.fm/api/account/create) but what info do I need to enter for:

Application/Device Name
Application Description
Application Homepage

I'm running Foobar200 v1.3.7 in portable mode. The script was updated to Common file: 8.2015-01-17.01

Please advise.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-01-18 21:10:27
just download and save this in your marc2003 folder.

http://marc2003.x10host.com/common8.js (http://marc2003.x10host.com/common8.js)

i can't update my main files hosted on dropbox until in the week sometime.

edit: i think passwords will need to be set again again because of the new api key in it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: firewater on 2015-01-18 23:29:32
Thanks for the quick response guys. Alright so it seemed to work properly, only problem is I don't know how to create a playlist with this. I'm making a new view on Library Tree with the field of %LASTFM_PLAYCOUNT_DB% but it's not grabbing anything.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-01-19 16:50:16
it should work. have you done a library search to check how many files got updated after the import?

Library menu>search

Code: [Select]
%LASTFM_PLAYCOUNT_DB% PRESENT
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: firewater on 2015-01-19 23:00:29
I'm not sure if I get what you mean, but it seems that I'm getting nothing there either.

(http://i.imgur.com/LYa10iu.png)

In case you feel like seeing it, I'm sending you my portable Foobar on a note link on DA (because IIRC I can't share it here). The panel for your script is hidden under library.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-01-20 09:21:16
you haven't followed this part of the instructions:

Quote
Install the foo_customdb component and if you've never used it before then you can extract the configuration folder from playcount sync.zip and place it inside your foobar2000 profile folder. You should know where this is after reading the previous Setup page.

Important: If you use foo_customdb for your own purposes then you should not use the configuration folder that I supply. Instead, you'll have to edit the database entries manually. Here are the steps to follow. You should do this before continuing.


if you need them, the manual database configuration instructions are at the bottom of this page: http://marc2003.x10host.com/lastfm-playcount-sync (http://marc2003.x10host.com/lastfm-playcount-sync)



Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: firewater on 2015-01-20 18:58:29
You mean I haven't installed foo_customdb? I had it on user-components (don't know how it got there, probably came with the theme). I downloaded it again, put it on components (and deleted the one from user-components), then I pasted the configuration file on the root of foobar and retrieved the playcounts/loved tracks again, but I'm still getting nothing.

This shouldn't look like this, right? It should have the last.fm field on it...

(http://i.imgur.com/ZLvrs7u.png)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-01-20 19:53:40
Quote
then I pasted the configuration file on the root of foobar


why would you do that? the instructions say to extract the configuration folder to the foobar profile. you're the first person in 5 years to question this.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: firewater on 2015-01-20 20:51:50
Oh, yes, I already had that were it belong, I confounded the file names. So I moved stuff around and then when I opened foobar2000.exe, it crashed. I thought maybe I had fiddled too much with this one and tried an older backup I had, replacing each file were it belongs:

foo_customdb.dll and foo_customdb.txt are on components
foo_customdb.dll.cfg is on configuration
marc2003 folder is on root
wsh panel has playcount sync.txt loaded

It still crashes and it's being caused by foo_customdb.dll.cfg
http://pastebin.com/sSUuzaF6 (http://pastebin.com/sSUuzaF6)

edit: i'm gonna do a fresh install of the theme to see if i can get it to work there.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: firewater on 2015-01-20 21:56:45
i can't edit above's post anymore for some reason ???

wanted to add that i did 2 portable installs from 0, but none of them worked. by this point i'm thinking it's the library tree thing... sent you fresh install + your script installed on da so you see what i mean

assuming this is true, i wonder if the script has a way to tag this playlist info into the files? because it will certainly pick it up that way.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-01-21 18:20:39
at the moment, i can't access your file download or even pastebin (even skydrive and most image hosts are banned on my current internet - it's free so i can't complain too much. google drive is available if you have a google account). anyway, it would seem you still don't have the .cfg file i supply installed correctly.

foo_customdb is notoriously unstable with the default configuration and does crash a lot - which is exactly why i supply a pre-configured file for people to use. it has never crashed on me and i've been at this for nearly 5 years now. no one else has reported crashes either. the only component related problem that has been reported over the years is slow performance on large collections (40,000+ tracks) - but as i have nothing to do with component development, there isn't anything i can do about that.

when the .cfg file is used correctly, your foo_customdb preferences should look like this:

https://drive.google.com/file/d/0B6f0H8likO...iew?usp=sharing (https://drive.google.com/file/d/0B6f0H8likO9_em9odHVFNTFlYmM/view?usp=sharing)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: jbercx on 2015-01-21 18:24:07
Hi Marc

would it be possible to have have a small script within the wsh panel that will reflect all upcoming events in whatever country where you live, dragged out of Last.FM?
Like the url page on last.fm: http://www.last.fm/events/+place/Switzerland (http://www.last.fm/events/+place/Switzerland)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-01-21 19:19:50
it's possible but i won't be doing it. for me to make something, i generally have to be motivated by the fact it's something i'd want to use. in this case, i don't.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: jbercx on 2015-01-22 07:14:41
it's possible but i won't be doing it. for me to make something, i generally have to be motivated by the fact it's something i'd want to use. in this case, i don't.


No problem. if you could give me tip or an advise, I will do it myself

thanks!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-01-22 10:27:59
before i reply, can you tell me what you are capable of creating at the moment - without any help?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: jbercx on 2015-01-22 10:52:12
before i reply, can you tell me what you are capable of creating at the moment - without any help?


Hi Marc

I want to create an overview (depending on your location / country) regarding upcoming events (concerts).
Last FM has a url that show exactly that. I want to use that link to grab this info / copy the info in a separate panel.
Should I create a separate script / code to have it loaded into wsh? Or can this in add into an existing script?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-01-22 10:56:20
although not explicitly, i think you have answered my question. 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: jbercx on 2015-01-22 11:13:52
Meaning?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-01-22 13:44:02
get yourself an api key here: http://www.last.fm/api (http://www.last.fm/api)

here's the documentation for the events feed. you can fetch a response in XML or JSON - considerably easier than trying to parse a webpage.

http://www.last.fm/api/show/geo.getEvents (http://www.last.fm/api/show/geo.getEvents)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Odinos on 2015-01-22 16:17:46
marc, i admire your patience with all these questions haha
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-01-22 18:08:32
^i like your avatar. 

(http://www.hydrogenaud.io/forums/uploads/av-103946.jpg)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: jbercx on 2015-01-22 18:13:46
get yourself an api key here: http://www.last.fm/api (http://www.last.fm/api)

here's the documentation for the events feed. you can fetch a response in XML or JSON - considerably easier than trying to parse a webpage.

http://www.last.fm/api/show/geo.getEvents (http://www.last.fm/api/show/geo.getEvents)


thanks Marc!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: firewater on 2015-01-22 18:38:50
at the moment, i can't access your file download or even pastebin (even skydrive and most image hosts are banned on my current internet - it's free so i can't complain too much. google drive is available if you have a google account). anyway, it would seem you still don't have the .cfg file i supply installed correctly.

foo_customdb is notoriously unstable with the default configuration and does crash a lot - which is exactly why i supply a pre-configured file for people to use. it has never crashed on me and i've been at this for nearly 5 years now. no one else has reported crashes either. the only component related problem that has been reported over the years is slow performance on large collections (40,000+ tracks) - but as i have nothing to do with component development, there isn't anything i can do about that.

when the .cfg file is used correctly, your foo_customdb preferences should look like this:

https://drive.google.com/file/d/0B6f0H8likO...iew?usp=sharing (https://drive.google.com/file/d/0B6f0H8likO9_em9odHVFNTFlYmM/view?usp=sharing)


Alright, then I don't have it installed right. It's like the configs are being stored on another file other than foo_customdb.dll.cfg. It has to be something with the theme I have or maybe I'm going blind... I uploaded the default theme with your script on Google drive and sent it to you on DA.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-01-23 09:13:23
no, it is not anything to do with your theme. i downloaded your file again and all i can do is point towards my previous post again.

you haven't followed this part of the instructions:

Quote
Install the foo_customdb component and if you've never used it before then you can extract the configuration folder from playcount sync.zip and place it inside your foobar2000 profile folder. You should know where this is after reading the previous Setup page.

Important: If you use foo_customdb for your own purposes then you should not use the configuration folder that I supply. Instead, you'll have to edit the database entries manually. Here are the steps to follow. You should do this before continuing.


if you need them, the manual database configuration instructions are at the bottom of this page: http://marc2003.x10host.com/lastfm-playcount-sync (http://marc2003.x10host.com/lastfm-playcount-sync)


try holding the ctrl key and scrolling your mouse wheel up.


Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: firewater on 2015-01-24 22:12:32
What?! Really? Could you tell me exactly what I'm doing wrong? I've read that part a thousand times, and as I said on another post, all folders and files are were they belong, are they not?

Quote
foo_customdb.dll and foo_customdb.txt are on components
foo_customdb.dll.cfg is on configuration
marc2003 folder is on root
wsh panel has playcount sync.txt loaded


CustomDB is certainly installed because I can see the configuration panel on preferences. marc2003 folder works because the cript loads. The only thing missing would be the configuration not working properly? So you mean I need to do that edit the database thing?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: DustMagnet on 2015-01-25 00:48:28
^i like your avatar. 

(http://www.hydrogenaud.io/forums/uploads/av-103946.jpg)


Isn't that Steven Wilson after seeing an iPod?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-01-25 11:38:17
The only thing missing would be the configuration not working properly? So you mean I need to do that edit the database thing?


i thought this part of the instructions was clear enough? 

Quote
Important: If you use foo_customdb for your own purposes then you should not use the configuration folder that I supply. Instead, you'll have to edit the database entries manually. Here are the steps to follow. You should do this before continuing.


only you know if you used foo_customdb before! 

Quote
Install the foo_customdb component and if you've never used it before then you can extract the configuration folder from playcount sync.zip and place it inside your foobar2000 profile folder. You should know where this is after reading the previous Setup page.


if this applies to you, i supply a "clean" cfg file with everything else stripped for these reasons which i explained above...

Quote
foo_customdb is notoriously unstable with the default configuration and does crash a lot - which is exactly why i supply a pre-configured file for people to use. it has never crashed on me and i've been at this for nearly 5 years now. no one else has reported crashes either. the only component related problem that has been reported over the years is slow performance on large collections (40,000+ tracks) - but as i have nothing to do with component development, there isn't anything i can do about that.


edit
: i just realised i didn't mention foobar should be closed when you extract the configuration folder. if you didn't know about this then i do apologise. i've also updated the website page to include this.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: wallawalla on 2015-01-25 21:08:46
Hi Marc,

Thanks for sharing all these great scripts!

I've got a couple problems.

First: It might be helpful to link to your website for the most up-to-date script in the OP. Currently, it links to the depreciated common7.js.

Second: I'm getting a couple errors when trying to download my library the first time.

Last.fm Playcount Sync: JSON.parse error.
Last.fm Playcount Sync: JSON.parse error.
Last.fm Playcount Sync: HTTP error: 0
Last.fm Playcount Sync: HTTP error: 0
Last.fm Playcount Sync: HTTP error: 0
Last.fm Playcount Sync: HTTP error: 0
Last.fm Playcount Sync: HTTP error: 0
...
Last.fm Playcount Sync: HTTP error: 0 ad infinitum

The first time it happened on when parsing page 250. I exited foobar and restarted the process before it happened on page 314. Thanks again for giving so much of your time to these projects!

edit: the second time through Last.fm Playcount Sync: HTTP error: 12002 was also in there after about ten HTTP error: 0 messages
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-01-25 21:41:42
First: It might be helpful to link to your website for the most up-to-date script in the OP. Currently, it links to the depreciated common7.js.


i'm pretty sure it doesn't. both the website and link in the OP point towards the same updated file on dropbox!

as for your problem, i've looked at the last.fm status page ( http://status.last.fm (http://status.last.fm) ) and everything appears to be ok at the moment. there's not a lot else i can do apart from try your username if you want to post it.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: wallawalla on 2015-01-27 04:07:55
I think the problem might be on my end. Perhaps the network was losing it's external connection every now and then. It updated fine for me at work today.

And yes, indeed, that is the correct file on the first page. >.<

Anyway,
I really appreciate the scripts.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: WhistleChips on 2015-01-27 17:04:30
Sometime after the API Key changes recently, my last.fm playback stats have stopped working.  I am getting Console messages "HTTP error: 12031" and sometimes "HTTP error: 12029".  Looking these up, they refer to:

12029      ERROR_INTERNET_CANNOT_CONNECT
              The attempt to connect to the server failed.

12031      ERROR_INTERNET_CONNECTION_RESET
              The connection with the server has been reset.

I made sure that I have the newest common8.js and have loaded the newest scripts, "last.fm charts.txt" and "playcount sync.txt" into their respective panels.

I have reentered the last.fm user name and password for the charts panel and have verified that they are correct by logging into my last.fm account with them.

Any advise or help is appreciated.

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-01-27 17:59:53
i've often seen 12029 errors when i have no connection. but if your internet is working for everything else, i'm not really sure what it could be? perhaps some firewall blocking outgoing connections or maybe DNS issues?

it certainly doesn't have anything to do with the API key change- it's just a co-incidence you're seeing problems soon after.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: firewater on 2015-01-28 00:03:56
The only thing missing would be the configuration not working properly? So you mean I need to do that edit the database thing?


i thought this part of the instructions was clear enough? 

Quote
Important: If you use foo_customdb for your own purposes then you should not use the configuration folder that I supply. Instead, you'll have to edit the database entries manually. Here are the steps to follow. You should do this before continuing.


only you know if you used foo_customdb before! 

Quote
Install the foo_customdb component and if you've never used it before then you can extract the configuration folder from playcount sync.zip and place it inside your foobar2000 profile folder. You should know where this is after reading the previous Setup page.


if this applies to you, i supply a "clean" cfg file with everything else stripped for these reasons which i explained above...

Quote
foo_customdb is notoriously unstable with the default configuration and does crash a lot - which is exactly why i supply a pre-configured file for people to use. it has never crashed on me and i've been at this for nearly 5 years now. no one else has reported crashes either. the only component related problem that has been reported over the years is slow performance on large collections (40,000+ tracks) - but as i have nothing to do with component development, there isn't anything i can do about that.


edit
: i just realised i didn't mention foobar should be closed when you extract the configuration folder. if you didn't know about this then i do apologise. i've also updated the website page to include this.


Yes!!! Finally!!! I had to close foobar for the configuration file to work. Does everybody know about this? How is it possible that no one has had this problem before for you to include it on the page? In any way, thanks!

If you could look into the star thing I talked to you about on the other thread (http://www.hydrogenaud.io/forums/index.php?s=&showtopic=77883&view=findpost&p=887329) one of these days then my issues with the player would be finished.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-01-28 10:18:20
If you could look into the star thing I talked to you about on the other thread (http://www.hydrogenaud.io/forums/index.php?s=&showtopic=77883&view=findpost&p=887329) one of these days then my issues with the player would be finished.


i must admit, i completely forgot about that.  i'l look into it later on today.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Odinos on 2015-01-30 13:51:59
^i like your avatar. 


haha thanks.

theres one track in my library that just wont sync. the scrobbles do get through to lastfm.
Code: [Select]
Last.fm Playcount Sync: {"error":6,"message":"Artist not found","links":[]}

The artist name is "DJ B.Boy & Puto Márcio", maybe the & confuses the api? I have other artists with an & that work fine though
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-01-30 14:31:41
i've seen this before. they treat á and Á as completely different. you can hack around it by right clicking your panel and selecting artist field remapping. replace the default with this:

Code: [Select]
$if($strcmp(%artist%,DJ B.Boy & Puto Márcio),$upper(%artist%),%artist%)

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Odinos on 2015-02-02 17:45:48
Code: [Select]
$if($strcmp(%artist%,DJ B.Boy & Puto Márcio),$upper(%artist%),%artist%)

thanks, that worked
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-02-06 12:37:48
if anyone uses falstaff/br3tt's new JSplaylist, i've made a mod that lets you display and love/unlove tracks on last.fm directly from the playlist.

pre-requisites:
you have fully installed and configured the actual playcount sync script from the first post in this thread. it needs to be active in your layout to "listen" for mouse clicks from the playlist.
you have installed JSplaylist version 1.1.1 or above (the requirements may change if the script gets updated and those details will be posted below)

http://www.deviantart.com/art/JSPlaylist-509803158 (http://www.deviantart.com/art/JSPlaylist-509803158)

make sure you follow all instructions and make sure you install the required fonts.

with foobar closed, browse your foobar profile folder\wsh_br3tt\jsplaylist\js and save this file to that location.

http://marc2003.x10host.com/WSHplaylist.js (http://marc2003.x10host.com/WSHplaylist.js)

lastly, you need to edit the built in "Mood" column that is in the layout. you may rename it but the most important part is that you change the title formatting to this.

Code: [Select]
[%LASTFM_LOVED_DB%]


you may also add your own "Plays" column with this

Code: [Select]
[%LASTFM_PLAYCOUNT_DB%]


if/when falstaff makes updates to his code, make sure you follow his update instructions fully and i'll be posting an updated file as soon as i can.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: firewater on 2015-02-06 21:27:17
have you ever considering adding a feature that fetches album name too? i have a lot of repeated songs from bootlegs, compilations and EPs that are different from the ones i've actually heard yet it displays it as 23 because i've played it a lot on the album version.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-02-06 21:41:08
this has been requested numerous times and i would consider it but it's simply not possible. last.fm only separate tracks by artist/title when it comes to fetching play counts back via their webservices.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: firewater on 2015-02-07 00:07:50
aaaah, what a shame, thanks for considering it though.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Majestic12 on 2015-02-14 00:29:15
Is it possible to count the playback stats for an artist or an album not only for a specific track?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-02-14 09:31:45
not with this script.

you could try this separate script which displays your last.fm artist/album/track stats for a few selected time periods like last 7 days, 1 month, 3month, overall etc....

http://marc2003.x10host.com/lastfm-charts (http://marc2003.x10host.com/lastfm-charts)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: firewater on 2015-02-15 07:29:12
Hey there again. I don't know what happened, but most playcounts aren't beng displaying now. Only very few tracks have them, and they seem to be totally random. I'm displaying them with $if2(%lastfm_playcount_db%,)... tried bringing them back with the heart (auto-correct disabled, just like in my profile), but nothing changed (I even didn't get the close foobar message at the end, in case that's weird).
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-02-15 09:11:30
what does the console report? that always has something to say.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ALuserX on 2015-02-15 23:59:11
Hello marc2003,

I've been using your awesome script for years now, but recently (I'm not sure when exactly though) I began experiencing API errors, so I thought, well maybe it's time to update the script. So I clicked on "Update script" and got an error "Last.fm Playcount Sync: HTTP error: 12029". So I thought, ok, maybe my script is old enough for updates not to work, so I googled the latest version of the script and tried to "update", I got a newer foo_customdb.dll, new marc2003 folder and a new script, restarted foobar, updated the script and had to reenter my Last.fm username & password. After that I still got the big red X, saying "User the right click to enter Last.fm password". So now every time I try to enter my password I get "Last.fm Playcount Sync: HTTP error: 12031". And "Update Script" still gets me a 12029.

As far as I understand both 12029 and 12031 would mean that I am not connected to the internets, but I surely am, because if I wasn't I wouldn't be able to write this.

Do you or anyone elso have any ideas what I could do to get the script working again?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: firewater on 2015-02-16 01:06:36
i don't remember anything unusual. i'm 99% sure it said that it succeeded. i removed the panel to reinstall it again one of these days and see how that works.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-02-16 10:06:49
As far as I understand both 12029 and 12031 would mean that I am not connected to the internets, but I surely am, because if I wasn't I wouldn't be able to write this.


can you access this page in internet explorer?

https://ws.audioscrobbler.com/2.0/ (https://ws.audioscrobbler.com/2.0/)

even if you normally use another browser, you need to use IE to test.

@firewater, well see how you get on. i can only help if you're more specific with the details.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ALuserX on 2015-02-16 12:16:02
can you access this page in internet explorer?

https://ws.audioscrobbler.com/2.0/ (https://ws.audioscrobbler.com/2.0/)

even if you normally use another browser, you need to use IE to test.


Nope, I can't. My IE isn't in english so I can't simply copy/paste, but it shows one of these default "page unavailable" things.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-02-16 12:22:36
well it looks like you have some kind of proxy/firewall that is blocking access to last.fm? or maybe a DNS issue? if you open a command prompt, do you get any result for this command.

Code: [Select]
nslookup ws.audioscrobbler.com


also, are you on some kind of managed network or is it your home connection?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ALuserX on 2015-02-16 12:37:08
That's my home connection.

> nslookup ws.audioscrobbler.com
Server:  ### - My Router Pseudo Domain
Address:  192.168.1.1

Name:    ws.audioscrobbler.com
Address:  195.24.233.55

I have tried disabling firewall yesterday before writing the first post, so it shouldn't be a firewall problem.
Last.fm actually works, I can for example Right Click -> Last.FM -> Last.FM Love Track ... in foobar and it works, and if I type 195.24.233.55 in IE it also redirects to last.fm without problems, so it souldn't be a dns problem either.

I think it may be a problem with https because https://www.last.fm/ (https://www.last.fm/) shows exactly the same error page in IE. On the other hand, https://google.com/ (https://google.com/) doesn't show me that error.

Well anyways, it seems to be my problem and not a problem of your script, so it probably would be better not to discuss it here.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-02-16 12:47:12
i'd have a look at the proxy settings in the internet explorer options then??

the last.fm command you're using on the context menu is provided by foo_softplaylists and that probably uses the foobar network settings found in the main preferences.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ALuserX on 2015-02-16 13:48:46
Nope, proxy setting are fine and empty.
I actually asked around other people from all around the world to try and 4 of 4 guys coudn't open https://ws.audioscrobbler.com/2.0/ (https://ws.audioscrobbler.com/2.0/) .
http://SSMaker.ru/1a606b11/ (http://SSMaker.ru/1a606b11/) one of them even made a screenshot.

So it seems to be a last.fm issue in the end, isn't it?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-02-16 14:37:22
i just realised that page is not good to test with. it works on the connection i was using earlier but now i'm somewhere else, i get the same 400 bad request error - however, my last.fm script is still working here.

stick this in a fresh panel and it should open a proper page on the webservices using https.

Code: [Select]
// ==PREPROCESSOR==
// @import "%fb2k_profile_path%marc2003\common8.js"
// ==/PREPROCESSOR==

var p = new panel("test");
var l = new lastfm();
var artist = "Katy Perry";

p.run("iexplore https://ws.audioscrobbler.com/2.0/?api_key=" + l.api_key + "&method=artist.getSimilar&artist=" + encodeURIComponent(artist));
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ALuserX on 2015-02-16 15:09:55
It opens IE with the same goddamn error. However if I copy the same link to Firefox it gives me a proper XML response.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-02-16 15:21:40
i just noticed you mentioned the "Update script" feature not working either. that actually fetches this file over https as well. i bet it works in firefox but not IE.

https://dl.dropboxusercontent.com/u/2280132...2003/common8.js (https://dl.dropboxusercontent.com/u/22801321/wsh/marc2003/common8.js)

it looks like you have https issues i can't help you with.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ALuserX on 2015-02-16 15:35:25
Yep, it works in FF but not in IE. Strange thing is that all the other people I asked had the same stupid https issues.

Well, thanks for trying anyways. I'll let you people know if I get it fixed.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ALuserX on 2015-02-16 17:15:33
Me again! It seems I got it to work!

First I added https://ws.audioscrobbler.com/ (https://ws.audioscrobbler.com/) and https://dl.dropboxusercontent.com/ (https://dl.dropboxusercontent.com/) to IE white-list. It seems it did nothing.
Next I turned on TLS 1.0 in Advanced IE settings. It seems it did nothing.
Lastly I checked my PC's local time and it seemed to be a couple of seconds in the future! I ran NTP sync and voila now your script works! I could enter my password and auth with last.fm successfully! Loving/unloving tracks works too and playcounts are now updatet as they should.

However if I uncheck TLS 1.0 or remove ws.audioscrobbler from white-list it doesn't work anymore even if the time is right.

And if I try to "Update script" via context-menu I now get this: Last.fm Playcount Sync: HTTP error: -2146869244 . Well, whatever, at least everything else seems to work.

One more thing I wanted to ask. The Heart-pic is now way too large and is cut in half. In the old version I used I remember there was an option to change the image, or the image size, i can't remember the exact wording. But now even if I replace this big image with the old one it's upscaled. is there a way to make it smaller?

(http://aluserex.vshost.ru/last-fm-heart.jpg)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-02-16 18:02:52
read the text at the start of the panel??

Code: [Select]
//function takes 3 values: x, y, size. see on_size function if you want to update these relative to panel width/height
var ps = new playcount_sync(3, 0, 32);
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ALuserX on 2015-02-16 18:26:59
read the text at the start of the panel??

Code: [Select]
//function takes 3 values: x, y, size. see on_size function if you want to update these relative to panel width/height
var ps = new playcount_sync(3, 0, 32);



Sorry, didn't read the script, thought it would be changeable via context-menu. Many thanks for your support, you're awesome.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-02-16 18:57:31
i hope you figured out how to get rid of that white background in your screenshot. you can use the menu for that.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ALuserX on 2015-02-16 21:03:50
Yep, I saw the setting, but prefer it that way though. Thanks.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: firewater on 2015-02-18 01:10:33
Damn it, it doesn't work!!!

Quote
Last.fm Playcount Sync: Playcount: completed page 180 of 180
Last.fm Playcount Sync: There were no errors reported.

Using %lastfm_playcount_db% to display it on JSPlaylist... get mostly ? and then sometimes one track shows amount, but pretty much almost none of them do...

More info:
+ I pressed Update Script and got "Download succesful. Restart foobar now?" even though I just installed it again with the latest version (and again, no blue command prompt appeared??? I removed the following files to reinstall: marc2003 folder, foo_customdb.dll, WSH data folder, WSH settings folder.
+ Loving a track still works.
+ I tried field mapping to %artist% and %album artist%
+ Console displays fine alll the way through (http://i.imgur.com/vX2Cnm6.png)[/s]

I have two Foobar folders (one is a backup, as I'm always changing stuff and messing it up) and on the backup one I tried to fetch playcounts one more time just to see if it worked there for some magical reason even though it's the same install and when the console finishes reporting I get the blue command prompt asking to close foobar!!! And now it works!!! So my guess is, I mistakenly updated the panel on the backup instead of my regular foobar and that's why it didn't get fixed with the reinstall... have no idea what caused it though.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-02-18 04:39:37
with 2 installs, you can copy the file named customdb_sqlite.db from folder to folder (while foobar is closed). obviously only one of them will get updated as you listen so it's up to you to keep them in sync.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: firewater on 2015-02-18 08:11:57
!!! I wondered about that file, I didn't know if it was part of this panel or not. Thanks.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: acmodeu on 2015-02-18 15:16:02
Today I have accidentally found out the following lines in console:

Code: [Select]
Last.fm Playcount Sync: Contacting Last.fm.... 
Last.fm Playcount Sync: {"error":26,"message":"Suspended API key - Access for your account has been suspended, please contact Last.fm","links":[]}

What could possibly go wrong? And what should I do about it? I tried re-getting the key but the problem still persists.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-02-18 15:30:38
right click the icon and select Configure. if the 2nd line of code matches this...

Code: [Select]
// @import "%fb2k_profile_path%marc2003\common8.js"


then simply close the dialog, right click the panel and Update script.

if that line references common7 (or earlier) then you need to download this zip file...

https://dl.dropboxusercontent.com/u/2280132...ount%20sync.zip (https://dl.dropboxusercontent.com/u/22801321/wsh/playcount%20sync.zip)

extract the marc2003 folder into your profile and overwrite any files if prompted. then copy the text from the playcount sync.txt file into your panel. you will need to configure your username and preferences again.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: acmodeu on 2015-02-18 16:01:01
Thank you, mark2003. You've just saved my day!
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Odinos on 2015-02-26 17:56:02
hi marc, is there a way to love a track with a global shortcut? sometimes im listening to music while gaming and then i dont want to alt-tab to love a song. thanks
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-02-26 19:09:07
it's not possible with any script - the panel has to have focus for keyboard shortcuts to work.

you'd have to use the foo_softplaylists component to do that. you can set up global shortcuts through the main foobar preferences. to keep the local database up to date, you could bind another keyboard shortcut to the Customdb Love 1 action found on the context menu under Legacy Commands (unsorted). that's 2 key presses but it's the only way.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Odinos on 2015-02-26 21:18:08
it's not possible with any script - the panel has to have focus for keyboard shortcuts to work.

you'd have to use the foo_softplaylists component to do that. you can set up global shortcuts through the main foobar preferences. to keep the local database up to date, you could bind another keyboard shortcut to the Customdb Love 1 action found on the context menu under Legacy Commands (unsorted). that's 2 key presses but it's the only way.

thanks a lot! i configured autohotkey to press the shortcuts in succession =D
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Odinos on 2015-02-27 16:00:18
hmm i realised i was wasting shortcuts the way i described above so im trying to do it with the command line. i cant figure out for the life of me why this isnt working
Code: [Select]
C:\Program Files (x86)\foobar2000\foobar2000.exe /playing_command:Customdb Love 1

it just tries playing a track called "love" and "1". i guess it has to do with the spaces in the command but ive tried every combination of quotation marks but to no avail
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Odinos on 2015-02-27 16:12:43
okay i got it to work. if anyone else wants to achieve this: you will need foo_runcmd, foo_softplaylists, autohotkey and marcs script ofcourse
this is the autohotkey script (in my case the shortcut is bound to right control and L)
Code: [Select]
Rcontrol & l::
Run, C:\Program Files (x86)\foobar2000\foobar2000.exe /runcmd-playing="Legacy Commands (unsorted)/Customdb Love 1"
Run, C:\Program Files (x86)\foobar2000\foobar2000.exe /runcmd-playing="Last.fm/Last.fm Love Track"
return

(sorry marc for spamming your thread)
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: systemlayers on 2015-02-28 03:08:53
Is it supposed to be possible to create an autoplaylist? I'm able to create one and use it while foobar2000 runs but Foobar crashes immediately upon startup unless i delete the offending autoplaylist.
Was hoping to catch files that were played on last.fm but not in playcount with "((%LASTFM_PLAYCOUNT_DB% GREATER 0) AND NOT (%play_count% GREATER 0))"

Love the plugin anyways.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-02-28 10:15:57
autoplaylists should be possible but it seems foo_customdb chokes on larger collections. someone else has reported this just in the last few days. and because it's a component problem, unfortunately there isn't anything i can do about it. i'm currently trying to test what the cut-off point is before it falls over so at least i can put a warning in the instructions.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: systemlayers on 2015-02-28 15:54:16
That would make sense. My collection is rather large at 83579 tracks over 1.24TB.
I'll copy my portable foobar application and see where the breaking point might be by including fewer and fewer folders.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-02-28 17:45:37
any information you could provide on this would be great. i'm not really able to test myself as i have such a tiny collection. i suppose i could create a library of dummy files but real world is always better.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Odinos on 2015-02-28 18:21:32
Is it supposed to be possible to create an autoplaylist? I'm able to create one and use it while foobar2000 runs but Foobar crashes immediately upon startup unless i delete the offending autoplaylist.
Was hoping to catch files that were played on last.fm but not in playcount with "((%LASTFM_PLAYCOUNT_DB% GREATER 0) AND NOT (%play_count% GREATER 0))"

Love the plugin anyways.

i think that tracks without any lastfm plays do not have a %LASTFM_PLAYCOUNT_DB% entry yet. so it cant be compared with 0. filter for tracks that have a %LASTFM_PLAYCOUNT_DB% at all.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: systemlayers on 2015-02-28 19:14:34
any information you could provide on this would be great. i'm not really able to test myself as i have such a tiny collection. i suppose i could create a library of dummy files but real world is always better.


I should note I am using Foobar 1.36
I went down in increments of about 5,000 tracks each (my folders are organized by letter - ie. [A],,[C] -  so I just started deleting each one).
From 83579 to 60,000 and every time I tried to create an autoplaylist it would crash.
From 60,000 to 40,000 I could create an autoplaylist but on startup it would crash and I'd have to delete the playlist file and reset the index file.
I didn't manage to add an autoplaylist and then restart successfully until 33678 files.

I had the same crash error as trebordean. Obvious that custom_db was just choking.

Now I do use dyn_fil and that does add a little bit extra to startup time and I do have a LOT of autoplaylists so that can't help.

However I did see in the other thread that trebordean reverted to Foobar 1.29 so i thought I'd rescan my full library and try. Lo and behold.. Foobar2000 starts MUCH quicker and even creating the autoplaylist was MUCH quicker.
Restart was fine and all 83579 files were able to be processed with the autoplaylist. Reverting to 1.29 did break my foo_discogs and foo_verifier components.

This must (mostly) have to do with custom_db not being updated in a while and having some problem with the newer foobar2000. I'm going to keep my main config at 1.37 and just forgo having autoplaylists.. kind of isn't the best solution but ah well.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-02-28 21:00:47
some good info there, thanks. i'll try and replicate the issue with some dummy files. it would nice to confirm that anything under 30k is fine. i'll update my webpage before the weekend is over.

i don't know what it is about foobar v1.3 and above that causes issues. i know there were changed to how it caches metadata for library/playlist but i always thought it was related to oversize fields.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: systemlayers on 2015-02-28 22:15:54
Hmm I think I may have to stop using your plugin with my large collection unfortunately - or give up on a couple other components and go back to 1.29. I left my computer running with the playlist (not auto) generated from my 1.29 portable foobar copy of my main 1.36 portable install (the one with tracks played on last.fm but not played in my library) - so that I could get my playback stats perfect.
I've found the easiest way to fake playcounts with foo_playcount is to use foo_preview (set to 1:01) and that was my main reason for creating the autoplaylist (sometimes foobar crashes and I lose my foo_playcount stats).

And well I came back to custom_db having the same fit as when I add or startup with an autoplaylist. Crashed on me after several hours of just playback. 

So it seems that with a large collection (30,000+tracks) on 1.3+ even just simple playback is enough to crash Foobar.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-02-28 23:23:55
i could provide a version that avoids using foo_customdb but it would mean writing to file tags instead - there are limitations on that such as no support for cuesheets, streams, untaggable formats, etc.

also, it can't support the library import* but the background playcount updates and loving/unloving tracks would be full functional. it's not an approach i like because of the modificiation of file timestamps and how it affects backups but i could add it without too much hassle.

*but you can transfer existing foo_customdb data to file tags easily enough.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Odinos on 2015-03-10 16:12:32
Playcount sync is not working due to suspended API key again. but this time updating the script doesnt work either:
Code: [Select]
Last.fm Playcount Sync: <!DOCTYPE html>
<html>
<head><title>Dropbox - 404</title>
<link href="//www.dropbox.com/static/css/error.css" rel="stylesheet" type="text/css"/>
<link rel="shortcut icon" href="//www.dropbox.com/static/images/favicon.ico"/>
</head>
<body>
<div class="figure">
<img src="//www.dropbox.com/static/images/psychobox.png" alt="Error: 404"/>
</div>
<div id="errorbox">
<h1>Error (404)</h1>We can't find the page you're looking for. Check out our <a href="https://www.dropbox.com/help">Help Center</a> and <a href="https://forums.dropbox.com">forums</a> for help, or head back to <a href="https://www.dropbox.com/home">home</a>.
</div>

</body>
</html>
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: acmodeu on 2015-03-10 16:20:23
I've faced the same problem today in the middle of the playing. The tracks were syncing and suddenly they stopped. Is it time to update scripts once again?
Some debug info if needed:
Code: [Select]
// ==PREPROCESSOR==
// @import "%fb2k_profile_path%marc2003\common8.js"
// @name "Last.fm Playcount Sync"
// @author "marc2003"
// @feature "v1.4"
// @feature "watch-metadb"
// ==/PREPROCESSOR==


Today I have accidentally found out the following lines in console:

Code: [Select]
Last.fm Playcount Sync: Contacting Last.fm.... 
Last.fm Playcount Sync: {"error":26,"message":"Suspended API key - Access for your account has been suspended, please contact Last.fm","links":[]}

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Odinos on 2015-03-10 16:24:34
follow these instructions (http://www.hydrogenaud.io/forums/index.php?s=&showtopic=76772&view=findpost&p=887354) to fix the syncing problem. apparently marcs dropbox is also not reachable so updating isnt possible atm
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: bulletproof2k on 2015-03-10 20:12:28
follow these instructions (http://www.hydrogenaud.io/forums/index.php?s=&showtopic=76772&view=findpost&p=887354) to fix the syncing problem. apparently marcs dropbox is also not reachable so updating isnt possible atm

Scripting Engine Initialization Failed (Last.fm Playcount Sync by marc2003, CODE: 0x80020101)
Check the console for more information (Always caused by unexcepted script error).
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: bulletproof2k on 2015-03-10 20:19:29
I have an api account, but I need to create it again?
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: acmodeu on 2015-03-10 21:15:32
Thanks, Odinos, that worked for me.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: bulletproof2k on 2015-03-10 23:23:42
I fixed it.
In my last update script common8.js
other line numbers:
1820
1821

Thanks 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-03-11 06:55:37
i'm no longer providing or supporting my scripts so i'd like to request that this thread is locked. the last few posts contain enough information for people to fix their own scripts should they wish.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Kohlrabi on 2015-03-11 09:54:25
marc2003, others might want to pick up where you left off. I don't think closing this thread is necessary or helpful. If you insist we will remove any code posted here by you, since from my understanding you still own said code. Using the code snippets without permission from marc2003 may or may not be illegal depending on your country's laws.

Though I still hope that the recent issues here on HA can be alleviated somehow.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Odinos on 2015-03-11 11:52:50
i'm no longer providing or supporting my scripts so i'd like to request that this thread is locked. the last few posts contain enough information for people to fix their own scripts should they wish.

marc please dont let 1 guy ruin it for everyone. youre the greatest thing that happened to foobar since musicmusic. your support is invalueable
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: ALuserX on 2015-03-11 12:30:44
i'm no longer providing or supporting my scripts so i'd like to request that this thread is locked. the last few posts contain enough information for people to fix their own scripts should they wish.

marc please dont let 1 guy ruin it for everyone. youre the greatest thing that happened to foobar since musicmusic. your support is invalueable

I second that.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: systemlayers on 2015-03-11 13:06:08
I have to agree Marc. Your support around here is second to none, you're in almost every thread helping out to an amazing degree. I hope you reconsider.
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: marc2003 on 2015-03-11 13:49:33
marc2003, others might want to pick up where you left off. I don't think closing this thread is necessary or helpful


i'd like to cite this from a thread in 2009. at the time tedgo was one of the most helpful forum members.

http://www.hydrogenaud.io/forums/index.php...st&p=666702 (http://www.hydrogenaud.io/forums/index.php?s=&showtopic=69046&view=findpost&p=666702)

Quote
tedgo, this skin recommends components that are problematic, which is against the rules. Here is the troubleshooter entry for DarkOne. Please fix this and verify your future skin versions using the Online Troubleshooter.


Quote
as problematic, although there are no problems with their settings made in DarkOne or they're updated to the latest version, its not possible to change DarkOne without destroying it completely (especially caused by PSS the configuration is based on).
So i decided to stop supporting DarkOne here on HA and request you to close this topic.
Thanks


Quote
Closed at author's request.


since this script also relies on known problematic components (foo_customdb), it should also be closed.

thanks.

Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: bulletproof2k on 2015-03-11 15:17:52
Too bad that you close the project, most users do not want this. 
Title: HOW TO: synchronise your last.fm playback stats with foobar
Post by: Kohlrabi on 2015-03-11 15:50:56
since this script also relies on known problematic components (foo_customdb), it should also be closed.
Fine.