Your Digital Media Has Never Looked So Good

 
davos119
Topic Author
Posts: 19
Joined: Tue Oct 04, 2005 3:40 pm

Play Count Updater

Wed Apr 02, 2008 2:50 am

I'm desperately trying to get hold of a copy of 'Play Count Updater' - see

http://forums.rokulabs.com/viewtopic.php?t=6274&highlight=play+count+updater

The website is now offline - is there anyone out there using it, who'd be willing and able to send it to me?

Filing that, does anyone know of something that does a similar job? I want to be able to update the 'last played' field as well as the 'play count' field in the iTunes library.

I've downloaded ibridge, but I can't get that to work - and in any case, I think that only updates the playcount anyway...?

I've also tried mcfh's program (http://www.tagsoft.co.uk/index.asp?page=/Soundbridge.asp&menu=SBMenu.asp), but for some reason, that crashes windows explorer.

Any help much appreciated, thanks.
 
YourMum
Posts: 215
Joined: Tue May 03, 2005 3:58 am
Location: Watford, UK
Contact:

Mon Sep 15, 2008 6:57 am

Hi. I wrote RIC, and I've had some hosting issues lately.

I will try and get it back up somewhere soon... if you are really desperate, please PM me and I can email you the ZIP...

Cheers!
YourMum
---
Have you tried the Roku / iTunes Track Counter?
 
YourMum
Posts: 215
Joined: Tue May 03, 2005 3:58 am
Location: Watford, UK
Contact:

RIC's back!

Tue Sep 23, 2008 2:11 pm

Hi folks!

After a long time absent, I have managed to get my website back online! Hurrah :)

Anyway, if you are interested in the Roku iTunes Track Counter (or RIC for short), then, go here:
http://www.over2u.net/foghorn/RokuTrackCounter.html

And in case you wondered, it works with iTunes v8 :P

Have fun!
YourMum

---

Have you tried the Roku / iTunes Track Counter?
 
cakes
Posts: 23
Joined: Sun Dec 16, 2007 3:02 am
Location: Belgium

Sun Sep 28, 2008 1:25 pm

Thanks, works like a charm !

if now only someone could be so ingenious to find a way to also update the songrating... (on a pinnacle; in some post i read it should be possible on a roku)
Server: WXP-SP2 PC with Firefly and GBPVR (tv, video,...)
Clients:
1x soundbridge homemusic
2x Hauppauge media MVP
 
zedug
Posts: 9
Joined: Wed May 09, 2007 9:10 am
Location: San Jose, CA

Sun Oct 12, 2008 1:34 pm

Works like a charm indeed.... many thanks !

Now just one thing and it would be absolute heaven :

My Roku is streaming from a Firefly installation running on an NLSU2. The whole point being that my computer is not on at all times (shocking! :)) and I do not want it to be, so songs are served from the Slug that's sitting in the living room. I do refresh Firefly with iTunes Library.xml at least once a week so they are in sync.

However I would still love it if the Play counters from the SoundBridge could be updated whenever I turn the PC on, that is, if there was a way to have RIC run on the Slug and store the play info, dumping it to iTunes whenever possible...

Does it make sense ?

Thanks again for the great app.
 
YourMum
Posts: 215
Joined: Tue May 03, 2005 3:58 am
Location: Watford, UK
Contact:

Thu Oct 16, 2008 1:45 pm

Hi zedug,

Sorry, I have no idea how to write an app for a slug... The theory is fairly straightforward though:
1. keep a record of what has been playing on the slug (or other NAS)
2. synchronise this with a PC on a regular basis - prolly by running a process on the PC on startup or at a regular/scheduled time

Maybe someone with the right knowledge can do this... I'd be happy to give assistance from the PC side if that's what's needed.
YourMum

---

Have you tried the Roku / iTunes Track Counter?
 
zedug
Posts: 9
Joined: Wed May 09, 2007 9:10 am
Location: San Jose, CA

Sat Nov 29, 2008 5:37 pm

So I finally took the time to try and do something about this.

Thanks to YourMum's suggestion (I just love writing this), I went ahead and made use of the log file that Firefly can generate. You should configure the debug level so that the log file contains the filename of the songs it streams to the Roku. I'm using Debug Level 5.

I wrote a javascript (I'm on a WinXP machine) that reads the log file, and tries to determine which song was played based on song title, track number, and filename. When there is a match I update the playcounter and the playeddate accordingly.

I am going to run this script on a regular basis so that my XP iTunes installation is aware of what was played on the Roku in the living room, probably using the Task Scheduler.

I am by no means a great coder so I'm sure the script below is not perfect. I was lazy and hardcoded a few things. However it is moderately commented. Oh and performance (meaning speed) is terrible but function matters most for me.

Usual caveats - I tested this for a few days at home but make no claims and will not be held responsible if your computer catches fire or a plane engine crashes on your roof :)



/* 
    File: UpdateTrackLog.js

    Take mtdaapd.log and update the PlayCount/LastPlayTime accordingly
     
    Version: 1.0

*/


var   ITTrackKindFile   = 1;
var   iTunesApp = WScript.CreateObject("iTunes.Application");
var   mainLibrary = iTunesApp.LibraryPlaylist;
var   tracks = mainLibrary.Tracks;
var   i;
var   numScanned = 0;
var   numUpdated = 0;
var   numLogLine = 0;
var   verbose = true;

objFSO = WScript.CreateObject("Scripting.FileSystemObject");

// Open the log file
objTextFile = objFSO.OpenTextFile("Z:\\mt-daapd.log", 1);
objLogFile  = objFSO.CreateTextFile("D:\\My Documents\\My Music\\iTunes\\messages.log", true);

while (objTextFile.AtEndOfStream == 0)
{
   
   // read line
   strLine = objTextFile.Readline();
   numLogLine++;

   // split timestamp and msg
   strSplitLog = strLine.split("): ");
   strTimeStamp = strSplitLog[0];
   strMessage = strSplitLog[1];
   
   if ((strTimeStamp == null) || (strMessage == null))
   {
      if (verbose)
         objLogFile.WriteLine ("LOG: Cannot split timestamp/message on line " + numLogLine);
   }
   else
   {
      strDate = strTimeStamp.substr(0, 10);
      strTime = strTimeStamp.substr(11, 8);
      
      // does the Message contain "Session 0: Streaming file " ???
      re = /Session 0: Streaming file '/
      numMatches = 0;
   
   
      if (strMessage.search(re) == 0)
      {
   
         // OK this line matches our pattern now let's get the file name between quotes
         if (verbose)
            objLogFile.WriteLine ("LOG: Found song on line " + numLogLine + " : \"" + strMessage + "\"");
        
         numScanned++;
         strSongFileName = strMessage.substring(27, strMessage.indexOf(".mp3'") );
         strSplitFileName = strSongFileName.split(" - ");
         strSongNumber = strSplitFileName[0];
         strSongTitle = strSplitFileName[1];
         if (verbose)
            objLogFile.WriteLine ("LOG: song is \"" + strSongTitle + "\" and track number is " + strSongNumber);
   
         // now search the song in iTunes with IITPlaylist::Search
         // hardcoded 5 is for search in title
         if (strSongTitle == null)
         {
            objLogFile.WriteLine ("LOG: cannot determine title and/or track number - exiting");
            splayList = null;
         }
         else
            splayList = mainLibrary.search(strSongTitle, 5);
   
   
         if (splayList == null)
         {
            numHits = 0;
            if (verbose)
               objLogFile.WriteLine ("ITUNES: \"" + strSongTitle + "\" " + "not found");
         }
         else
         {
            numHits = splayList.Count;
            if (verbose)
               objLogFile.WriteLine ("ITUNES: \"" + strSongTitle  + "\" found " + numHits + " time(s)");
         }
   
         for (i = 1; i <= numHits; i++)
         {
            if (verbose)
               objLogFile.WriteLine ("ITUNES: Hit #" + i + " points to " + splayList.Item(i).Location);
            if (splayList.Item(i).TrackNumber == strSongNumber)
            {
                if (verbose)
                 objLogFile.WriteLine ("ITUNES: Hit #" + i + " also matches track number");
   
              // okay so the search above is not an exact match. Ie for a song titled "wrong", the search
              // will return all songs that contain "wrong" in the title
              // so I need to search on filename. Easy for the LOG, but for the iTunes file I will
              // need to clean up the location... (ie remove path)
   
               strTemp = splayList.Item(i).Location.split("\\");
               strFileName = strTemp[strTemp.length-1];
   
   
               // now compare strFileName with strSongFileName.mp3
   
               if (strFileName == (strSongFileName + ".mp3"))
               {
                  if (verbose)
                     objLogFile.WriteLine("ITUNES: file name match for \"" + strSongFileName + ".mp3\"");
                  numMatches++;
               }
   
               if (numMatches == 1)
               {
                  if (verbose)
                      objLogFile.WriteLine ("ITUNES: Playcount was " + splayList.Item(i).PlayedCount + ", PlayedDate was " + splayList.Item(i).PlayedDate);
                  dBefore = splayList.Item(i).PlayedDate;
                  logYear = strDate.substring(0,4);
                  logMonth = strDate.substring(5,7);
                  logDay = strDate.substring(8,10);
                  logHour = strTime.substring(0,2);
                  logMinutes = strTime.substring(3,5);
                  logSeconds = strTime.substring(6,8);
                  dAfter = new Date();
                  dAfter = logDay + "/" + logMonth + "/" + logYear + " " + logHour + ":" + logMinutes + ":" + logSeconds;
                  //if (verbose)
                   //  objLogFile.WriteLine ("DLOG: " + dAfter);
                  splayList.Item(i).PlayedDate = dAfter;
                  splayList.Item(i).PlayedCount++;
                  numUpdated++;
                  if (verbose)
                      objLogFile.WriteLine ("ITUNES: Playcount is now " + splayList.Item(i).PlayedCount + ", PlayedDate is now " + splayList.Item(i).PlayedDate);
               }
               else
               {
                  if (numMatches == 0) {}
                  else
                  {
                     if (verbose)
                        objLogFile.WriteLine("More than one match for " + strSongFileName + " - doing nothing");
                        i = numHits + 1;
                     }
                  }
               }         
            }
         }
      }
   } //while (objTextFile.AtEndOfStream == 0)

// we're done, print some numbers

objLogFile.WriteLine ("DONE: Scanned " + numScanned + " songs, updated " + numUpdated);
WScript.Echo ("DONE: Scanned " + numScanned + " songs, updated " + numUpdated);

objTextFile.Close();
objLogFile.Close();

if (verbose)
   WScript.Echo ("Log file is D:\\My Documents\\My Music\\iTunes\\messages.log");
WScript.Echo ("You should probably delete Z:\\mt-daapd.log now");

// ENDFILE
 
aann
Posts: 13
Joined: Sun May 20, 2007 12:09 pm

Re: Play Count Updater

Mon Jul 04, 2011 6:00 pm

viewtopic.php?f=1&t=41010

Play count updates from the SB are now possible with MediaMonkey 4!
 
smithjhon
Posts: 1
Joined: Thu Mar 29, 2012 10:06 pm

Re: Play Count Updater

Thu Mar 29, 2012 10:10 pm

I Updated from your post.

Thanks to sharing.......
 
chal5oye
Posts: 1
Joined: Fri Jan 10, 2014 9:55 pm

Re: Play Count Updater

Fri Jan 10, 2014 11:21 pm

My Roku is streaming from a Firefly installation running on an NLSU2. The whole point being that my computer is not on at all times (shocking! :)) and I do not want it to be, so songs are served from the Slug that's sitting in the living room. I do refresh Firefly with iTunes Library.xml at least once a week so they are in sync.

However I would still love it if the Play counters from the SoundBridge could be updated whenever I turn the PC on, that is, if there was a way to have RIC run on the Slug and store the play info, dumping it to iTunes whenever possible...

Does it make sense ?
GuL

Who is online

Users browsing this forum: No registered users and 4 guests