Skip to main content

Topic: HOW TO: synchronise your last.fm playback stats with foobar (Read 268485 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • carmenm
  • [*][*][*][*][*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #50
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!

  • marc2003
  • [*][*][*][*][*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #51
- 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.
  • Last Edit: 11 December, 2009, 12:32:59 PM by marc2003

  • marc2003
  • [*][*][*][*][*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #52
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

(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.


  • loft
  • [*][*][*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #53
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!

HOW TO: synchronise your last.fm playback stats with foobar
Reply #54
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.

HOW TO: synchronise your last.fm playback stats with foobar
Reply #55
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
  • Last Edit: 14 December, 2009, 11:12:14 AM by jimbothigpen

  • carmenm
  • [*][*][*][*][*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #56
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
  • Last Edit: 14 December, 2009, 11:55:13 AM by carmenm

  • marc2003
  • [*][*][*][*][*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #57
@ 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.

HOW TO: synchronise your last.fm playback stats with foobar
Reply #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 -- 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

  • marc2003
  • [*][*][*][*][*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #59
replace

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


with

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



HOW TO: synchronise your last.fm playback stats with foobar
Reply #60
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

  • marc2003
  • [*][*][*][*][*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #61
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);
}


HOW TO: synchronise your last.fm playback stats with foobar
Reply #62
thanks so much to both marc2003 and carmenm!
--jimbothigpen

  • carmenm
  • [*][*][*][*][*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #63
Thanks for helping marc2003.

HOW TO: synchronise your last.fm playback stats with foobar
Reply #64
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!
  • Last Edit: 15 December, 2009, 05:36:09 AM by スラッシュ

  • marc2003
  • [*][*][*][*][*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #65
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)
  • Last Edit: 15 December, 2009, 07:39:55 AM by marc2003

HOW TO: synchronise your last.fm playback stats with foobar
Reply #66
Brilliant, works a charm. Thanks again!
  • Last Edit: 15 December, 2009, 07:41:57 AM by スラッシュ

  • marc2003
  • [*][*][*][*][*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #67
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

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.
  • Last Edit: 15 December, 2009, 02:41:56 PM by marc2003

HOW TO: synchronise your last.fm playback stats with foobar
Reply #68
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.

  • marc2003
  • [*][*][*][*][*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #69
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.
  • Last Edit: 16 December, 2009, 09:38:13 PM by marc2003

HOW TO: synchronise your last.fm playback stats with foobar
Reply #70
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), 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)

  • marc2003
  • [*][*][*][*][*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #71
it would seem that is exclusive to their own web pages. they don't publish that info in the web services.

HOW TO: synchronise your last.fm playback stats with foobar
Reply #72
Yeah, I was afraid of that. It's a shame they keep a lot of info to themselves. Thanks for checking

  • rafib
  • [*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #73
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


  • marc2003
  • [*][*][*][*][*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #74
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.