Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: HOW TO: synchronise your last.fm playback stats with foobar (Read 386297 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

HOW TO: synchronise your last.fm playback stats with foobar

Reply #375
marc2003 thanks for script
can you fix "do not hide legacy commands (unsorted)" or this is customdb plugin problem?

HOW TO: synchronise your last.fm playback stats with foobar

Reply #376
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.

HOW TO: synchronise your last.fm playback stats with foobar

Reply #377
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.

HOW TO: synchronise your last.fm playback stats with foobar

Reply #378
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.

 

HOW TO: synchronise your last.fm playback stats with foobar

Reply #379
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).

HOW TO: synchronise your last.fm playback stats with foobar

Reply #380
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?

HOW TO: synchronise your last.fm playback stats with foobar

Reply #381
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.

HOW TO: synchronise your last.fm playback stats with foobar

Reply #382
last.fm gives the time of the 1st scrobble of the song now, so can this be embedded in the script too?

HOW TO: synchronise your last.fm playback stats with foobar

Reply #383
@acmodeu, only the website shows the first played date for tracks. this information isn't available via the last.fm API.


HOW TO: synchronise your last.fm playback stats with foobar

Reply #385
depending on how many plays you have for an artist, you could end up parsing 100+ pages which is totally unworkable.

HOW TO: synchronise your last.fm playback stats with foobar

Reply #386
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...

HOW TO: synchronise your last.fm playback stats with foobar

Reply #387
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..

HOW TO: synchronise your last.fm playback stats with foobar

Reply #388
Hi,
I'm having a problem.

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.

HOW TO: synchronise your last.fm playback stats with foobar

Reply #389
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)

HOW TO: synchronise your last.fm playback stats with foobar

Reply #390
Ok, I got it.
But what can I do with this data, now?
Can I sort this or create autoplaylists?

HOW TO: synchronise your last.fm playback stats with foobar

Reply #391
I can confirm the same probs like demauvaisgout ( http://www.hydrogenaudio.org/forums/index....st&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?!

HOW TO: synchronise your last.fm playback stats with foobar

Reply #392
@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.

HOW TO: synchronise your last.fm playback stats with foobar

Reply #393
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.

HOW TO: synchronise your last.fm playback stats with foobar

Reply #394
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
and something here:
http://stackoverflow.com/questions/872206/...n-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...

HOW TO: synchronise your last.fm playback stats with foobar

Reply #395
hmm, i guess my script isn't very robust, expecting a 200 repsonse code otherwise it craps out. 

thanks for the links.

HOW TO: synchronise your last.fm playback stats with foobar

Reply #396
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.



HOW TO: synchronise your last.fm playback stats with foobar

Reply #397
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


HOW TO: synchronise your last.fm playback stats with foobar

Reply #399
^ see this post...

http://www.hydrogenaudio.org/forums/index....st&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)