/** * Parse le flux RSS pour trouver les Torrents * @param Passkey $p_oPasskey * @return array */ public function parse($p_oPasskey) { $aTorrents = array(); //Ouverture du flux RSS libxml_use_internal_errors(true); if ($this->isPasskey()) { $sUrlWithPasskey = $p_oPasskey->getLinkWithPasskey($this->sUrl); } else { $sUrlWithPasskey = $this->sUrl; } $oRssDoc = simpleXML_load_file($sUrlWithPasskey); if (!$oRssDoc) { return array('error' => "Impossible d'ouvrir le flux : " . $this->sUrl); } //Traitement des items foreach ($oRssDoc->channel->item as $oRssItem) { //Traitement des jeux de caractères if ($this->sEncoding === "UTF-8") { $sPubDate = $oRssItem->pubDate; $sTitle = $oRssItem->title; $sLink = $oRssItem->link; } else { $sPubDate = iconv($this->sEncoding, "UTF-8//TRANSLIT", $oRssItem->pubDate); $sTitle = iconv($this->sEncoding, "UTF-8//TRANSLIT", $oRssItem->title); $sLink = iconv($this->sEncoding, "UTF-8//TRANSLIT", $oRssItem->link); } //On regarde si on a une date de publication : if (empty($sPubDate) || $this->bForcedate) { $sPubDate = date("Y-m-j G:i:s"); } if (strtotime($sPubDate) > strtotime($this->sLastCheck)) { $oTorrent = new Torrent($sTitle); $oTorrent->setDate(date("Y-m-j G:i:s", strtotime($sPubDate))); $oTorrent->setIdLink($this->getIdLink($sLink, $p_oPasskey)); $oTorrent->setTracker($this->iTracker); $aTorrents[] = $oTorrent; } } return $aTorrents; }