Example #1
0
    /**
     * Process each game, updating game information from Giantbomb
     *
     * @param $gameInfo
     *
     * @return bool
     */
    public function updateGamesInfo($gameInfo)
    {
        $gen = new Genres(['Settings' => $this->pdo]);
        $ri = new ReleaseImage($this->pdo);
        $con = [];
        // Process Steam first before giantbomb
        // Steam has more details
        $this->_gameResults = [];
        $this->_getGame = new Steam();
        $this->_classUsed = "steam";
        $this->_getGame->cookie = $this->cookie;
        $this->_getGame->searchTerm = $gameInfo['title'];
        if ($this->_getGame->search() !== false) {
            $this->_gameResults = $this->_getGame->getAll();
        }
        if (count($this->_gameResults) < 1) {
            $this->_getGame = new Desura();
            $this->_classUsed = "desura";
            $this->_getGame->cookie = $this->cookie;
            $this->_getGame->searchTerm = $gameInfo['title'];
            if ($this->_getGame->search() !== false) {
                $this->_gameResults = $this->_getGame->getAll();
            }
        }
        if (count($this->_gameResults) < 1) {
            $this->_getGame = new Greenlight();
            $this->_classUsed = "gl";
            $this->_getGame->cookie = $this->cookie;
            $this->_getGame->searchTerm = $gameInfo['title'];
            if ($this->_getGame->search() !== false) {
                $this->_gameResults = $this->_getGame->getAll();
            }
        }
        if (count($this->_gameResults) < 1) {
            $this->_gameResults = (array) $this->fetchGiantBombID($gameInfo['title']);
            if ($this->maxHitRequest === true) {
                return false;
            }
        }
        if (empty($this->_gameResults['title'])) {
            return false;
        }
        if (!is_array($this->_gameResults)) {
            return false;
        }
        if (count($this->_gameResults) > 1) {
            $genreName = '';
            switch ($this->_classUsed) {
                case "desura":
                    if (isset($this->_gameResults['cover'])) {
                        $con['coverurl'] = (string) $this->_gameResults['cover'];
                    }
                    if (isset($this->_gameResults['backdrop'])) {
                        $con['backdropurl'] = (string) $this->_gameResults['backdrop'];
                    }
                    $con['title'] = (string) $this->_gameResults['title'];
                    $con['asin'] = $this->_gameResults['desuragameid'];
                    $con['url'] = (string) $this->_gameResults['directurl'];
                    if (isset($this->_gameResults['gamedetails']['Publisher'])) {
                        $con['publisher'] = (string) $this->_gameResults['gamedetails']['Publisher'];
                    } else {
                        $con['publisher'] = "Unknown";
                    }
                    if (isset($this->_gameResults['rating'])) {
                        $con['esrb'] = (string) $this->_gameResults['rating'];
                    } else {
                        $con['esrb'] = "Not Rated";
                    }
                    if (isset($this->_gameResults['description'])) {
                        $con['review'] = trim(strip_tags((string) $this->_gameResults['description']));
                    }
                    if (isset($this->_gameResults['trailer'])) {
                        $con['trailer'] = (string) $this->_gameResults['trailer'];
                    }
                    if (isset($this->_gameResults['gamedetails']['Genre'])) {
                        $genres = (string) $this->_gameResults['gamedetails']['Genre'];
                        $genreName = $this->_matchGenre($genres);
                    }
                    break;
                case "gb":
                    $con['coverurl'] = (string) $this->_gameResults['image']['super_url'];
                    $con['title'] = (string) $this->_gameResults['name'];
                    $con['asin'] = $this->_gameID;
                    $con['url'] = (string) $this->_gameResults['site_detail_url'];
                    if (is_array($this->_gameResults['publishers'])) {
                        while (list($key) = each($this->_gameResults['publishers'])) {
                            if ($key == 0) {
                                $con['publisher'] = (string) $this->_gameResults['publishers'][$key]['name'];
                            }
                        }
                    } else {
                        $con['publisher'] = "Unknown";
                    }
                    if (is_array($this->_gameResults['original_game_rating'])) {
                        $con['esrb'] = (string) $this->_gameResults['original_game_rating'][0]['name'];
                    } else {
                        $con['esrb'] = (string) $this->_gameResults['original_game_rating']['name'];
                    }
                    $con['releasedate'] = (string) $this->_gameResults['original_release_date'];
                    if (isset($this->_gameResults['description'])) {
                        $con['review'] = trim(strip_tags((string) $this->_gameResults['description']));
                    }
                    if (isset($this->_gameResults['genres'][0]['name'])) {
                        $genres = (string) $this->_gameResults['genres'][0]['name'];
                        $genreName = $this->_matchGenre($genres);
                    }
                    break;
                case "gl":
                    if (isset($this->_gameResults['cover'])) {
                        $con['coverurl'] = (string) $this->_gameResults['cover'];
                    }
                    if (isset($this->_gameResults['backdrop'])) {
                        $con['backdropurl'] = (string) $this->_gameResults['backdrop'];
                    }
                    $con['title'] = (string) $this->_gameResults['title'];
                    $con['asin'] = $this->_gameResults['greenlightgameid'];
                    $con['url'] = (string) $this->_gameResults['directurl'];
                    $con['publisher'] = "Unknown";
                    $con['esrb'] = "Not Rated";
                    if (isset($this->_gameResults['description'])) {
                        $con['review'] = trim(strip_tags((string) $this->_gameResults['description']));
                    }
                    if (isset($this->_gameResults['trailer'])) {
                        $con['trailer'] = (string) $this->_gameResults['trailer'];
                    }
                    if (isset($this->_gameResults['gamedetails']['Genre'])) {
                        $genres = (string) $this->_gameResults['gamedetails']['Genre'];
                        $genreName = $this->_matchGenre($genres);
                    }
                    break;
                case "steam":
                    if (isset($this->_gameResults['cover'])) {
                        $con['coverurl'] = (string) $this->_gameResults['cover'];
                    }
                    if (isset($this->_gameResults['backdrop'])) {
                        $con['backdropurl'] = (string) $this->_gameResults['backdrop'];
                    }
                    $con['title'] = (string) $this->_gameResults['title'];
                    $con['asin'] = $this->_gameResults['steamgameid'];
                    $con['url'] = (string) $this->_gameResults['directurl'];
                    if (isset($this->_gameResults['gamedetails']['Publisher'])) {
                        $con['publisher'] = (string) $this->_gameResults['gamedetails']['Publisher'];
                    } else {
                        $con['publisher'] = "Unknown";
                    }
                    if (isset($this->_gameResults['rating'])) {
                        $con['esrb'] = (string) $this->_gameResults['rating'];
                    } else {
                        $con['esrb'] = "Not Rated";
                    }
                    if (!empty($this->_gameResults['gamedetails']['Release Date'])) {
                        $dateReleased = $this->_gameResults['gamedetails']['Release Date'];
                        if (!preg_match('#^\\s*(?P<month>\\w+)\\s+(?P<day>\\d{1,2}),?\\s+(?P<year>\\d{4})\\s*$#', $dateReleased)) {
                            if (preg_match('#^\\s*(?P<month>\\w+)\\s+(?P<year>\\d{4})\\s*$#', $dateReleased, $matches)) {
                                $dateReleased = "{$matches['month']} 1, {$matches['year']}";
                            }
                        }
                        $date = \DateTime::createFromFormat('M/j/Y', $dateReleased);
                        if ($date instanceof \DateTime) {
                            $con['releasedate'] = (string) $date->format('Y-m-d');
                        }
                    }
                    if (isset($this->_gameResults['description'])) {
                        $con['review'] = trim(strip_tags((string) $this->_gameResults['description']));
                    }
                    if (isset($this->_gameResults['trailer'])) {
                        $con['trailer'] = (string) $this->_gameResults['trailer'];
                    }
                    if (isset($this->_gameResults['gamedetails']['Genre'])) {
                        $genres = (string) $this->_gameResults['gamedetails']['Genre'];
                        $genreName = $this->_matchGenre($genres);
                    }
                    break;
                default:
                    return false;
            }
        } else {
            return false;
        }
        // Load genres.
        $defaultGenres = $gen->getGenres(Genres::GAME_TYPE);
        $genreassoc = [];
        foreach ($defaultGenres as $dg) {
            $genreassoc[$dg['id']] = strtolower($dg['title']);
        }
        // Prepare database values.
        if (isset($con['coverurl'])) {
            $con['cover'] = 1;
        } else {
            $con['cover'] = 0;
        }
        if (isset($con['backdropurl'])) {
            $con['backdrop'] = 1;
        } else {
            $con['backdrop'] = 0;
        }
        if (!isset($con['trailer'])) {
            $con['trailer'] = 0;
        }
        if (empty($con['title'])) {
            $con['title'] = $gameInfo['title'];
        }
        if (!isset($con['releasedate'])) {
            $con['releasedate'] = "";
        }
        if ($con['releasedate'] == "''") {
            $con['releasedate'] = "";
        }
        if (!isset($con['review'])) {
            $con['review'] = 'No Review';
        }
        $con['classused'] = $this->_classUsed;
        if (empty($genreName)) {
            $genreName = 'Unknown';
        }
        if (in_array(strtolower($genreName), $genreassoc)) {
            $genreKey = array_search(strtolower($genreName), $genreassoc);
        } else {
            $genreKey = $this->pdo->queryInsert(sprintf("\n\t\t\t\t\tINSERT INTO genres (title, type)\n\t\t\t\t\tVALUES (%s, %d)", $this->pdo->escapeString($genreName), Genres::GAME_TYPE));
        }
        $con['gamesgenre'] = $genreName;
        $con['gamesgenreID'] = $genreKey;
        $check = $this->pdo->queryOneRow(sprintf('
				SELECT id
				FROM gamesinfo
				WHERE asin = %s', $this->pdo->escapeString($con['asin'])));
        if ($check === false) {
            $gamesId = $this->pdo->queryInsert(sprintf("\n\t\t\t\t\tINSERT INTO gamesinfo\n\t\t\t\t\t\t(title, asin, url, publisher, genre_id, esrb, releasedate, review, cover, backdrop, trailer, classused, createddate, updateddate)\n\t\t\t\t\tVALUES (%s, %s, %s, %s, %s, %s, %s, %s, %d, %d, %s, %s, NOW(), NOW())", $this->pdo->escapeString($con['title']), $this->pdo->escapeString($con['asin']), $this->pdo->escapeString($con['url']), $this->pdo->escapeString($con['publisher']), $con['gamesgenreID'] == -1 ? "null" : $con['gamesgenreID'], $this->pdo->escapeString($con['esrb']), $con['releasedate'] != "" ? $this->pdo->escapeString($con['releasedate']) : "null", $this->pdo->escapeString(substr($con['review'], 0, 3000)), $con['cover'], $con['backdrop'], $this->pdo->escapeString($con['trailer']), $this->pdo->escapeString($con['classused'])));
        } else {
            $gamesId = $check['id'];
            $this->pdo->queryExec(sprintf('
					UPDATE gamesinfo
					SET
						title = %s, asin = %s, url = %s, publisher = %s, genre_id = %s,
						esrb = %s, releasedate = %s, review = %s, cover = %d, backdrop = %d, trailer = %s, classused = %s, updateddate = NOW()
					WHERE id = %d', $this->pdo->escapeString($con['title']), $this->pdo->escapeString($con['asin']), $this->pdo->escapeString($con['url']), $this->pdo->escapeString($con['publisher']), $con['gamesgenreID'] == -1 ? "null" : $con['gamesgenreID'], $this->pdo->escapeString($con['esrb']), $con['releasedate'] != "" ? $this->pdo->escapeString($con['releasedate']) : "null", $this->pdo->escapeString(substr($con['review'], 0, 3000)), $con['cover'], $con['backdrop'], $this->pdo->escapeString($con['trailer']), $this->pdo->escapeString($con['classused']), $gamesId));
        }
        if ($gamesId) {
            if ($this->echoOutput) {
                $this->pdo->log->doEcho($this->pdo->log->header("Added/updated game from " . $this->_classUsed . ": ") . $this->pdo->log->alternateOver("   Title:    ") . $this->pdo->log->primary($con['title']));
            }
            if ($con['cover'] === 1) {
                $con['cover'] = $ri->saveImage($gamesId, $con['coverurl'], $this->imgSavePath, 250, 250);
            }
            if ($con['backdrop'] === 1) {
                $con['backdrop'] = $ri->saveImage($gamesId . '-backdrop', $con['backdropurl'], $this->imgSavePath, 1920, 1024);
            }
        } else {
            if ($this->echoOutput) {
                $this->pdo->log->doEcho($this->pdo->log->headerOver("Nothing to update: ") . $this->pdo->log->primary($con['title'] . ' (PC)'));
            }
        }
        return $gamesId;
    }
Example #2
0
    /**
     * @param             $title
     * @param             $year
     * @param object|null $amazdata
     *
     * @return bool
     */
    public function updateMusicInfo($title, $year, $amazdata = null)
    {
        $gen = new Genres(['Settings' => $this->pdo]);
        $ri = new ReleaseImage($this->pdo);
        $titlepercent = 0;
        $mus = [];
        if ($title != '') {
            $amaz = $this->fetchAmazonProperties($title);
        } else {
            if ($amazdata != null) {
                $amaz = $amazdata;
            } else {
                $amaz = false;
            }
        }
        if (!$amaz) {
            return false;
        }
        if (isset($amaz->Items->Item->ItemAttributes->Title)) {
            $mus['title'] = (string) $amaz->Items->Item->ItemAttributes->Title;
            if (empty($mus['title'])) {
                return false;
            }
        } else {
            return false;
        }
        // Load genres.
        $defaultGenres = $gen->getGenres(Genres::MUSIC_TYPE);
        $genreassoc = [];
        foreach ($defaultGenres as $dg) {
            $genreassoc[$dg['id']] = strtolower($dg['title']);
        }
        // Get album properties.
        $mus['coverurl'] = (string) $amaz->Items->Item->LargeImage->URL;
        if ($mus['coverurl'] != "") {
            $mus['cover'] = 1;
        } else {
            $mus['cover'] = 0;
        }
        $mus['asin'] = (string) $amaz->Items->Item->ASIN;
        $mus['url'] = (string) $amaz->Items->Item->DetailPageURL;
        $mus['url'] = str_replace("%26tag%3Dws", "%26tag%3Dopensourceins%2D21", $mus['url']);
        $mus['salesrank'] = (string) $amaz->Items->Item->SalesRank;
        if ($mus['salesrank'] == "") {
            $mus['salesrank'] = 'null';
        }
        $mus['artist'] = (string) $amaz->Items->Item->ItemAttributes->Artist;
        if (empty($mus['artist'])) {
            $mus['artist'] = (string) $amaz->Items->Item->ItemAttributes->Creator;
            if (empty($mus['artist'])) {
                $mus['artist'] = "";
            }
        }
        $mus['publisher'] = (string) $amaz->Items->Item->ItemAttributes->Publisher;
        $mus['releasedate'] = $this->pdo->escapeString((string) $amaz->Items->Item->ItemAttributes->ReleaseDate);
        if ($mus['releasedate'] == "''") {
            $mus['releasedate'] = 'null';
        }
        $mus['review'] = "";
        if (isset($amaz->Items->Item->EditorialReviews)) {
            $mus['review'] = trim(strip_tags((string) $amaz->Items->Item->EditorialReviews->EditorialReview->Content));
        }
        $mus['year'] = $year;
        if ($mus['year'] == "") {
            $mus['year'] = $mus['releasedate'] != 'null' ? substr($mus['releasedate'], 1, 4) : date("Y");
        }
        $mus['tracks'] = "";
        if (isset($amaz->Items->Item->Tracks)) {
            $tmpTracks = (array) $amaz->Items->Item->Tracks->Disc;
            $tracks = $tmpTracks['Track'];
            $mus['tracks'] = is_array($tracks) && !empty($tracks) ? implode('|', $tracks) : '';
        }
        similar_text($mus['artist'] . " " . $mus['title'], $title, $titlepercent);
        if ($titlepercent < 60) {
            return false;
        }
        $genreKey = -1;
        $genreName = '';
        if (isset($amaz->Items->Item->BrowseNodes)) {
            // Had issues getting this out of the browsenodes obj.
            // Workaround is to get the xml and load that into its own obj.
            $amazGenresXml = $amaz->Items->Item->BrowseNodes->asXml();
            $amazGenresObj = simplexml_load_string($amazGenresXml);
            $amazGenres = $amazGenresObj->xpath("//BrowseNodeId");
            foreach ($amazGenres as $amazGenre) {
                $currNode = trim($amazGenre[0]);
                if (empty($genreName)) {
                    $genreMatch = $this->matchBrowseNode($currNode);
                    if ($genreMatch !== false) {
                        $genreName = $genreMatch;
                        break;
                    }
                }
            }
            if (in_array(strtolower($genreName), $genreassoc)) {
                $genreKey = array_search(strtolower($genreName), $genreassoc);
            } else {
                $genreKey = $this->pdo->queryInsert(sprintf("\n\t\t\t\t\t\t\t\t\t\tINSERT INTO genres (title, type)\n\t\t\t\t\t\t\t\t\t\tVALUES (%s, %d)", $this->pdo->escapeString($genreName), Genres::MUSIC_TYPE));
            }
        }
        $mus['musicgenre'] = $genreName;
        $mus['musicgenreid'] = $genreKey;
        $check = $this->pdo->queryOneRow(sprintf('
				SELECT id
				FROM musicinfo
				WHERE asin = %s', $this->pdo->escapeString($mus['asin'])));
        if ($check === false) {
            $musicId = $this->pdo->queryInsert(sprintf("\n\t\t\t\t\tINSERT INTO musicinfo\n\t\t\t\t\t\t(title, asin, url, salesrank, artist, publisher,\n\t\t\t\t\t\treleasedate, review, year, genre_id, tracks, cover, createddate, updateddate)\n\t\t\t\t\tVALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, now(), now())", $this->pdo->escapeString($mus['title']), $this->pdo->escapeString($mus['asin']), $this->pdo->escapeString($mus['url']), $mus['salesrank'], $this->pdo->escapeString($mus['artist']), $this->pdo->escapeString($mus['publisher']), $mus['releasedate'], $this->pdo->escapeString($mus['review']), $this->pdo->escapeString($mus['year']), $mus['musicgenreid'] == -1 ? "null" : $mus['musicgenreid'], $this->pdo->escapeString($mus['tracks']), $mus['cover']));
        } else {
            $musicId = $check['id'];
            $this->pdo->queryExec(sprintf('
					UPDATE musicinfo
					SET title = %s, asin = %s, url = %s, salesrank = %s, artist = %s,
						publisher = %s, releasedate = %s, review = %s, year = %s, genre_id = %s, tracks = %s, cover = %s,
						updateddate = NOW()
					WHERE id = %d', $this->pdo->escapeString($mus['title']), $this->pdo->escapeString($mus['asin']), $this->pdo->escapeString($mus['url']), $mus['salesrank'], $this->pdo->escapeString($mus['artist']), $this->pdo->escapeString($mus['publisher']), $mus['releasedate'], $this->pdo->escapeString($mus['review']), $this->pdo->escapeString($mus['year']), $mus['musicgenreid'] == -1 ? "null" : $mus['musicgenreid'], $this->pdo->escapeString($mus['tracks']), $mus['cover'], $musicId));
        }
        if ($musicId) {
            if ($this->echooutput) {
                $this->pdo->log->doEcho($this->pdo->log->header("\nAdded/updated album: ") . $this->pdo->log->alternateOver("   Artist: ") . $this->pdo->log->primary($mus['artist']) . $this->pdo->log->alternateOver("   Title:  ") . $this->pdo->log->primary($mus['title']) . $this->pdo->log->alternateOver("   Year:   ") . $this->pdo->log->primary($mus['year']));
            }
            $mus['cover'] = $ri->saveImage($musicId, $mus['coverurl'], $this->imgSavePath, 250, 250);
        } else {
            if ($this->echooutput) {
                if ($mus["artist"] == "") {
                    $artist = "";
                } else {
                    $artist = "Artist: " . $mus['artist'] . ", Album: ";
                }
                $this->pdo->log->doEcho($this->pdo->log->headerOver("Nothing to update: ") . $this->pdo->log->primary($artist . $mus['title'] . " (" . $mus['year'] . ")"));
            }
        }
        return $musicId;
    }
Example #3
0
 /**
  * Fetch IMDB/TMDB info for the movie.
  *
  * @param string $imdbId
  *
  * @return bool
  */
 public function updateMovieInfo($imdbId)
 {
     if ($this->echooutput && $this->service !== '') {
         $this->pdo->log->doEcho($this->pdo->log->primary("Fetching IMDB info from TMDB using IMDB ID: " . $imdbId));
     }
     // Check TMDB for IMDB info.
     $tmdb = $this->fetchTMDBProperties($imdbId);
     // Check IMDB for movie info.
     $imdb = $this->fetchIMDBProperties($imdbId);
     // Check TRAKT for movie info
     $trakt = $this->fetchTraktTVProperties($imdbId);
     if (!$imdb && !$tmdb && !$trakt) {
         return false;
     }
     // Check FanArt.tv for background images.
     $fanart = $this->fetchFanartTVProperties($imdbId);
     $mov = [];
     $mov['cover'] = $mov['backdrop'] = $mov['banner'] = $movieID = 0;
     $mov['type'] = $mov['director'] = $mov['actors'] = $mov['language'] = '';
     $mov['imdb_id'] = $imdbId;
     $mov['tmdb_id'] = !isset($tmdb['tmdb_id']) || $tmdb['tmdb_id'] == '' ? 0 : $tmdb['tmdb_id'];
     // Prefer Fanart.tv cover over TRAKT, TRAKT over TMDB and TMDB over IMDB.
     if ($this->checkVariable($fanart['cover'])) {
         $mov['cover'] = $this->releaseImage->saveImage($imdbId . '-cover', $fanart['cover'], $this->imgSavePath);
     } else {
         if ($this->checkVariable($trakt['cover'])) {
             $mov['cover'] = $this->releaseImage->saveImage($imdbId . '-cover', $trakt['cover'], $this->imgSavePath);
         } else {
             if ($this->checkVariable($tmdb['cover'])) {
                 $mov['cover'] = $this->releaseImage->saveImage($imdbId . '-cover', $tmdb['cover'], $this->imgSavePath);
             } else {
                 if ($this->checkVariable($imdb['cover'])) {
                     $mov['cover'] = $this->releaseImage->saveImage($imdbId . '-cover', $imdb['cover'], $this->imgSavePath);
                 }
             }
         }
     }
     // Backdrops.
     if ($this->checkVariable($fanart['backdrop'])) {
         $mov['backdrop'] = $this->releaseImage->saveImage($imdbId . '-backdrop', $fanart['backdrop'], $this->imgSavePath, 1920, 1024);
     } else {
         if ($this->checkVariable($tmdb['backdrop'])) {
             $mov['backdrop'] = $this->releaseImage->saveImage($imdbId . '-backdrop', $tmdb['backdrop'], $this->imgSavePath, 1920, 1024);
         }
     }
     $mov['title'] = $this->setTmdbImdbTraktVar($imdb['title'], $tmdb['title'], $trakt['title']);
     $mov['rating'] = $this->setTmdbImdbTraktVar($imdb['rating'], $tmdb['rating'], $trakt['rating']);
     $mov['plot'] = $this->setTmdbImdbTraktVar($imdb['plot'], $tmdb['plot'], $trakt['overview']);
     $mov['tagline'] = $this->setTmdbImdbTraktVar($imdb['tagline'], $tmdb['tagline'], $trakt['tagline']);
     $mov['year'] = $this->setTmdbImdbTraktVar($imdb['year'], $tmdb['year'], $trakt['year']);
     $mov['genre'] = $this->setTmdbImdbTraktVar($imdb['genre'], $tmdb['genre'], $trakt['genres']);
     if ($this->checkVariable($imdb['type'])) {
         $mov['type'] = $imdb['type'];
     }
     if ($this->checkVariable($imdb['director'])) {
         $mov['director'] = is_array($imdb['director']) ? implode(', ', array_unique($imdb['director'])) : $imdb['director'];
     }
     if ($this->checkVariable($imdb['actors'])) {
         $mov['actors'] = is_array($imdb['actors']) ? implode(', ', array_unique($imdb['actors'])) : $imdb['actors'];
     }
     if ($this->checkVariable($imdb['language'])) {
         $mov['language'] = is_array($imdb['language']) ? implode(', ', array_unique($imdb['language'])) : $imdb['language'];
     }
     if (is_array($mov['genre'])) {
         $mov['genre'] = implode(', ', array_unique($mov['genre']));
     }
     if (is_array($mov['type'])) {
         $mov['type'] = implode(', ', array_unique($mov['type']));
     }
     $mov['title'] = html_entity_decode($mov['title'], ENT_QUOTES, 'UTF-8');
     $mov['title'] = str_replace(['/', '\\'], '', $mov['title']);
     $movieID = $this->update(['actors' => html_entity_decode($mov['actors'], ENT_QUOTES, 'UTF-8'), 'backdrop' => $mov['backdrop'], 'cover' => $mov['cover'], 'director' => html_entity_decode($mov['director'], ENT_QUOTES, 'UTF-8'), 'genre' => html_entity_decode($mov['genre'], ENT_QUOTES, 'UTF-8'), 'imdbid' => $mov['imdb_id'], 'language' => html_entity_decode($mov['language'], ENT_QUOTES, 'UTF-8'), 'plot' => html_entity_decode(preg_replace('/\\s+See full summary ยป/', ' ', $mov['plot']), ENT_QUOTES, 'UTF-8'), 'rating' => round($mov['rating'], 1), 'tagline' => html_entity_decode($mov['tagline'], ENT_QUOTES, 'UTF-8'), 'title' => $mov['title'], 'tmdbid' => $mov['tmdb_id'], 'type' => html_entity_decode(ucwords(preg_replace('/[\\.\\_]/', ' ', $mov['type'])), ENT_QUOTES, 'UTF-8'), 'year' => $mov['year']]);
     if ($this->echooutput && $this->service !== '') {
         $this->pdo->log->doEcho($this->pdo->log->headerOver($movieID !== 0 ? 'Added/updated movie: ' : 'Nothing to update for movie: ') . $this->pdo->log->primary($mov['title'] . ' (' . $mov['year'] . ') - ' . $mov['imdb_id']));
     }
     return $movieID === 0 ? false : true;
 }
Example #4
0
    /**
     * Deletes a single release by GUID, and all the corresponding files.
     *
     * @param array        $identifiers ['g' => Release GUID(mandatory), 'id => ReleaseID(optional, pass false)]
     * @param NZB          $nzb
     * @param ReleaseImage $releaseImage
     */
    public function deleteSingle($identifiers, $nzb, $releaseImage)
    {
        // Delete NZB from disk.
        $nzbPath = $nzb->NZBPath($identifiers['g']);
        if ($nzbPath) {
            @unlink($nzbPath);
        }
        // Delete images.
        $releaseImage->delete($identifiers['g']);
        // Delete from sphinx.
        $this->sphinxSearch->deleteRelease($identifiers, $this->pdo);
        // Delete from DB.
        $this->pdo->queryExec(sprintf('
				DELETE r, rn, rc, uc, rf, ra, rs, rv, re
				FROM releases r
				LEFT OUTER JOIN release_nfos rn ON rn.releaseid = r.id
				LEFT OUTER JOIN release_comments rc ON rc.releaseid = r.id
				LEFT OUTER JOIN users_releases uc ON uc.releaseid = r.id
				LEFT OUTER JOIN release_files rf ON rf.releaseid = r.id
				LEFT OUTER JOIN audio_data ra ON ra.releaseid = r.id
				LEFT OUTER JOIN release_subtitles rs ON rs.releaseid = r.id
				LEFT OUTER JOIN video_data rv ON rv.releaseid = r.id
				LEFT OUTER JOIN releaseextrafull re ON re.releaseid = r.id
				WHERE r.guid = %s', $this->pdo->escapeString($identifiers['g'])));
    }
Example #5
0
 /**
  * Fetch IMDB/TMDB info for the movie.
  *
  * @param string $imdbId
  *
  * @return bool
  */
 public function updateMovieInfo($imdbId)
 {
     if ($this->echooutput && $this->service !== '') {
         $this->pdo->log->doEcho($this->pdo->log->primary("Fetching IMDB info from TMDB using IMDB ID: " . $imdbId));
     }
     // Check TMDB for IMDB info.
     $tmdb = $this->fetchTMDBProperties($imdbId);
     // Check IMDB for movie info.
     $imdb = $this->fetchIMDBProperties($imdbId);
     if (!$imdb && !$tmdb) {
         return false;
     }
     // Check FanArt.tv for background images.
     $fanart = $this->fetchFanartTVProperties($imdbId);
     $mov = [];
     $mov['cover'] = $mov['backdrop'] = $movieID = 0;
     $mov['type'] = $mov['director'] = $mov['actors'] = $mov['language'] = '';
     $mov['imdb_id'] = $imdbId;
     $mov['tmdb_id'] = !isset($tmdb['tmdb_id']) || $tmdb['tmdb_id'] == '' ? 'NULL' : $tmdb['tmdb_id'];
     // Prefer FanArt.tv cover over TMDB. And TMDB over IMDB.
     if ($this->checkVariable($fanart['cover'])) {
         $mov['cover'] = $this->releaseImage->saveImage($imdbId . '-cover', $fanart['cover'], $this->imgSavePath);
     } else {
         if ($this->checkVariable($tmdb['cover'])) {
             $mov['cover'] = $this->releaseImage->saveImage($imdbId . '-cover', $tmdb['cover'], $this->imgSavePath);
         } else {
             if ($this->checkVariable($imdb['cover'])) {
                 $mov['cover'] = $this->releaseImage->saveImage($imdbId . '-cover', $imdb['cover'], $this->imgSavePath);
             }
         }
     }
     // Backdrops.
     if ($this->checkVariable($fanart['backdrop'])) {
         $mov['backdrop'] = $this->releaseImage->saveImage($imdbId . '-backdrop', $fanart['backdrop'], $this->imgSavePath, 1920, 1024);
     } else {
         if ($this->checkVariable($tmdb['backdrop'])) {
             $mov['backdrop'] = $this->releaseImage->saveImage($imdbId . '-backdrop', $tmdb['backdrop'], $this->imgSavePath, 1920, 1024);
         }
     }
     $mov['title'] = $this->setTmdbImdbVar($imdb['title'], $tmdb['title']);
     $mov['rating'] = $this->setTmdbImdbVar($imdb['rating'], $tmdb['rating']);
     $mov['plot'] = $this->setTmdbImdbVar($imdb['plot'], $tmdb['plot']);
     $mov['tagline'] = $this->setTmdbImdbVar($imdb['tagline'], $tmdb['tagline']);
     $mov['year'] = $this->setTmdbImdbVar($imdb['year'], $tmdb['year']);
     $mov['genre'] = $this->setTmdbImdbVar($imdb['genre'], $tmdb['genre']);
     if ($this->checkVariable($imdb['type'])) {
         $mov['type'] = $imdb['type'];
     }
     if ($this->checkVariable($imdb['director'])) {
         $mov['director'] = is_array($imdb['director']) ? implode(', ', array_unique($imdb['director'])) : $imdb['director'];
     }
     if ($this->checkVariable($imdb['actors'])) {
         $mov['actors'] = is_array($imdb['actors']) ? implode(', ', array_unique($imdb['actors'])) : $imdb['actors'];
     }
     if ($this->checkVariable($imdb['language'])) {
         $mov['language'] = is_array($imdb['language']) ? implode(', ', array_unique($imdb['language'])) : $imdb['language'];
     }
     if (is_array($mov['genre'])) {
         $mov['genre'] = implode(', ', array_unique($mov['genre']));
     }
     if (is_array($mov['type'])) {
         $mov['type'] = implode(', ', array_unique($mov['type']));
     }
     $mov['title'] = html_entity_decode($mov['title'], ENT_QUOTES, 'UTF-8');
     $mov['plot'] = html_entity_decode(preg_replace('/\\s+See full summary ยป/', ' ', $mov['plot']), ENT_QUOTES, 'UTF-8');
     $mov['tagline'] = html_entity_decode($mov['tagline'], ENT_QUOTES, 'UTF-8');
     $mov['genre'] = html_entity_decode($mov['genre'], ENT_QUOTES, 'UTF-8');
     $mov['director'] = html_entity_decode($mov['director'], ENT_QUOTES, 'UTF-8');
     $mov['actors'] = html_entity_decode($mov['actors'], ENT_QUOTES, 'UTF-8');
     $mov['language'] = html_entity_decode($mov['language'], ENT_QUOTES, 'UTF-8');
     $mov['type'] = html_entity_decode(ucwords(preg_replace('/[\\.\\_]/', ' ', $mov['type'])), ENT_QUOTES, 'UTF-8');
     $mov['title'] = str_replace(['/', '\\'], '', $mov['title']);
     $movieID = $this->pdo->queryInsert(sprintf("\n\t\t\t\tINSERT INTO movieinfo\n\t\t\t\t\t(imdbid, tmdbid, title, rating, tagline, plot, year, genre, type,\n\t\t\t\t\tdirector, actors, language, cover, backdrop, createddate, updateddate)\n\t\t\t\tVALUES\n\t\t\t\t\t(%d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %d, NOW(), NOW())\n\t\t\t\tON DUPLICATE KEY UPDATE\n\t\t\t\t\timdbid = %d, tmdbid = %s, title = %s, rating = %s, tagline = %s, plot = %s, year = %s, genre = %s,\n\t\t\t\t\ttype = %s, director = %s, actors = %s, language = %s, cover = %d, backdrop = %d, updateddate = NOW()", $mov['imdb_id'], $mov['tmdb_id'], $this->pdo->escapeString($mov['title']), $this->pdo->escapeString($mov['rating']), $this->pdo->escapeString($mov['tagline']), $this->pdo->escapeString($mov['plot']), $this->pdo->escapeString($mov['year']), $this->pdo->escapeString(substr($mov['genre'], 0, 64)), $this->pdo->escapeString($mov['type']), $this->pdo->escapeString($mov['director']), $this->pdo->escapeString($mov['actors']), $this->pdo->escapeString(substr($mov['language'], 0, 64)), $mov['cover'], $mov['backdrop'], $mov['imdb_id'], $mov['tmdb_id'], $this->pdo->escapeString($mov['title']), $this->pdo->escapeString($mov['rating']), $this->pdo->escapeString($mov['tagline']), $this->pdo->escapeString($mov['plot']), $this->pdo->escapeString($mov['year']), $this->pdo->escapeString(substr($mov['genre'], 0, 64)), $this->pdo->escapeString($mov['type']), $this->pdo->escapeString($mov['director']), $this->pdo->escapeString($mov['actors']), $this->pdo->escapeString(substr($mov['language'], 0, 64)), $mov['cover'], $mov['backdrop']));
     if ($this->echooutput && $this->service !== '') {
         $this->pdo->log->doEcho($this->pdo->log->headerOver($movieID !== 0 ? 'Added/updated movie: ' : 'Nothing to update for movie: ') . $this->pdo->log->primary($mov['title'] . ' (' . $mov['year'] . ') - ' . $mov['imdb_id']));
     }
     return $movieID === 0 ? false : true;
 }
Example #6
0
    /**
     * @param string $bookInfo
     * @param null   $amazdata
     *
     * @return false|int|string
     */
    public function updateBookInfo($bookInfo = '', $amazdata = null)
    {
        $ri = new ReleaseImage($this->pdo);
        $book = [];
        $amaz = false;
        if ($bookInfo != '') {
            $amaz = $this->fetchAmazonProperties($bookInfo);
        } else {
            if ($amazdata != null) {
                $amaz = $amazdata;
            }
        }
        if (!$amaz) {
            return false;
        }
        $book['title'] = (string) $amaz->Items->Item->ItemAttributes->Title;
        $book['author'] = (string) $amaz->Items->Item->ItemAttributes->Author;
        $book['asin'] = (string) $amaz->Items->Item->ASIN;
        $book['isbn'] = (string) $amaz->Items->Item->ItemAttributes->ISBN;
        if ($book['isbn'] == '') {
            $book['isbn'] = 'null';
        }
        $book['ean'] = (string) $amaz->Items->Item->ItemAttributes->EAN;
        if ($book['ean'] == '') {
            $book['ean'] = 'null';
        }
        $book['url'] = (string) $amaz->Items->Item->DetailPageURL;
        $book['url'] = str_replace("%26tag%3Dws", "%26tag%3Dopensourceins%2D21", $book['url']);
        $book['salesrank'] = (string) $amaz->Items->Item->SalesRank;
        if ($book['salesrank'] == '') {
            $book['salesrank'] = 'null';
        }
        $book['publisher'] = (string) $amaz->Items->Item->ItemAttributes->Publisher;
        if ($book['publisher'] == '') {
            $book['publisher'] = 'null';
        }
        $book['publishdate'] = date('Y-m-d', strtotime((string) $amaz->Items->Item->ItemAttributes->PublicationDate));
        if ($book['publishdate'] == '') {
            $book['publishdate'] = 'null';
        }
        $book['pages'] = (string) $amaz->Items->Item->ItemAttributes->NumberOfPages;
        if ($book['pages'] == '') {
            $book['pages'] = 'null';
        }
        if (isset($amaz->Items->Item->EditorialReviews->EditorialReview->Content)) {
            $book['overview'] = strip_tags((string) $amaz->Items->Item->EditorialReviews->EditorialReview->Content);
            if ($book['overview'] == '') {
                $book['overview'] = 'null';
            }
        } else {
            $book['overview'] = 'null';
        }
        if (isset($amaz->Items->Item->BrowseNodes->BrowseNode->Name)) {
            $book['genre'] = (string) $amaz->Items->Item->BrowseNodes->BrowseNode->Name;
            if ($book['genre'] == '') {
                $book['genre'] = 'null';
            }
        } else {
            $book['genre'] = 'null';
        }
        $book['coverurl'] = (string) $amaz->Items->Item->LargeImage->URL;
        if ($book['coverurl'] != '') {
            $book['cover'] = 1;
        } else {
            $book['cover'] = 0;
        }
        $check = $this->pdo->queryOneRow(sprintf('SELECT id FROM bookinfo WHERE asin = %s', $this->pdo->escapeString($book['asin'])));
        if ($check === false) {
            $bookId = $this->pdo->queryInsert(sprintf("\n\t\t\t\t\t\t\t\tINSERT INTO bookinfo\n\t\t\t\t\t\t\t\t\t(title, author, asin, isbn, ean, url, salesrank, publisher, publishdate, pages,\n\t\t\t\t\t\t\t\t\toverview, genre, cover, createddate, updateddate)\n\t\t\t\t\t\t\t\tVALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, now(), now())", $this->pdo->escapeString($book['title']), $this->pdo->escapeString($book['author']), $this->pdo->escapeString($book['asin']), $this->pdo->escapeString($book['isbn']), $this->pdo->escapeString($book['ean']), $this->pdo->escapeString($book['url']), $book['salesrank'], $this->pdo->escapeString($book['publisher']), $this->pdo->escapeString($book['publishdate']), $book['pages'], $this->pdo->escapeString($book['overview']), $this->pdo->escapeString($book['genre']), $book['cover']));
        } else {
            $bookId = $check['id'];
            $this->pdo->queryExec(sprintf('
							UPDATE bookinfo
							SET title = %s, author = %s, asin = %s, isbn = %s, ean = %s, url = %s, salesrank = %s, publisher = %s,
								publishdate = %s, pages = %s, overview = %s, genre = %s, cover = %d, updateddate = NOW()
							WHERE id = %d', $this->pdo->escapeString($book['title']), $this->pdo->escapeString($book['author']), $this->pdo->escapeString($book['asin']), $this->pdo->escapeString($book['isbn']), $this->pdo->escapeString($book['ean']), $this->pdo->escapeString($book['url']), $book['salesrank'], $this->pdo->escapeString($book['publisher']), $this->pdo->escapeString($book['publishdate']), $book['pages'], $this->pdo->escapeString($book['overview']), $this->pdo->escapeString($book['genre']), $book['cover'], $bookId));
        }
        if ($bookId) {
            if ($this->echooutput) {
                $this->pdo->log->doEcho($this->pdo->log->header("Added/updated book: "));
                if ($book['author'] !== '') {
                    $this->pdo->log->doEcho($this->pdo->log->alternateOver("   Author: ") . $this->pdo->log->primary($book['author']));
                }
                echo $this->pdo->log->alternateOver("   Title: ") . $this->pdo->log->primary(" " . $book['title']);
                if ($book['genre'] !== 'null') {
                    $this->pdo->log->doEcho($this->pdo->log->alternateOver("   Genre: ") . $this->pdo->log->primary(" " . $book['genre']));
                }
            }
            $book['cover'] = $ri->saveImage($bookId, $book['coverurl'], $this->imgSavePath, 250, 250);
        } else {
            if ($this->echooutput) {
                $this->pdo->log->doEcho($this->pdo->log->header('Nothing to update: ') . $this->pdo->log->primary($book['author'] . ' - ' . $book['title']));
            }
        }
        return $bookId;
    }
Example #7
0
 /**
  * Try to get a preview image from a video file.
  *
  * @param string $fileLocation
  *
  * @return bool
  */
 protected function _getSample($fileLocation)
 {
     if (!$this->_processThumbnails) {
         return false;
     }
     if (is_file($fileLocation)) {
         // Create path to temp file.
         $fileName = $this->tmpPath . 'zzzz' . mt_rand(5, 12) . mt_rand(5, 12) . '.jpg';
         $time = $this->getVideoTime($fileLocation);
         // Create the image.
         Misc::runCmd($this->_killString . $this->pdo->getSetting('ffmpegpath') . '" -i "' . $fileLocation . '" -ss ' . ($time === '' ? '00:00:03.00' : $time) . ' -vframes 1 -loglevel quiet -y "' . $fileName . '"');
         // Check if the file exists.
         if (is_file($fileName)) {
             // Try to resize/move the image.
             $saved = $this->_releaseImage->saveImage($this->_release['guid'] . '_thumb', $fileName, $this->_releaseImage->imgSavePath, 800, 600);
             // Delete the temp file we created.
             @unlink($fileName);
             // Check if it saved.
             if ($saved === 1) {
                 if ($this->_echoCLI) {
                     $this->_echo('s', 'primaryOver', false);
                 }
                 return true;
             }
         }
     }
     return false;
 }
Example #8
0
    /**
     * @param array $con
     *
     * @return false|int|string
     */
    protected function _updateConsoleTable($con = [])
    {
        $ri = new ReleaseImage($this->pdo);
        $check = $this->pdo->queryOneRow(sprintf('
							SELECT id
							FROM consoleinfo
							WHERE asin = %s', $this->pdo->escapeString($con['asin'])));
        if ($check === false) {
            $consoleId = $this->pdo->queryInsert(sprintf("INSERT INTO consoleinfo (title, asin, url, salesrank, platform, publisher, genre_id, esrb, releasedate, review, cover, createddate, updateddate)\n\t\t\t\t\tVALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, NOW(), NOW())", $this->pdo->escapeString($con['title']), $this->pdo->escapeString($con['asin']), $this->pdo->escapeString($con['url']), $con['salesrank'], $this->pdo->escapeString($con['platform']), $this->pdo->escapeString($con['publisher']), $con['consolegenreID'] == -1 ? "null" : $con['consolegenreID'], $this->pdo->escapeString($con['esrb']), $con['releasedate'] != "" ? $this->pdo->escapeString($con['releasedate']) : "null", $this->pdo->escapeString(substr($con['review'], 0, 3000)), $con['cover']));
            if ($con['cover'] === 1) {
                $con['cover'] = $ri->saveImage($consoleId, $con['coverurl'], $this->imgSavePath, 250, 250);
            }
        } else {
            $consoleId = $check['id'];
            if ($con['cover'] === 1) {
                $con['cover'] = $ri->saveImage($consoleId, $con['coverurl'], $this->imgSavePath, 250, 250);
            }
            $this->update($consoleId, $con['title'], $con['asin'], $con['url'], $con['salesrank'], $con['platform'], $con['publisher'], isset($con['releasedate']) ? $con['releasedate'] : null, $con['esrb'], $con['cover'], $con['consolegenreID'], isset($con['review']) ? $con['review'] : null);
        }
        return $consoleId;
    }
Example #9
0
 /**
  * Fetch xxx info for the movie.
  *
  * @param string $xxxmovie
  *
  * @return boolean
  */
 public function updateXXXInfo($xxxmovie)
 {
     $res = false;
     $this->whichclass = '';
     $iafd = new IAFD();
     $iafd->searchTerm = $xxxmovie;
     if ($iafd->findme() !== false) {
         switch ($iafd->classUsed) {
             case "ade":
                 $mov = new ADE();
                 $mov->directLink = (string) $iafd->directUrl;
                 $res = $mov->getDirect();
                 $res['title'] = $iafd->title;
                 $res['directurl'] = (string) $iafd->directUrl;
                 $this->whichclass = $iafd->classUsed;
                 $this->pdo->log->doEcho($this->pdo->log->primary("Fetching XXX info from IAFD -> Adult DVD Empire"));
                 break;
         }
     }
     if ($res === false) {
         $this->whichclass = "aebn";
         $mov = new AEBN();
         $mov->cookie = $this->cookie;
         $mov->searchTerm = $xxxmovie;
         $res = $mov->search();
         if ($res === false) {
             $this->whichclass = "ade";
             $mov = new ADE();
             $mov->searchTerm = $xxxmovie;
             $res = $mov->search();
         }
         if ($res === false) {
             $this->whichclass = "pop";
             $mov = new Popporn();
             $mov->cookie = $this->cookie;
             $mov->searchTerm = $xxxmovie;
             $res = $mov->search();
         }
         // Last in list as it doesn't have trailers
         if ($res === false) {
             $this->whichclass = "adm";
             $mov = new ADM();
             $mov->cookie = $this->cookie;
             $mov->searchTerm = $xxxmovie;
             $res = $mov->search();
         }
         // If a result is true getAll information.
         if ($res !== false) {
             if ($this->echooutput) {
                 switch ($this->whichclass) {
                     case "aebn":
                         $fromstr = "Adult Entertainment Broadcast Network";
                         break;
                     case "ade":
                         $fromstr = "Adult DVD Empire";
                         break;
                     case "pop":
                         $fromstr = "PopPorn";
                         break;
                     case "adm":
                         $fromstr = "Adult DVD Marketplace";
                         break;
                     default:
                         $fromstr = null;
                 }
                 $this->pdo->log->doEcho($this->pdo->log->primary("Fetching XXX info from: " . $fromstr));
             }
             $res = $mov->getAll();
         } else {
             // Nothing was found, go ahead and set to -2
             return -2;
         }
     }
     $mov = [];
     $mov['trailers'] = isset($res['trailers']) ? serialize($res['trailers']) : '';
     $mov['extras'] = isset($res['extras']) ? serialize($res['extras']) : '';
     $mov['productinfo'] = isset($res['productinfo']) ? serialize($res['productinfo']) : '';
     $mov['backdrop'] = isset($res['backcover']) ? $res['backcover'] : 0;
     $mov['cover'] = isset($res['boxcover']) ? $res['boxcover'] : 0;
     $res['cast'] = isset($res['cast']) ? join(",", $res['cast']) : '';
     $res['genres'] = isset($res['genres']) ? $this->getgenreid($res['genres']) : '';
     $mov['title'] = html_entity_decode($res['title'], ENT_QUOTES, 'UTF-8');
     $mov['plot'] = isset($res['sypnosis']) ? html_entity_decode($res['sypnosis'], ENT_QUOTES, 'UTF-8') : '';
     $mov['tagline'] = isset($res['tagline']) ? html_entity_decode($res['tagline'], ENT_QUOTES, 'UTF-8') : '';
     $mov['genre'] = html_entity_decode($res['genres'], ENT_QUOTES, 'UTF-8');
     $mov['director'] = isset($res['director']) ? html_entity_decode($res['director'], ENT_QUOTES, 'UTF-8') : '';
     $mov['actors'] = html_entity_decode($res['cast'], ENT_QUOTES, 'UTF-8');
     $mov['directurl'] = html_entity_decode($res['directurl'], ENT_QUOTES, 'UTF-8');
     $mov['classused'] = $this->whichclass;
     $check = $this->pdo->queryOneRow(sprintf('SELECT id FROM xxxinfo WHERE title = %s', $this->pdo->escapeString($mov['title'])));
     $xxxID = 0;
     if (isset($check['id'])) {
         $xxxID = $check['id'];
     }
     if ($check === false || $xxxID > 0) {
         // Update Current XXX Information - getXXXCovers.php
         if ($xxxID > 0) {
             $this->update($check['id'], $mov['title'], $mov['tagline'], $mov['plot'], $mov['genre'], $mov['director'], $mov['actors'], $mov['extras'], $mov['productinfo'], $mov['trailers'], $mov['directurl'], $mov['classused']);
             $xxxID = $check['id'];
         }
         // Insert New XXX Information
         if ($check === false) {
             $xxxID = $this->pdo->queryInsert(sprintf("\n\t\t\t\t\tINSERT INTO xxxinfo\n\t\t\t\t\t\t(title, tagline, plot, genre, director, actors, extras, productinfo, trailers, directurl, classused, cover, backdrop, createddate, updateddate)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t(%s, %s, COMPRESS(%s), %s, %s, %s, %s, %s, %s, %s, %s, 0, 0, NOW(), NOW())", $this->pdo->escapeString($mov['title']), $this->pdo->escapeString($mov['tagline']), $this->pdo->escapeString($mov['plot']), $this->pdo->escapeString(substr($mov['genre'], 0, 64)), $this->pdo->escapeString($mov['director']), $this->pdo->escapeString($mov['actors']), $this->pdo->escapeString($mov['extras']), $this->pdo->escapeString($mov['productinfo']), $this->pdo->escapeString($mov['trailers']), $this->pdo->escapeString($mov['directurl']), $this->pdo->escapeString($mov['classused'])));
         }
         if ($xxxID > 0) {
             // BoxCover.
             if (isset($mov['cover'])) {
                 $mov['cover'] = $this->releaseImage->saveImage($xxxID . '-cover', $mov['cover'], $this->imgSavePath);
             }
             // BackCover.
             if (isset($mov['backdrop'])) {
                 $mov['backdrop'] = $this->releaseImage->saveImage($xxxID . '-backdrop', $mov['backdrop'], $this->imgSavePath, 1920, 1024);
             }
             $this->pdo->queryExec(sprintf('UPDATE xxxinfo SET cover = %d, backdrop = %d  WHERE id = %d', $mov['cover'], $mov['backdrop'], $xxxID));
         } else {
             $xxxID = -2;
         }
     }
     if ($this->echooutput) {
         $this->pdo->log->doEcho($this->pdo->log->headerOver($xxxID !== false ? 'Added/updated XXX movie: ' : 'Nothing to update: ') . $this->pdo->log->primary($mov['title']));
     }
     return $xxxID;
 }
Example #10
0
 /**
  * Retrieves the poster art for the processed show
  *
  * @param int $videoId -- the local Video ID
  * @param int $showId  -- the TVMaze ID
  *
  * @return int
  */
 public function getPoster($videoId, $showId = 0)
 {
     $ri = new ReleaseImage($this->pdo);
     // Try to get the Poster
     $hascover = $ri->saveImage($videoId, $this->posterUrl, $this->imgSavePath, '', '');
     // Mark it retrieved if we saved an image
     if ($hascover == 1) {
         $this->setCoverFound($videoId);
     }
     return $hascover;
 }
Example #11
0
 /**
  * Retrieves the poster art for the processed show
  *
  * @param int $videoId -- the local Video ID
  * @param int $showId -- the TVDB ID
  *
  * @return null
  */
 protected function getPoster($videoId, $showId)
 {
     $ri = new ReleaseImage($this->pdo);
     // Try to get the Poster
     $hascover = $ri->saveImage($videoId, sprintf($this->posterUrl, $showId), $this->imgSavePath, '', '');
     // Couldn't get poster, try fan art instead
     if ($hascover !== 1) {
         $hascover = $ri->saveImage($videoId, sprintf($this->fanartUrl, $showId), $this->imgSavePath, '', '');
     }
     // Mark it retrieved if we saved an image
     if ($hascover == 1) {
         $this->setCoverFound($videoId);
     }
 }
Example #12
0
 /**
  * Retrieve poster image for TV episode from site using its API.
  *
  * @param integer $videoId ID from videos table.
  * @param integer $siteId  ID that this site uses for the programme.
  *
  * @return null
  */
 public function getPoster($videoId, $siteId)
 {
     $hascover = 0;
     $ri = new ReleaseImage($this->pdo);
     if ($this->posterUrl !== '') {
         // Try to get the Poster
         $hascover = $ri->saveImage($videoId, $this->posterUrl, $this->imgSavePath, '', '');
     }
     // Couldn't get poster, try fan art instead
     if ($hascover !== 1 && $this->fanartUrl !== '') {
         $hascover = $ri->saveImage($videoId, $this->fanartUrl, $this->imgSavePath, '', '');
     }
     // Mark it retrieved if we saved an image
     if ($hascover == 1) {
         $this->setCoverFound($videoId);
     }
 }