[ [ [ []]]]\n"; exit( 1 ); } $mastersName = 'your twitter name'; $inputFile = dirname($_SERVER['PHP_SELF']).'/tivo_nowplaying.xml'; $oldDataFile = dirname($_SERVER['PHP_SELF']).'/oldTiVoData.php'; $twitterUser=$argv[1]; $twitterPW=$argv[2]; if ( $argc > 3 ) $mastersName = $argv[3]; if ( $argc > 4 ) $inputFile = $argv[4]; if ( $argc > 5 ) $oldDataFile = $argv[5]; if ( $argc > 6 ) $noTweet = $argv[6]; // Parse the XML returned by the tivo $tivoParser = new Tivo_XML(); $tivoParser->init(); $programs = $tivoParser->parseTiVoXML( $inputFile ); // load up the old recording, offset and watching data. this file // contains the $recordingInfo, $oldOffset and $watchingState variables. include( $oldDataFile ); function cleanTitle( $title ) { // clean up the title $title = str_replace( "amp;", "&", $title ); $title = str_replace( "\"", "", $title ); return( urlencode($title) ); } function tweetIt( $tweetTxt ) { global $twitterUser; global $twitterPW; global $noTweet; echo "$tweetTxt\n"; $curlCmd = "curl -u $twitterUser:$twitterPW -d status=\"$tweetTxt\" http://twitter.com/statuses/update.json"; echo "$curlCmd\n"; if ( !$noTweet ) exec( $curlCmd ); } // now look through the new now playing data and see if it's recording anything new $i = 0; foreach ( $programs as $programInfo ) { $title = cleanTitle( $programInfo['title'] ); if ( $title != '' ) { $newOffsets[$title] = $programInfo['byteoffset']; if ( $i < 2 ) { if ( $programInfo['customicon'] == "urn:tivo:image:in-progress-recording" ) { if ( $recordingInfo[$i] != $title ) { // If this is the first recording, shift the recording down one if ( $i == 0 ) $recordingInfo[1] = $recordingInfo[0]; // assign the new title $recordingInfo[$i] = $title; tweetIt( "I just started recording '$title'!" ); } else echo "already were recording: $title\n"; $i++; } } } } echo "$i recordings in progress\n"; $fh = fopen( $oldDataFile, 'w' ) or die("can't open old data file"); fwrite( $fh, "\n" ); fclose($fh); ?>