Ejemplo n.º 1
0
 /**
  * getIndexes
  * Get an indexed structure of all artists.
  * Takes optional musicFolderId and optional ifModifiedSince in parameters.
  */
 public static function getindexes($input)
 {
     self::check_version($input);
     set_time_limit(300);
     $musicFolderId = $input['musicFolderId'];
     $ifModifiedSince = $input['ifModifiedSince'];
     $catalogs = array();
     if (!empty($musicFolderId) && $musicFolderId != '-1') {
         $catalogs[] = $musicFolderId;
     } else {
         $catalogs = Catalog::get_catalogs();
     }
     $lastmodified = 0;
     $fcatalogs = array();
     foreach ($catalogs as $id) {
         $clastmodified = 0;
         $catalog = Catalog::create_from_id($id);
         if ($catalog->last_update > $clastmodified) {
             $clastmodified = $catalog->last_update;
         }
         if ($catalog->last_add > $clastmodified) {
             $clastmodified = $catalog->last_add;
         }
         if ($catalog->last_clean > $clastmodified) {
             $clastmodified = $catalog->last_clean;
         }
         if ($clastmodified > $lastmodified) {
             $lastmodified = $clastmodified;
         }
         if (!empty($ifModifiedSince) && $clastmodified > $ifModifiedSince / 1000) {
             $fcatalogs[] = $id;
         }
     }
     if (empty($ifModifiedSince)) {
         $fcatalogs = $catalogs;
     }
     $r = Subsonic_XML_Data::createSuccessResponse();
     if (count($fcatalogs) > 0) {
         $artists = Catalog::get_artists($fcatalogs);
         Subsonic_XML_Data::addArtistsIndexes($r, $artists, $lastmodified);
     }
     self::apiOutput($input, $r);
 }