The following code could be used to read information from the database of a running Rhapsody server. It uses the 2.x SQLite API from http://www.sqlite.org.

By querying the database every 10 seconds or so (and keeping track of when the database was last queried), a scrobbler could submit any track that has been played within the last interval.

#include <cstdlib>
#include <cstdio>
#include "sqlite.h"

int Callback(void *pArg, int argc, char **argv, char **columnNames)
{
  int i;
  for (i = 0; i < argc; ++i)
  {
    if (argv[i] != 0)
    {
      printf("%s: %s\n", columnNames[i], argv[i]);
    }
    else
    {
      //      printf("%s: NULL in database.\n", columnNames[i]);
    }
  }

  return 0;
}

int main(void)
{
  char *errMsg;
  sqlite *db = sqlite_open("local.seb", 0, &errMsg);

  if (db == NULL)
  {
    printf("%s\n", errMsg);
    free(errMsg);
  }
  else
  {
    if (sqlite_exec(db, 
                    "select track.artist_name, track.album_name, track.track_name, track.track_duration, track.last_played from track join playlist_track on (track.track_id = playlist_track.track_id and playlist_id=1);",
                    Callback, NULL, &errMsg) != 0)
    {
      printf("%s\n", errMsg);
      free(errMsg);
    }

    sqlite_close(db);
  }

  return 0;
}