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 383461 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 #175
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.

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

Reply #176
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!

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

Reply #177
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%]

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

Reply #178
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%],)

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

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

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

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

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

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

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

Reply #182
@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

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

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.

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

Reply #183
Yep. thought so. Thanks anyway.

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

Reply #184
New version uploaded

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.

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

Reply #185
good update!
any other changes?

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

Reply #186
no 

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

Reply #187
Fantastic! It really works (on DUI also)! Thank you so much!

And is it posible to remove track from "loved" (last fm db)?
🇺🇦 Glory to Ukraine!

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

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

hover over the tracks and you'll see a drop down arrow which you can click to "unlove".

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

Reply #189
@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

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

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

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

Reply #190
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; }
:)

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

Reply #191
Thank you marc2003 for this plugin & for your personal help with wsh scripts.

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

Reply #192
Though I did everything as was written in the manual and get "Playcount sync: Contacting Last.fm....

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

Reply #193
Looks like internet connection problem.
Check your firewall settings
🇺🇦 Glory to Ukraine!

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

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

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

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

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

Reply #196
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; }

🇺🇦 Glory to Ukraine!

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

Reply #197
@acmodeu, does your "legacy commands (unsorted)" context menu look like this?

screenshot

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);
}

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

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

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

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