Exemple #1
0
 /**
  * @param SimpleXMLElement $album
  * [@param bool $rebuildCache]
  * @return void
  */
 public function fetchAlbum($album, $rebuildCache = false)
 {
     $Cache_Lite = new Cache_Lite(parent::getCacheOptions());
     $id = $this->buildAlbumId($album);
     if (!$rebuildCache && ($data = $Cache_Lite->get($id))) {
         $this->albumdata[$id] = simplexml_load_string($data);
     } else {
         $Cache_Lite->get($id);
         PubwichLog::log(2, Pubwich::_('Rebuilding cache for a Last.fm album'));
         $url = sprintf("http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=%s&artist=%s&album=%s", $this->key, urlencode($album->artist), urlencode($album->name));
         $data = FileFetcher::get($url);
         $cacheWrite = $Cache_Lite->save($data);
         if (PEAR::isError($cacheWrite)) {
             //var_dump( $cacheWrite );
         }
         $this->albumdata[$id] = simplexml_load_string($data);
     }
 }