From d5be3b2e45891e0164162c0b6190784c2199a3e4 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Sat, 6 Apr 2019 11:19:05 +0200 Subject: [PATCH] Remove padding of imdbid as column is now varchar and stores imdbid properly --- Blacklight/Movie.php | 34 +++++++++--------- Blacklight/Releases.php | 2 +- Blacklight/http/XML_Response.php | 2 +- Changelog | 1 + misc/testing/DB/add_movieinfo_id.php | 2 +- misc/testing/PostProc/getTraktData.php | 4 +-- resources/views/themes/Gentele/movies.tpl | 36 +++++++++---------- resources/views/themes/Gentele/search.tpl | 2 +- .../views/themes/Gentele/viewmoviefull.tpl | 10 +++--- resources/views/themes/Gentele/viewnzb.tpl | 4 +-- resources/views/themes/admin/movie-list.tpl | 8 ++--- 11 files changed, 53 insertions(+), 52 deletions(-) diff --git a/Blacklight/Movie.php b/Blacklight/Movie.php index e0a04b3ef..f8c42427b 100755 --- a/Blacklight/Movie.php +++ b/Blacklight/Movie.php @@ -212,7 +212,7 @@ class Movie */ public function getMovieInfo($imdbId) { - return MovieInfo::query()->where('imdbid', str_pad($imdbId, 8, '0', STR_PAD_LEFT))->first(); + return MovieInfo::query()->where('imdbid', $imdbId)->first(); } /** @@ -596,16 +596,16 @@ class Movie } // Check TMDB for IMDB info. - $tmdb = $this->fetchTMDBProperties(str_pad($imdbId, 8, '0', STR_PAD_LEFT)); + $tmdb = $this->fetchTMDBProperties($imdbId); // Check IMDB for movie info. - $imdb = $this->fetchIMDBProperties(str_pad($imdbId, 8, '0', STR_PAD_LEFT)); + $imdb = $this->fetchIMDBProperties($imdbId); // Check TRAKT for movie info - $trakt = $this->fetchTraktTVProperties(str_pad($imdbId, 8, '0', STR_PAD_LEFT)); + $trakt = $this->fetchTraktTVProperties($imdbId); // Check OMDb for movie info - $omdb = $this->fetchOmdbAPIProperties(str_pad($imdbId, 8, '0', STR_PAD_LEFT)); + $omdb = $this->fetchOmdbAPIProperties($imdbId); // Check iTunes for movie info as last resort (iTunes do not provide all the info we need) @@ -616,40 +616,40 @@ class Movie } // Check FanArt.tv for cover and background images. - $fanart = $this->fetchFanartTVProperties(str_pad($imdbId, 8, '0', STR_PAD_LEFT)); + $fanart = $this->fetchFanartTVProperties($imdbId); $mov = []; $mov['cover'] = $mov['backdrop'] = $mov['banner'] = 0; $mov['type'] = $mov['director'] = $mov['actors'] = $mov['language'] = ''; - $mov['imdbid'] = str_pad($imdbId, 8, '0', STR_PAD_LEFT); + $mov['imdbid'] = $imdbId; $mov['tmdbid'] = (! isset($tmdb['tmdbid']) || $tmdb['tmdbid'] === '') ? 0 : $tmdb['tmdbid']; $mov['traktid'] = (! isset($trakt['id']) || $trakt['id'] === '') ? 0 : $trakt['id']; // Prefer Fanart.tv cover over TMDB,TMDB over IMDB,IMDB over OMDB and OMDB over iTunes. if (! empty($fanart['cover'])) { - $mov['cover'] = $this->releaseImage->saveImage(str_pad($imdbId, 8, '0', STR_PAD_LEFT).'-cover', $fanart['cover'], $this->imgSavePath); + $mov['cover'] = $this->releaseImage->saveImage($imdbId.'-cover', $fanart['cover'], $this->imgSavePath); } elseif (! empty($tmdb['cover'])) { - $mov['cover'] = $this->releaseImage->saveImage(str_pad($imdbId, 8, '0', STR_PAD_LEFT).'-cover', $tmdb['cover'], $this->imgSavePath); + $mov['cover'] = $this->releaseImage->saveImage($imdbId.'-cover', $tmdb['cover'], $this->imgSavePath); } elseif (! empty($imdb['cover'])) { - $mov['cover'] = $this->releaseImage->saveImage(str_pad($imdbId, 8, '0', STR_PAD_LEFT).'-cover', $imdb['cover'], $this->imgSavePath); + $mov['cover'] = $this->releaseImage->saveImage($imdbId.'-cover', $imdb['cover'], $this->imgSavePath); } elseif (! empty($omdb['cover'])) { - $mov['cover'] = $this->releaseImage->saveImage(str_pad($imdbId, 8, '0', STR_PAD_LEFT).'-cover', $omdb['cover'], $this->imgSavePath); + $mov['cover'] = $this->releaseImage->saveImage($imdbId.'-cover', $omdb['cover'], $this->imgSavePath); } elseif (! empty($iTunes['cover'])) { - $mov['cover'] = $this->releaseImage->saveImage(str_pad($imdbId, 8, '0', STR_PAD_LEFT).'-cover', $iTunes['cover'], $this->imgSavePath); + $mov['cover'] = $this->releaseImage->saveImage($imdbId.'-cover', $iTunes['cover'], $this->imgSavePath); } // Backdrops. if (! empty($fanart['backdrop'])) { - $mov['backdrop'] = $this->releaseImage->saveImage(str_pad($imdbId, 8, '0', STR_PAD_LEFT).'-backdrop', $fanart['backdrop'], $this->imgSavePath, 1920, 1024); + $mov['backdrop'] = $this->releaseImage->saveImage($imdbId.'-backdrop', $fanart['backdrop'], $this->imgSavePath, 1920, 1024); } elseif (! empty($tmdb['backdrop'])) { - $mov['backdrop'] = $this->releaseImage->saveImage(str_pad($imdbId, 8, '0', STR_PAD_LEFT).'-backdrop', $tmdb['backdrop'], $this->imgSavePath, 1920, 1024); + $mov['backdrop'] = $this->releaseImage->saveImage($imdbId.'-backdrop', $tmdb['backdrop'], $this->imgSavePath, 1920, 1024); } // Banner if (! empty($fanart['banner'])) { - $mov['banner'] = $this->releaseImage->saveImage(str_pad($imdbId, 8, '0', STR_PAD_LEFT).'-banner', $fanart['banner'], $this->imgSavePath); + $mov['banner'] = $this->releaseImage->saveImage($imdbId.'-banner', $fanart['banner'], $this->imgSavePath); } // RottenTomatoes rating from OmdbAPI @@ -1100,7 +1100,7 @@ class Movie $movieInfoId = MovieInfo::query()->where('imdbid', $imdbID)->first(['id']); - Release::query()->where('id', $id)->update(['imdbid' => str_pad($imdbID, 8, '0', STR_PAD_LEFT), 'movieinfo_id' => $movieInfoId !== null ? $movieInfoId['id'] : null]); + Release::query()->where('id', $id)->update(['imdbid' =>$imdbID, 'movieinfo_id' => $movieInfoId !== null ? $movieInfoId['id'] : null]); // If set, scan for imdb info. if ($processImdb === 1) { @@ -1112,7 +1112,7 @@ class Movie } elseif ($info === true) { $movieInfoId = MovieInfo::query()->where('imdbid', $imdbID)->first(['id']); - Release::query()->where('id', $id)->update(['imdbid' => str_pad($imdbID, 8, '0', STR_PAD_LEFT), 'movieinfo_id' => $movieInfoId !== null ? $movieInfoId['id'] : null]); + Release::query()->where('id', $id)->update(['imdbid' =>$imdbID, 'movieinfo_id' => $movieInfoId !== null ? $movieInfoId['id'] : null]); } } } diff --git a/Blacklight/Releases.php b/Blacklight/Releases.php index bd452600d..5ec9635bb 100755 --- a/Blacklight/Releases.php +++ b/Blacklight/Releases.php @@ -1164,7 +1164,7 @@ class Releases extends Release $this->showPasswords(), (! empty($searchResult) ? 'AND r.id IN ('.implode(',', $searchResult).')' : ''), ! empty($tags) ? " AND tt.tag_name IN ('".implode("','", $tags)."')" : '', - ($imDbId !== -1 && is_numeric($imDbId)) ? sprintf(' AND m.imdbid = %d ', str_pad($imDbId, 8, '0', STR_PAD_LEFT)) : '', + ($imDbId !== -1 && is_numeric($imDbId)) ? sprintf(' AND m.imdbid = %d ', $imDbId) : '', ($tmDbId !== -1 && is_numeric($tmDbId)) ? sprintf(' AND m.tmdbid = %d ', $tmDbId) : '', ($traktId !== -1 && is_numeric($traktId)) ? sprintf(' AND m.traktid = %d ', $traktId) : '', ! empty($excludedCategories) ? sprintf('AND r.categories_id NOT IN('.implode(',', $excludedCategories).')') : '', diff --git a/Blacklight/http/XML_Response.php b/Blacklight/http/XML_Response.php index bb33569d7..66c5ed791 100755 --- a/Blacklight/http/XML_Response.php +++ b/Blacklight/http/XML_Response.php @@ -479,7 +479,7 @@ class XML_Response $this->writeZedAttr('tvmazeid', $this->release->tvmaze); } if (isset($this->release->imdb) && $this->release->imdb > 0) { - $this->writeZedAttr('imdbid', str_pad($this->release->imdb, 8, '0', STR_PAD_LEFT)); + $this->writeZedAttr('imdbid', $this->release->imdb); } if (isset($this->release->tmdb) && $this->release->tmdb > 0) { $this->writeZedAttr('tmdbid', $this->release->tmdb); diff --git a/Changelog b/Changelog index b28ddf327..8ece72834 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2019-04-06 DariusIII + * Chg: Remove padding of imdbid as column is now varchar and stores imdbid properly * Chg: Use our own is_it_json function 2019-04-05 DariusIII * Fix: Update Forking class, fix releases check query diff --git a/misc/testing/DB/add_movieinfo_id.php b/misc/testing/DB/add_movieinfo_id.php index 1a083eec4..94ae0e9e4 100644 --- a/misc/testing/DB/add_movieinfo_id.php +++ b/misc/testing/DB/add_movieinfo_id.php @@ -27,7 +27,7 @@ $count = $sql->count(); echo 'Copying '.$count.' imdbid values'.PHP_EOL; foreach ($sql as $movie) { - DB::table('movie_temp')->insert(['releases_id' => $movie['id'], 'imdbid' => str_pad($movie['imdbid'], 8, '0', STR_PAD_LEFT)]); + DB::table('movie_temp')->insert(['releases_id' => $movie['id'], 'imdbid' => $movie['imdbid']]); echo '.'; } diff --git a/misc/testing/PostProc/getTraktData.php b/misc/testing/PostProc/getTraktData.php index 9c90e1d17..2296033eb 100644 --- a/misc/testing/PostProc/getTraktData.php +++ b/misc/testing/PostProc/getTraktData.php @@ -17,9 +17,9 @@ if ($count > 0) { $colorCli->primary('Updating '.number_format($count).' movies for TraktTV id.'); foreach ($movies as $mov) { $traktTv = new TraktTv(['Settings' => null]); - $traktmovie = $traktTv->client->movieSummary('tt'.str_pad($mov['imdbid'], 7, '0', STR_PAD_LEFT), 'full'); + $traktmovie = $traktTv->client->movieSummary('tt'.$mov['imdbid'], 'full'); if ($traktmovie !== false) { - $colorCli->info('Updating IMDb id: tt'.str_pad($mov['imdbid'], 7, '0', STR_PAD_LEFT)); + $colorCli->info('Updating IMDb id: tt'.$mov['imdbid']); $trakt = $movie->parseTraktTv($traktmovie); if ($trakt === true) { $colorCli->info('Added traktid: '.$traktmovie['ids']['trakt']); diff --git a/resources/views/themes/Gentele/movies.tpl b/resources/views/themes/Gentele/movies.tpl index 3258225ae..cc8cf265e 100755 --- a/resources/views/themes/Gentele/movies.tpl +++ b/resources/views/themes/Gentele/movies.tpl @@ -92,21 +92,21 @@ {assign var="mhaspreview" value=","|explode:$result->grp_haspreview} {foreach $msplits as $m} {if $m@first} - {$result->title|escape: {if !empty($mfailed[$m@index])} {/if} IMDB TRAKT {if (!empty($result->tmdbid))} Group - Add + Add
{$result->title|escape:"htmlall"} + href="{$smarty.const.WWW_TOP}/Movies?imdb={$result->imdbid}">{$result->title|escape:"htmlall"}
{if $result->genre != ''} Genre: {$result->genre}, {/if}
@@ -183,7 +183,7 @@ {/if} {if !empty($cpurl) && !empty($cpapi)} grp_haspreview} {foreach $msplits as $m} {if $m@first} - {$result->title|escape: {if !empty($mfailed[$m@index])} {/if} IMDB TRAKT {if (!empty($result->tmdbid))} Group - Add + Add
{$result->title|escape:"htmlall"} + href="{$smarty.const.WWW_TOP}/Movies?imdb={$result->imdbid}">{$result->title|escape:"htmlall"}
{if $result->genre != ''} Genre: {$result->genre}, {/if}
@@ -328,7 +328,7 @@ {/if} {if !empty($cpurl) && !empty($cpapi)} Nfo {/if} {if $result->imdbid > 0} - Cover {/if} {if $result->haspreview == 1 && $userdata->can('preview') == true} diff --git a/resources/views/themes/Gentele/viewmoviefull.tpl b/resources/views/themes/Gentele/viewmoviefull.tpl index 2a5233f5c..a177c5b59 100755 --- a/resources/views/themes/Gentele/viewmoviefull.tpl +++ b/resources/views/themes/Gentele/viewmoviefull.tpl @@ -16,7 +16,7 @@ {if $result->cover == 1} {$result->title|escape: + src="{$smarty.const.WWW_TOP}/covers/movies/{$result->imdbid}-cover.jpg"/> {else} {$result->title|escape:{$result->title|escape:"htmlall"} ({$result->year}) IMDB + href="{$site->dereferrer_link}http://www.imdb.com/title/tt{$result->imdbid}/" + name="imdb{$result->imdbid}" title="View IMDB page">IMDB TRAKT + href="{$site->dereferrer_link}http://trakt.tv/search/imdb/tt{$result->imdbid}/" + name="trakt{$result->imdbid}" title="View Trakt page" rel="trakt">TRAKT {if (!empty($result->tmdbid))}