IPB

Welcome Guest ( Log In | Register )

42 Pages V   1 2 3 > »   
Reply to this topicStart new topic
HOW TO: synchronise your last.fm playback stats with foobar, ...works with CUI and DUI
marc2003
post Dec 7 2009, 14:47
Post #1





Group: Members
Posts: 4577
Joined: 27-January 05
From: England
Member No.: 19379



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
%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
changelog: https://dl.dropboxusercontent.com/u/2280132...e/changelog.txt

updated 30/04/13: no longer requires foo_softplaylists meaning artist field remapping is supported for loving tracks and background updates.

This post has been edited by db1989: May 2 2013, 12:03
Reason for edit: updated by request
Go to the top of the page
+Quote Post
bob12
post Dec 7 2009, 16:01
Post #2





Group: Members
Posts: 4
Joined: 9-March 07
Member No.: 41338



This is amazing. Thank you.
Go to the top of the page
+Quote Post
dreadroach
post Dec 7 2009, 16:13
Post #3





Group: Members
Posts: 64
Joined: 27-January 09
From: Croatia
Member No.: 66144



Works like a charm, thank you. smile.gif


--------------------
Disregard the constabulary.
Go to the top of the page
+Quote Post
dreadroach
post Dec 7 2009, 17:07
Post #4





Group: Members
Posts: 64
Joined: 27-January 09
From: Croatia
Member No.: 66144



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?


--------------------
Disregard the constabulary.
Go to the top of the page
+Quote Post
marc2003
post Dec 7 2009, 17:32
Post #5





Group: Members
Posts: 4577
Joined: 27-January 05
From: England
Member No.: 19379



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
[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>
<userplaycount>7</userplaycount> <userloved>0</userloved>
<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
fb.trace("Status: " + xmlhttp.statustext);


add this as the next line directly after it.

CODE
fb.trace(xmlhttp.responsetext);


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

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. tongue.gif

the quickest way to update your files using this would be stop playback. highlight a track, right click button, "sync now". repeat until bored.

This post has been edited by marc2003: Dec 7 2009, 17:55
Go to the top of the page
+Quote Post
marc2003
post Dec 8 2009, 10:54
Post #6





Group: Members
Posts: 4577
Joined: 27-January 05
From: England
Member No.: 19379



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.

This post has been edited by marc2003: Dec 8 2009, 10:55
Go to the top of the page
+Quote Post
dreadroach
post Dec 8 2009, 11:47
Post #7





Group: Members
Posts: 64
Joined: 27-January 09
From: Croatia
Member No.: 66144



Thanks for new version. smile.gif Anyway, i fixed my "error", everything works perfect now..it was so stupid that i don't even want to mention it blink.gif


--------------------
Disregard the constabulary.
Go to the top of the page
+Quote Post
marc2003
post Dec 8 2009, 12:33
Post #8





Group: Members
Posts: 4577
Joined: 27-January 05
From: England
Member No.: 19379



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. biggrin.gif

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

Go to the top of the page
+Quote Post
carmenm
post Dec 8 2009, 14:43
Post #9





Group: Members
Posts: 720
Joined: 24-November 05
From: Grenoble
Member No.: 25981



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
Go to the top of the page
+Quote Post
marc2003
post Dec 8 2009, 15:00
Post #10





Group: Members
Posts: 4577
Joined: 27-January 05
From: England
Member No.: 19379



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.

This post has been edited by marc2003: Dec 8 2009, 15:16
Go to the top of the page
+Quote Post
carmenm
post Dec 8 2009, 15:27
Post #11





Group: Members
Posts: 720
Joined: 24-November 05
From: Grenoble
Member No.: 25981



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
Go to the top of the page
+Quote Post
marc2003
post Dec 8 2009, 15:38
Post #12





Group: Members
Posts: 4577
Joined: 27-January 05
From: England
Member No.: 19379



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

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


This post has been edited by marc2003: Dec 8 2009, 16:08
Go to the top of the page
+Quote Post
T.P Wang
post Dec 8 2009, 15:55
Post #13





Group: Developer
Posts: 486
Joined: 8-June 07
From: Chengdu
Member No.: 44175



@marc2003:
I think it's better to use something like this:
CODE
...
// or %_path_raw%
case (g_metadb.RawPath.indexOf("mms://") == 0):
...

Go to the top of the page
+Quote Post
marc2003
post Dec 8 2009, 16:07
Post #14





Group: Members
Posts: 4577
Joined: 27-January 05
From: England
Member No.: 19379



thanks. post above edited to reflect changes.
Go to the top of the page
+Quote Post
carmenm
post Dec 8 2009, 16:32
Post #15





Group: Members
Posts: 720
Joined: 24-November 05
From: Grenoble
Member No.: 25981



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?

This post has been edited by carmenm: Dec 8 2009, 17:09
Go to the top of the page
+Quote Post
marc2003
post Dec 8 2009, 20:24
Post #16





Group: Members
Posts: 4577
Joined: 27-January 05
From: England
Member No.: 19379



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. laugh.gif
Go to the top of the page
+Quote Post
marc2003
post Dec 8 2009, 22:48
Post #17





Group: Members
Posts: 4577
Joined: 27-January 05
From: England
Member No.: 19379



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.
Go to the top of the page
+Quote Post
Fractal_Mortalit...
post Dec 9 2009, 00:19
Post #18





Group: Members
Posts: 374
Joined: 20-June 05
Member No.: 22863



edit: nevermind, the default works happy.gif

This post has been edited by Fractal_Mortality: Dec 9 2009, 00:48


--------------------
http://www.last.fm/user/magnumforce2006
Go to the top of the page
+Quote Post
Fractal_Mortalit...
post Dec 9 2009, 00:46
Post #19





Group: Members
Posts: 374
Joined: 20-June 05
Member No.: 22863



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


--------------------
http://www.last.fm/user/magnumforce2006
Go to the top of the page
+Quote Post
marc2003
post Dec 9 2009, 00:53
Post #20





Group: Members
Posts: 4577
Joined: 27-January 05
From: England
Member No.: 19379



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.

This post has been edited by marc2003: Dec 9 2009, 01:02
Go to the top of the page
+Quote Post
Fractal_Mortalit...
post Dec 9 2009, 01:20
Post #21





Group: Members
Posts: 374
Joined: 20-June 05
Member No.: 22863



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.


--------------------
http://www.last.fm/user/magnumforce2006
Go to the top of the page
+Quote Post
marc2003
post Dec 9 2009, 01:45
Post #22





Group: Members
Posts: 4577
Joined: 27-January 05
From: England
Member No.: 19379



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.

This post has been edited by marc2003: Dec 9 2009, 01:47
Go to the top of the page
+Quote Post
Fractal_Mortalit...
post Dec 9 2009, 02:04
Post #23





Group: Members
Posts: 374
Joined: 20-June 05
Member No.: 22863



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.


--------------------
http://www.last.fm/user/magnumforce2006
Go to the top of the page
+Quote Post
marc2003
post Dec 9 2009, 02:24
Post #24





Group: Members
Posts: 4577
Joined: 27-January 05
From: England
Member No.: 19379



there is also the last.fm TOS to consider. i've just added this information to the readme as well.

QUOTE (http://www.last.fm/api/tos)
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.
Go to the top of the page
+Quote Post
Fractal_Mortalit...
post Dec 9 2009, 04:28
Post #25





Group: Members
Posts: 374
Joined: 20-June 05
Member No.: 22863



QUOTE (marc2003 @ Dec 8 2009, 20:24) *
there is also the last.fm TOS to consider. i've just added this information to the readme as well.

QUOTE (http://www.last.fm/api/tos)
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).


--------------------
http://www.last.fm/user/magnumforce2006
Go to the top of the page
+Quote Post

42 Pages V   1 2 3 > » 
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 20th October 2014 - 10:50