functions.php
changeset 14 7a1573676cc4
parent 13 b5db2345c397
child 15 2adca0f363fd
equal deleted inserted replaced
13:b5db2345c397 14:7a1573676cc4
   101   $effective_md5 = md5_playlist_file($playlist_file);
   101   $effective_md5 = md5_playlist_file($playlist_file);
   102   if ( $playlist_last_md5 == $effective_md5 )
   102   if ( $playlist_last_md5 == $effective_md5 )
   103   {
   103   {
   104     return true;
   104     return true;
   105   }
   105   }
       
   106   status('Rebuilding playlist cache');
   106   $playlist_last_md5 = $effective_md5;
   107   $playlist_last_md5 = $effective_md5;
   107   // start XML parser
   108   // start XML parser
   108   try
   109   try
   109   {
   110   {
   110     $xml = simplexml_load_file($playlist_file);
   111     $xml = simplexml_load_file($playlist_file);
   146   $contents = @file_get_contents($file);
   147   $contents = @file_get_contents($file);
   147   if ( empty($contents) )
   148   if ( empty($contents) )
   148     return false;
   149     return false;
   149   $count = preg_match_all('/uniqueid="([a-fA-F0-9]+?)"/', $contents, $matches);
   150   $count = preg_match_all('/uniqueid="([a-fA-F0-9]+?)"/', $contents, $matches);
   150   $matches = implode("", $matches[1]);
   151   $matches = implode("", $matches[1]);
       
   152   if ( empty($matches) )
       
   153   {
       
   154     // sometimes current.xml has blank unique IDs
       
   155     $count = preg_match_all('/url="([^"]+?)"/', $contents, $matches);
       
   156     $matches = implode("", $matches[1]);
       
   157   }
   151   return md5($matches);
   158   return md5($matches);
   152 }
   159 }
   153 
   160 
   154 /**
   161 /**
   155  * Converts a number to minute:second format
   162  * Converts a number to minute:second format