Example #1
0
 private function loadMusicFiche()
 {
     $oLastFM = new \LASTFM\LastFM(Config::get('lastFMApiKey'));
     try {
         $oAlbum = $oLastFM->getInfos('', '', $this->oRequest->getParam('fiche', 'string'));
         if ($oAlbum == null) {
             throw new Error('Aucune fiche ne correspond à l\'ID', 1163);
         }
         $oFicheMusic = new Fichemusic();
         $oFicheMusic->loadFromLastFM($oAlbum);
         $oFicheMusic->storeIfNotExists($this->oRelease->getId());
         return $oFicheMusic;
     } catch (Exception $e) {
         throw new Error('Aucune fiche ne correspond à l\'ID', 1163);
     }
 }
Example #2
0
 /**
  * Essai de scrapper une musique
  * @return boolean Vrai si c'est une musique
  */
 private function tryMusique()
 {
     if (!$this->checkTags(3)) {
         return false;
     }
     //On regarde si on a une date
     if (preg_match('#(\\W|^)[0-9]{4}(\\W|$)#i', $this->sReleaseName, $aYear)) {
         $aElements = preg_split('#(\\W|^)[0-9]{4}(\\W|$)#i', $this->sReleaseName);
         $sArtisteAlbum = strtr($aElements[0], ".", " ");
         $sYear = substr($aYear[0], 1, 4);
     } else {
         $sArtisteAlbum = strtr($this->sReleaseName, ".", " ");
     }
     $aElements = explode('-', $sArtisteAlbum);
     if (count($aElements) > 1) {
         $sArtist = trim($aElements[0]);
         $sAlbum = trim($aElements[1]);
     } else {
         $sArtist = null;
         $sAlbum = trim($aElements[0]);
     }
     $oLastFM = new \LASTFM\LastFM(Config::get('lastFMApiKey'));
     try {
         $oAlbum = $oLastFM->search($sAlbum, $sArtist);
         if ($oAlbum == null) {
             throw new Exception();
         }
         $oFicheMusic = new Fichemusic();
         $oFicheMusic->loadFromLastFM($oAlbum);
         $oFicheMusic->storeIfNotExists($this->iReleaseId);
         $this->iCategorieId = 3;
         $this->sFicheId = $oAlbum->getId();
         $aDatas = array('id_categorie' => $this->iCategorieId);
         parent::update('tks_releases', $aDatas, $this->iReleaseId);
         return true;
     } catch (Exception $e) {
         return false;
     }
 }