INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: updating playstats from last.fm to mc  (Read 1464 times)

robydago

  • Citizen of the Universe
  • *****
  • Posts: 518
updating playstats from last.fm to mc
« on: January 03, 2009, 10:10:00 am »

Hi,
is it possible to sync playstats (number plays and last played) from last.fm to MC?

Since my portable media player (Nokia E71) can't sync playstats with MC I was wondering if this setup is possible:

NokiaE71  ->  last.fm  ->  MC

I can do the E71 to last.fm part, but what about last.fm to MC? I know I can submit played tracks from MC to last.fm but I need the other way around.

Ciao.




Logged

robydago

  • Citizen of the Universe
  • *****
  • Posts: 518
Re: updating playstats from last.fm to mc
« Reply #1 on: January 04, 2009, 09:28:40 am »

Still wondering if a last.fm to MC sync plugin is possible....

If it is, it could be a way to sync playstats back to MC for all players (portable or not) that can submit played tracks to last.fm


I checked the last.fm APIs and maybe it could be done, but with one big limitation:

- must be run frequently: this is because last.fm APIs don't return more than the last 100 tracks played; thus, if with a non MC player you play 140 tracks before synching playstats from last.fm to MC, you can't sync the 40 older plays from last.fm into MC.

and one small limitation:

- I think you need one dedicated last.fm account for all non-MC players you want to use and sync back to MC (atr least one for all of them), different form the one used with MC last.fm JR plugin: this is to avoid a loop where MC played tracks go to last.fm, via the JR provided plugin, and bounce back via this plugin and so on. Keeping in mind the 100 limit (see above) it coud be better to setup an account for each player you want to use in this way.


These are my thoughts on what such a plug-in could do to try to accomplish the result of getting last.fm stats synched to MC


0) This must be done manually: create a new last.fm account dedicated to your non-MC player, but don't use it with JR provided MC last.fm plugin. In MC this new last.fm account will be used only by the "last.fm to MC sync" plugin


Now to what the "last.fm to MC sync" plugin will do:

1) at startup check registry (or wherever plugin settings will be saved) for "last processed date" data (at first run it will be empty)


2) from last.fm via its API, get latest 100 (100 is a limit set by last.fm) tracks played by your non-MC player (plugin is querying the last.fm account dedicated to this player)
(e.g.: http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=rj&limit=0&api_key=b25b959554ed76058ac220b7b2e0a026)
   So you get, for each played track an XML output with this structure for each track (non relevant fields not shown):

    <track>
      <artist>[artistvalue]</artist>
      <name>[namevalue]</name>
      <album>[albumvalue]</album>
       <date>[datevalue]</date>
    </track>


3) parse the XML output got from previous step and discard all <track> nodes containing a <date> older than "last processed date" (at first run nothing will be discarded)

 
4) reparse the reduced (actually reduced only if anything was discared in step 3) xml output and create a new XML structure by grouping entries by identical artist\name\album values and adding all dates they were played at, The new XML nodes for each track could be something like this:


    <track artist=[artistvalue] name=[namevalue] album=[albumvalue]>
      <alldates>
         <date>[datevalue]</date>
         <date>[datevalue]</date>
                ...
      </alldates>
    </track>


5) parse the new XML data  got from previous step and, for each <track>, perform a lookup in MC (using MC API - must match all Artist, Name and Album); if track exists in MC:
(note: if MC lookup returns more than one match, prompt user to choose the correct one before continuing)
   
   a) in MC, read the Last Played tag

   b) in the new xml data, count only <date> entries that are more recent than the Last Played value in MC and
          I.  add the resulting value in MC, to the current Number Plays tag

   e) in the new xml data, read the more recent <date> entry and
          I.   set the same value in MC, to the Last Played tag
          II.  set the same value in the registry  (it will be the "last processed date" checked at startup)



Maybe it works...


If using an handheld device managed via MC, to avoid more than one match in step 5, maybe MC lookup could be limited to content of the playlists set to be synched with handheld in MC.

Ciao!
Logged
Pages: [1]   Go Up