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 383408 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

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

Reply #925
you can request your entire scrobbling history on this page....

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.


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

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

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

Reply #927
Whoa... I requested mine also!

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

Reply #928
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 (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

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:


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

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

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

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

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

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



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

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

Reply #932
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
link to script: https://dl.dropboxusercontent.com/u/2280132...port/export.txt

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

Reply #933
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:



Of course the "first played" and DADA score calculation columns are just there for testing purposes. But yeah, it works!

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

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

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

Reply #935
If the tracks have been played all the way the playcount component should tag them by default regardless of their length.

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

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



@?????, 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.

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

Reply #937
I see, wasn't paying attention, my bad.

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

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

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

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

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

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


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

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

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

Reply #942
Thank you Marc!

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

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

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

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

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

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

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

Reply #946
read my post again. where does it say anything about editing the script? 

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

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

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

Reply #948
what you're asking isn't possible. either play the track or run the full import on a regular basis.

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

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