/**
  * Get classname  of the Module which can process this $uri
  *
  * @param string $uri
  * @return string
  */
 private static function _getClassNameByUri($uri)
 {
     $fs = Lms_Ufs_Index::findModule($uri);
     if ($fs == NULL) {
         throw new Lms_Exception("There is no Module to process this uri: " . $uri, E_USER_ERROR);
     } else {
         $className = Lms_Modular::loadModule($fs);
     }
     return $className;
 }
 /**
  * Parse url
  *
  * @param string $url
  * @return unknown
  */
 public static function parseUrl($url)
 {
     $fileSize = Lms_Ufs::filesize($url);
     //Для удалённых файлов не отработает т.к. нет модулей UFS_HTTP, UFS_FTP ...
     $filePath = Lms_Ufs::getAbsolutePath($url);
     $extension = strtolower(pathinfo($url, PATHINFO_EXTENSION));
     $demuxer = self::_getDemuxer($fileSize, $extension);
     $localtempfilename = false;
     $info = array();
     if ($demuxer) {
         if (self::_isRemote($url)) {
             if ($fp_remote = fopen($url, 'rb')) {
                 $localtempfilename = tempnam('/tmp', 'getID3');
                 if ($fp_local = fopen($localtempfilename, 'wb')) {
                     $buffer = '';
                     while (!feof($fp_remote) && strlen($buffer) < 32768) {
                         $buffer .= fread($fp_remote, 8192);
                     }
                     fwrite($fp_local, $buffer);
                     fclose($fp_local);
                     self::_log("Localize {$filePath} to {$localtempfilename}");
                     $filePath = $localtempfilename;
                 }
                 fclose($fp_remote);
             }
         }
         do {
             $curAdapter = Lms_Modular::loadModule('Adapter_' . ucfirst($demuxer), true);
             if (!$curAdapter) {
                 throw new Exception("Can't get instance of Adapter_" . ucfirst($demuxer));
             }
             if (isset(self::$_config['instances'][$demuxer]) && is_object(self::$_config['instances'][$demuxer])) {
                 $instance = self::$_config['instances'][$demuxer];
                 try {
                     $next = false;
                     self::_log("Parse {$filePath} with {$demuxer}");
                     $info = call_user_func(array($curAdapter, 'analyze'), $instance, $filePath, $fileSize);
                 } catch (Exception $e) {
                     self::_log("{$demuxer} failed");
                     if ($nextDemuxer = self::_getNextDemuxer($fileSize, $extension, $demuxer)) {
                         $next = true;
                         $demuxer = $nextDemuxer;
                     } else {
                         $next = false;
                     }
                 }
             } else {
                 self::_log("You must get an instance of demuxer: {$demuxer} before parsing url! ");
                 if ($nextDemuxer = self::_getNextDemuxer($fileSize, $extension, $demuxer)) {
                     $next = true;
                     $demuxer = $nextDemuxer;
                 } else {
                     $next = false;
                 }
             }
         } while ($next);
         if ($localtempfilename) {
             self::_log("Unlink {$localtempfilename}");
             unlink($localtempfilename);
             $localtempfilename = false;
         }
         return $info;
     } else {
         throw new Exception("There is no demuxer to parse this extension: " . $extension);
     }
 }