Skip to main content

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

0 Members and 1 Guest are viewing this topic.
  • marc2003
  • [*][*][*][*][*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #725
so you haven't actually ran the import then? 

and try and please be more accurate with your reporting so i don't have to guess. you mention "0" in a previous post but it will never show that - entries without playcounts are blank. also, it's worth checking the foobar console found on the main view menu for messages.
  • Last Edit: 09 August, 2012, 08:07:20 AM by marc2003

HOW TO: synchronise your last.fm playback stats with foobar
Reply #726
I did run the import, as mentioned I tried several times with no different results. Everything seemed to work fine while doing the import, but the play counts still didn't update.

Yeah, sorry about that, they're blank. I imported again with the same result, but when starting Foobar again, I found this in the console:

Custom Database: Initialize
Custom Database: table quicktag already exists (1)
Custom Database: table database_version already exists (1)
Custom Database: index url_idx already exists (1)
Custom Database: Completed
WSH Panel Mod (Last.fm Playcount Sync by marc2003): initialized in 104 ms

Could this be related to the problem? Also, I should maybe mention that the first time I ran the import I forgot to close foobar for that last screen, could that have caused problems even after doing it again, correctly?
  • Last Edit: 10 August, 2012, 08:51:39 AM by tyblazitar

  • marc2003
  • [*][*][*][*][*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #727
so long as you imported it once correctly with foobar closed, it really shouldn't matter if it wasn't done properly before.

a few things to look at....

-can you check File>preferences>tools>custom database and then the database tab? the entries should probably be in the thousands depending on how many tracks you have.

-assuming the tracks are monitored as part of your foobar libraryuse the Library>search menu and enter this as the query...

%LASTFM_PLAYCOUNT_DB% PRESENT

are you getting numbers somewhere near the entries value? (it won't match if you have loved tracks because that would be part of the entries total)

if all this shows up ok then right click a track in the search window and select properties and then the properties tab. there should be a custom database section showing totals. if values appear here but not in your playlist then something is wrong with your playlist view???




HOW TO: synchronise your last.fm playback stats with foobar
Reply #728
It says there are 3884 entries in the database, which is a lot less than the number of tracks I have (and have listened to at least once), and a lot more than the number of tracks that currently show up with a play count. A library search shows that the playcount is present in 4130 tracks, so yeah, pretty close. I haven't loved any tracks though.

When checking the Properties - Properties tab, the tracks that won't display play count doesn't have a Custom Database section, so it doesn't seem to be a playlist view problem.
  • Last Edit: 11 August, 2012, 08:54:00 AM by tyblazitar

  • marc2003
  • [*][*][*][*][*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #729
assuming you use the same username here as you do on last.fm, i can see that account has 12490 different tracks in the library. if that is you then the import hasn't completed properly. try again and when the blue window pops up, check the foobar console for errors before closing it.

it shouldn't make any difference but you could start afresh by deleting the file named customdb_sqlite.db in your foobar profile folder while foobar is closed and before starting the import.
  • Last Edit: 13 August, 2012, 08:25:11 AM by marc2003

HOW TO: synchronise your last.fm playback stats with foobar
Reply #730
That's my account, yeah. I tried importing again after deleting the customdb_sqlite.db file, and it still doesn't work. The console said:

Completed page 125 of 125 (playcount)
Loved track page errors: 1 (200 records are lost for every page that fails.)
Playcount page errors: 0 (100 records are lost for every page that fails.)
Individual errors: 0

EDIT: Fixed my problem by copying over the db file from my laptop, so now I have my playcounts back at least. Still no idea what caused it though.
  • Last Edit: 13 August, 2012, 10:30:15 AM by tyblazitar

  • dumdidum
  • [*][*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #731
finally got around to playing with this. works like a charm, thanks a lot


  • tagged
  • [*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #732
Works perfectly. Thanks!

  • BrutuZ
  • [*][*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #733
Bumped into a small issue here.
If I have a track with multiple artists split in the tag %artist%, but scrobble and love this track with only the first artist (so that Last.fm won't tell me the artist is invalid or whatever) the script won't set the loved status on the DB.

For example: This song (Helena Noguerra - Fly Me To The Moon (∞ Climax Mix) is loved on Last.fm, however the file's %artist% tag value is Helena Noguerra; Hiroshi Yamaguchi (note the semicolon splitting the multiple values) and since the names don't match the %LASTFM_LOVED_DB% isn't set correctly.
Any ideas on how to circumvent this?
  • Last Edit: 29 August, 2012, 07:09:40 PM by BrutuZ

  • marc2003
  • [*][*][*][*][*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #734
file>preferences>tools>custom database>fields tab

edit both custom entries...

Code: [Select]
$crc32($lower(%artist%%title%))


should become

Code: [Select]
$crc32($lower($meta(artist,0)%title%))


RESTART foobar now. foo_customdb is buggy if these changes are made without immediately restarting

now inside the panel for the script....

line 95 should become

Code: [Select]
artist = fb.TitleFormat("$meta(artist,0)").EvalWithMetadb(g_metadb);


line 100 should become

Code: [Select]
crc32 = fb.TitleFormat("$crc32($lower($meta(artist,0)%title%))").EvalWithMetadb(g_metadb);


i think that should do it.

  • BrutuZ
  • [*][*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #735
Thanks marc, I must be using quite an old version of the script because both the database and script code itself are significantly different. The lines you mentioned are around 50 here instead of 100, and the customdb values were different with LOVED_DB not using the crc32 function.

Anyway, I edited the corresponding settings and hopefully it'll work now, thanks again

  • sevenarts
  • [*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #736
Thanks for this script, it's great! I've got it working nicely and set it up so that when I rate a track 5, it's automatically loved. I also added a statement so that when a track that is currently loved is no longer rated 5, it gets unloved, both at last.fm and in the customdb.

The next step I can't quite figure out though: if I love a track from some other method besides rating it 5, I want to automatically update the rating (which is the rating field from Playback Statistics, not a tag).

Also, I know this was in previous versions of the script, and I'd love it if the "sync now" context menu option was restored. I know, I can just play the track for a few seconds but it's even more convenient to just click a menu command or, better yet, hit a shortcut key.


  • sevenarts
  • [*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #737
Sorry, one more question:

Is there some reason the auto-correct feature can't work on library import? I noticed that all tracks that were auto-corrected by last.fm were not updated on import, but will only update if I play them after the import. I have an annoying number of these and it would be nice if importing the library performed the auto-correct searches.

  • gob
  • [*][*][*][*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #738
I understand that solution allows you to import your playback stats from last.fm into foobar2000, but is there a way to do this in reverse? My last fm stats have not been updated in over two years, so I'd like to basically overwrite them with my stats from foobar2000. Is this at all possible, even outside the scope of your solution here?

  • marc2003
  • [*][*][*][*][*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #739
as far as i know, last.fm only supports importing into new accounts when using their official client app with itunes, WMP or winamp.

  • Zageron
  • [*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #740
foo_softplaylists: feed downloading: error
foo_softplaylists: failed to unlove track: authentication failed: empty reply
foo_softplaylists: failed to unlove track '[insert track here]' by '[artist]'

This is all I get when I try to use the un-love function. I have used this functionality successfully in the past, but for the last few weeks I haven't been able to.


My password in soft playlists was incorrect. What a tool.
  • Last Edit: 13 September, 2012, 12:18:51 PM by Zageron

  • BrutuZ
  • [*][*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #741
as far as i know, last.fm only supports importing into new accounts when using their official client app with itunes, WMP or winamp.

That and mobile devices. For instance, I use Pocket Player on my Windows Mobile Pro 6.1 phone (a Samsung Omnia i900), and even though it is a third party software, it has it's own plugin that caches the played tracks and scrobble all of them when the phone connects to the internet with the player running.
Pretty much the same functionality foo_audioscrobbler has, caching played tracks and scrobbling when possible.

I don't think you could "cheat" the system to accept 2 whole years worth of scrobbles though.

  • error
  • [*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #742


is it normal for this to happen? i tried to update my plays count so i deleted my old customdb_sqlite.db then i right clicked >library import > create and import sql file but this has been happening for a long time now

i mainly did this because i had a problem where i would play a song and it would update to 1 play fine but when i played it again it wouldnt update at all why could that be?

  • error
  • [*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #743
actually nevermind i got it fixed^^^

i would edit the post but i cant see/find the edit button

HOW TO: synchronise your last.fm playback stats with foobar
Reply #744
Hey dude, I bought a new computer and decided to update to the latest version, it works fantastically well! I just have one suggestion that you can think about: For songs under 30 seconds, since last.fm doesn't keep track of those (which is laaaaaame), how about locally adding +1 to the LASTFM_PLAYCOUNT_DB, when they're done playing? I know you can't do anything about last.fm's stupid 30 second or less thing, but that way at least the playcount increases on new plays, so I don't get a playlist in which some tracks have 0 plays while everything else has 10+. It's not a big deal I guess but it would be neat!
  • Last Edit: 18 November, 2012, 01:22:16 AM by スラッシュ

  • protospork
  • [*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #745
Every time I try to do a full library import, the script crashes after getting one page of loved tracks.

Code: [Select]
Last.fm Playcount Sync: Completed page 1 of 2 (loved tracks) 
Error: WSH Panel Mod (Last.fm Playcount Sync by marc2003): Microsoft JScript runtime error:
'page' is undefined
File: M:\foobar2000\marc2003\common6.js
Ln: 2116, Col: 4
<source text only available at compile time>


Since I only have 253 loved tracks, I "fixed" it by changing
Code: [Select]
"&method=user.getlovedtracks&limit=200&page="

on line 2079 to
Code: [Select]
"&method=user.getlovedtracks&limit=260&page="


Just thought you should know about the issue.

  • marc2003
  • [*][*][*][*][*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #746
thanks for spotting that. here's the proper fix.

line 2116

Code: [Select]
this.sync_loved(page);


should be

Code: [Select]
this.sync_loved(this.page);


now it should work regardless of how many results there are. i've updated the file hosted file as well. just the file common6.js inside the marc2003 folder needs extracting again and the panel needs to be reloaded to pick up the change if foobar is running.

edit: i did do major background updates about a week ago without announcing it so anyone using my script from before then won't have this problem. if people do update to this from the older version, they need to update the script in the panel as well.
  • Last Edit: 26 November, 2012, 05:24:36 AM by marc2003

  • ehrgeiz
  • [*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #747
since i got fed up with the trackdetail panel from columnsUI i tried to write my own on top of marcs scripts.
i guess it's written in a horrible way but it works for me  thx for all the stuff to play with!




ah and i have one feature request for the 'now playing' script! it would be awesome if it could remember
which artist picture it was set too and not always return to the first one in the folder. writing a new config
file in the wsh_lastfm folder would be the way to go i think?

Code: [Select]
// ==PREPROCESSOR==
// @import "%fb2k_profile_path%marc2003\common6.js"
// @name "Trackdetails"
// @author "ehrgeiz dabbling on top of marc2003 scripts"
// @feature "v1.4"
// @feature "watch-metadb"
// ==/PREPROCESSOR==


//first argument is any arbitrary text to name the panel. it will use in the console and popup boxes.
//seconds argument is an array of features. it's mostly for handling right click menus.
var p = new panel("Track Details", ["remap"]);
//force the panel to always prefer the playing track regardless of selection
p.selection_mode = 1;

// adding some modified textfunction from common6.js since id dont like DT_VCENTER
p.right_text_ml = function(gr, text, font, colour, x, y, w, h) {
gr.GdiDrawText(text, font, colour, x, y, w, h, DT_RIGHT | DT_END_ELLIPSIS | DT_CALCRECT | DT_NOPREFIX);
}

//setup all metadata fields you want to display. if you change the font sizes, adjustments may need
//to be made to the positions in the on_paint function
var genre = {text: "", tf: "$if(%genre%,$lower(%genre%),[no genre set]$crlf())", font: gdi.Font("Segoe UI", 18, 1), colour: RGB(180, 180, 180)}
var style = {text: "", tf: "$if(%style%,$lower(%style%),)", font: gdi.Font("Segoe UI", 14, 2), colour: RGB(180, 180, 180)}

var comp_b = {text: "", tf: "$if(%composer%,composer,)", font: gdi.Font("Segoe UI", 10, 0), colour: RGB(180, 180, 180)}
var comp_c = {text: "", tf: "$if(%composer%,$meta_num(composer),)"}
var compo = {text: "", tf: "$if(%composer%,$meta_sep(composer,$crlf()),)", font: gdi.Font("Segoe UI", 10, 1), colour: RGB(180, 180, 180)}

var lyri_b = {text: "", tf: "$if(%lyricist%,lyricist,)", font: gdi.Font("Segoe UI", 10, 0), colour: RGB(180, 180, 180)}
var lyri_c = {text: "", tf: "$if(%lyricist%,$meta_num(lyricist),)"}
var lyric = {text: "", tf: "$if(%lyricist%,$meta_sep(lyricist,$crlf()),)", font: gdi.Font("Segoe UI", 10, 1), colour: RGB(180, 180, 180)}

var cond_b = {text: "", tf: "$if(%conductor%,conducter,)", font: gdi.Font("Segoe UI", 10, 0), colour: RGB(180, 180, 180)}
var cond_c = {text: "", tf: "$if(%conductor%,$meta_num(conductor),)"}
var condu = {text: "", tf: "$if(%conductor%,$meta_sep(conductor,$crlf()),)", font: gdi.Font("Segoe UI", 10, 1), colour: RGB(180, 180, 180)}

var perf_b = {text: "", tf: "$if(%performer%,performer,)", font: gdi.Font("Segoe UI", 10, 0), colour: RGB(180, 180, 180)}
var perf_c = {text: "", tf: "$if(%performer%,$meta_num(performer),)"}
var perfo = {text: "", tf: "$if(%performer%,$meta_sep(performer,$crlf()),)", font: gdi.Font("Segoe UI", 10, 1), colour: RGB(180, 180, 180)}

var engi_b = {text: "", tf: "$if(%engineer%,engineer,)", font: gdi.Font("Segoe UI", 10, 0), colour: RGB(180, 180, 180)}
var engi_c = {text: "", tf: "$if(%engineer%,$meta_num(engineer),)"}
var engin = {text: "", tf: "$if(%engineer%,$meta_sep(engineer,$crlf()),)", font: gdi.Font("Segoe UI", 10, 1), colour: RGB(180, 180, 180)}

var staf_b = {text: "", tf: "$if(%involvedpeople%,staff,)", font: gdi.Font("Segoe UI", 10, 0), colour: RGB(180, 180, 180)}
var staf_c = {text: "", tf: "$if(%involvedpeople%,$meta_num(involvedpeople),)"}
var staff = {text: "", tf: "$if(%involvedpeople%,$meta_sep(involvedpeople,$crlf()),)", font: gdi.Font("Segoe UI", 10, 1), colour: RGB(180, 180, 180)}

var publ_b = {text: "", tf: "$if(%publisher%,released by,)", font: gdi.Font("Segoe UI", 10, 0), colour: RGB(180, 180, 180)}
var publi = {text: "", tf: "$if(%publisher%,%publisher%,)$crlf()$if(%ORIGINAL RELEASE DATE%, $if($strcmp(%date%,%ORIGINAL RELEASE DATE%), ©$char(8471) %date%, © %date% $char(8471) %ORIGINAL RELEASE DATE% ), © %date%)", font: gdi.Font("Segoe UI", 10, 0), colour: RGB(180, 180, 180)}

var playc = {text: "", tf: "$if(%LASTFM_PLAYCOUNT_DB%,Track played$ifequal(%LASTFM_PLAYCOUNT_DB%,1, only once,$ifequal(%LASTFM_PLAYCOUNT_DB%,2, twice, %LASTFM_PLAYCOUNT_DB% times)),no plays)", font: gdi.Font("Segoe UI", 10, 0), colour: RGB(180, 180, 180)}

var dbtxt = {text: "", tf: "", font: gdi.Font("Segoe UI", 10, 0), colour: RGB(0, 0, 0)}

//startup
on_item_focus_change();

function on_size() {
//always call p.size to update the values of p.w and p.h
p.size();
}

function on_paint(gr) {
   //setup a variable for y-offset
   var cr = 40;
   //setup a variable for lineheight
   var lh = 12;
   //var debugvar = cond_c.text;
   //p.draw_background(gr);
   //background for trackdetails
gr.FillSolidRect(0, 0, p.w, p.h - 15, RGBA(0, 0, 0, 156));
//draw trackdetails
   //genre+style
   p.right_text(gr, genre.text, genre.font, genre.colour, 5, 4, p.w - 10, 18);
   p.right_text_ml(gr, style.text, style.font, style.colour, 5, 16, p.w - 10, 20);
   //composer
   if (comp_b.text.length != 0) {   
       p.left_text(gr, comp_b.text, comp_b.font, comp_b.colour, 5, cr, p.w - 10, 12);
       p.right_text_ml(gr, compo.text, compo.font, compo.colour, 5, cr += 10, p.w - 10, p.h - cr - 45);
       cr = cr + lh * comp_c.text;
   }
   //lyricist
   if (lyri_b.text.length != 0) {
       p.left_text(gr, lyri_b.text, lyri_b.font, lyri_b.colour, 5, cr, p.w - 10, 12);
       p.right_text_ml(gr, lyric.text, lyric.font, lyric.colour, 5, cr += 10, p.w - 10, p.h - cr - 45);
       cr = cr + lh * lyri_c.text;
   }
   //conductor
   if (cond_b.text.length != 0) {
       p.left_text(gr, cond_b.text, cond_b.font, cond_b.colour, 5, cr, p.w - 10, 12);
       p.right_text_ml(gr, condu.text, condu.font, condu.colour, 5, cr += 10, p.w - 10, p.h - cr - 45);
       cr = cr + lh * cond_c.text;
   }
   //performer
   if (perf_b.text.length != 0) {
       p.left_text(gr, perf_b.text, perf_b.font, perf_b.colour, 5, cr, p.w - 10, 12);
       p.right_text_ml(gr, perfo.text, perfo.font, perfo.colour, 5, cr += 10, p.w - 10, p.h - cr - 45);
       cr = cr + lh * perf_c.text;
   }
   //engineer
   if (engi_b.text.length != 0) {
       p.left_text(gr, engi_b.text, engi_b.font, engi_b.colour, 5, cr, p.w - 10, 12);
       p.right_text_ml(gr, engin.text, engin.font, engin.colour, 5, cr += 10, p.w - 10, p.h - cr - 45);
       cr = cr + lh * engi_c.text;
   }
   //involved people
   if (staf_b.text.length != 0) {
       p.left_text(gr, staf_b.text, staf_b.font, staf_b.colour, 5, cr, p.w - 10, 12);
       p.right_text_ml(gr, staff.text, staff.font, staff.colour, 5, cr += 10, p.w - 10, p.h - cr - 45);
       cr = cr + lh * staf_c.text;
   }
   //publisher/label
   //p.left_text(gr, publ_b.text, publ_b.font, publ_b.colour, 5, cr, p.w - 10, 12);
   p.right_text(gr, publi.text, publi.font, publi.colour, 5, p.h - 35, p.w - 10, 12);
   //lastfm.playcount
   //first draw background
   gr.FillSolidRect(0, p.h - 15, p.w, 15, RGBA(0, 0, 0, 116));
   p.centre_text(gr, playc.text, playc.font, playc.colour, 5, p.h - 14, p.w, 12);
//debug
   //gr.FillSolidRect(0, 0, 60, lh * perf_c.text, RGBA(255, 0, 0, 236));
   //p.left_text(gr, debugvar, dbtxt.font, dbtxt.colour, 0, 0, 60, 12);
}

function on_metadb_changed() {
//call these functions when selection changes/tag updates are made
if (p.metadb) {
       genre.text = p.eval(genre.tf);
       style.text = p.eval(style.tf);
      
       comp_b.text = p.eval(comp_b.tf);
       comp_c.text = p.eval(comp_c.tf);
       compo.text = p.eval(compo.tf);
      
       lyri_b.text = p.eval(lyri_b.tf);
       lyri_c.text = p.eval(lyri_c.tf);
       lyric.text = p.eval(lyric.tf);
      
       cond_b.text = p.eval(cond_b.tf);
       cond_c.text = p.eval(cond_c.tf);
       condu.text = p.eval(condu.tf);
      
       perf_b.text = p.eval(perf_b.tf);
       perf_c.text = p.eval(perf_c.tf);
       perfo.text = p.eval(perfo.tf);
      
       engi_b.text = p.eval(engi_b.tf);
       engi_c.text = p.eval(engi_c.tf);
       engin.text = p.eval(engin.tf);
      
       staf_b.text = p.eval(staf_b.tf);
       staf_c.text = p.eval(staf_c.tf);
       staff.text = p.eval(staff.tf);
      
       publ_b.text = p.eval(publ_b.tf);
       //publ_c.text = p.eval(publ_c.tf);
       publi.text = p.eval(publi.tf);
      
       playc.text = p.eval(playc.tf);
}
window.Repaint();
}

function on_playback_stop() {
on_item_focus_change();
// b.update();
}

function on_mouse_wheel(step) {
//scroll text
//if (t.wheel(step)) return;
//this scrolls through multiple images
//im.wheel(step);
}

function on_mouse_move(x, y) {
//we only need to call p.move if there elements in our panel which require scrollling as i need to track where the mouse is. do not return after it.
p.move(x, y);
}

function on_mouse_rbtn_up(x, y) {
//handles right click menu.
p.rbtn_up(x, y);
return true;
}
  • Last Edit: 27 November, 2012, 05:15:34 PM by ehrgeiz

  • error
  • [*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #748
Why do i get this

Code: [Select]
Error: WSH Panel Mod (Last.fm Playcount Sync by marc2003): Parsing file "C:\Users\nand\Desktop\foobar2000\marc2003\common4.js": Failed to load
WSH Panel Mod (Last.fm Playcount Sync by marc2003): Parsing file "C:\Users\nand\Desktop\foobar2000\marc2003\tooltip_buttons.js"
Error: WSH Panel Mod (Last.fm Playcount Sync by marc2003): Microsoft JScript runtime error:
'settings_path' is undefined
File: <main>
Ln: 16, Col: 1
<source text only available at compile time>

i'm adding it to a panel stack splitter and everything is upto date

  • marc2003
  • [*][*][*][*][*]
HOW TO: synchronise your last.fm playback stats with foobar
Reply #749
Quote
Error: WSH Panel Mod (Last.fm Playcount Sync by marc2003): Parsing file "C:\Users\nand\Desktop\foobar2000\marc2003\common4.js": Failed to load


the bit in bold means the file is not there meaning the files were not extracted correctly. also you're using a slightly outdated version. i recommend using the latest.

http://dl.dropbox.com/u/22801321/playcount%20sync.zip