/** * Scrapes additional fields not offered through the standard API * Returns an array of additional params or false if no matched response * * @param string $rageid * * @return array|bool|mixed */ public function getRageInfoFromService($rageid) { $result = false; // Standard show info search as AKAs not needed. $xml = Misc::getUrl(['url' => $this->xmlShowInfoUrl . $rageid]); if ($xml !== false) { $arrXml = Misc::objectsIntoArray(simplexml_load_string($xml)); if (is_array($arrXml)) { $result = ['showid' => $rageid]; $result['country'] = isset($arrXml['origin_country']) ? $arrXml['origin_country'] : ''; $result['firstaired'] = isset($arrXml['startdate']) ? date('m-d-Y', strtotime($arrXml['startdate'])) : ''; $result = Country::countryCode($result, $this->pdo); } } return $result; }
/** * Updates the show info with data from the supplied array * Only called when a duplicate show is found during insert * * @param int $videoId * @param array $show */ public function update($videoId, array $show = []) { if ($show['country'] !== '') { $show['country'] = Country::countryCode($show['country'], $this->pdo); } $ifStringID = 'IF(%s = 0, %s, %s)'; $ifStringInfo = "IF(%s = '', %s, %s)"; $this->pdo->queryExec(sprintf(' UPDATE videos v LEFT JOIN tv_info tvi ON v.id = tvi.videos_id SET v.countries_id = %s, v.tvdb = %s, v.trakt = %s, v.tvrage = %s, v.tvmaze = %s, v.imdb = %s, v.tmdb = %s, tvi.summary = %s, tvi.publisher = %s, tvi.localzone = %s WHERE v.id = %d', sprintf($ifStringInfo, 'v.countries_id', $this->pdo->escapeString($show['country']), 'v.countries_id'), sprintf($ifStringID, 'v.tvdb', $show['tvdb'], 'v.tvdb'), sprintf($ifStringID, 'v.trakt', $show['trakt'], 'v.trakt'), sprintf($ifStringID, 'v.tvrage', $show['tvrage'], 'v.tvrage'), sprintf($ifStringID, 'v.tvmaze', $show['tvmaze'], 'v.tvmaze'), sprintf($ifStringID, 'v.imdb', $show['imdb'], 'v.imdb'), sprintf($ifStringID, 'v.tmdb', $show['tmdb'], 'v.tmdb'), sprintf($ifStringInfo, 'tvi.summary', $this->pdo->escapeString($show['summary']), 'tvi.summary'), sprintf($ifStringInfo, 'tvi.publisher', $this->pdo->escapeString($show['publisher']), 'tvi.publisher'), sprintf($ifStringInfo, 'tvi.localzone', $this->pdo->escapeString($show['localzone']), 'tvi.localzone'), $videoId)); if (!empty($show['aliases'])) { $this->addAliases($videoId, $show['aliases']); } }