fix bug of non existing insert query
This commit is contained in:
parent
653146213e
commit
c2991bcd50
@ -54,7 +54,7 @@ class VideoParser {
|
|||||||
$arr = scandir($foldername);
|
$arr = scandir($foldername);
|
||||||
|
|
||||||
foreach ($arr as $elem) {
|
foreach ($arr as $elem) {
|
||||||
if($elem == '.' || $elem == '..') continue;
|
if ($elem == '.' || $elem == '..') continue;
|
||||||
|
|
||||||
$ext = pathinfo($elem, PATHINFO_EXTENSION);
|
$ext = pathinfo($elem, PATHINFO_EXTENSION);
|
||||||
if ($ext == "mp4") {
|
if ($ext == "mp4") {
|
||||||
@ -136,45 +136,39 @@ class VideoParser {
|
|||||||
// convert video to base64
|
// convert video to base64
|
||||||
$backpic64 = 'data:image/jpeg;base64,' . base64_encode($backpic);
|
$backpic64 = 'data:image/jpeg;base64,' . base64_encode($backpic);
|
||||||
|
|
||||||
|
// set default insert query without tmdb poster
|
||||||
|
$insert_query = "INSERT INTO videos(movie_name,movie_url,thumbnail,quality,length)
|
||||||
|
VALUES ('" . mysqli_real_escape_string($this->conn, $moviename) . "',
|
||||||
|
'" . mysqli_real_escape_string($this->conn, $this->videopath . $filename) . "',
|
||||||
|
'$backpic64',
|
||||||
|
'$width',
|
||||||
|
'$duration')";
|
||||||
|
|
||||||
// check if tmdb grabbing is enabled
|
// check if tmdb grabbing is enabled
|
||||||
if ($this->TMDBenabled) {
|
if ($this->TMDBenabled) {
|
||||||
// search in tmdb api
|
// search in tmdb api
|
||||||
try {
|
if (!is_null($dta = $this->tmdb->searchMovie($moviename, $year))) {
|
||||||
if (!is_null($dta = $this->tmdb->searchMovie($moviename, $year))) {
|
$poster = file_get_contents($this->tmdb->picturebase . $dta->poster_path);
|
||||||
$poster = file_get_contents($this->tmdb->picturebase . $dta->poster_path);
|
|
||||||
|
|
||||||
// error handling for download error
|
// error handling for download error
|
||||||
if ($poster) {
|
if ($poster) {
|
||||||
$poster_base64 = 'data:image/jpeg;base64,' . base64_encode($poster);
|
$poster_base64 = 'data:image/jpeg;base64,' . base64_encode($poster);
|
||||||
|
|
||||||
$insert_query = "INSERT INTO videos(movie_name,movie_url,poster,thumbnail,quality,length)
|
// override insert query if pic loaded correctly
|
||||||
|
$insert_query = "INSERT INTO videos(movie_name,movie_url,poster,thumbnail,quality,length)
|
||||||
VALUES ('" . mysqli_real_escape_string($this->conn, $moviename) . "',
|
VALUES ('" . mysqli_real_escape_string($this->conn, $moviename) . "',
|
||||||
'" . mysqli_real_escape_string($this->conn, $this->videopath . $filename) . "',
|
'" . mysqli_real_escape_string($this->conn, $this->videopath . $filename) . "',
|
||||||
'$backpic64',
|
'$backpic64',
|
||||||
'$poster_base64',
|
'$poster_base64',
|
||||||
'$width',
|
'$width',
|
||||||
'$duration')";
|
'$duration')";
|
||||||
} else {
|
|
||||||
throw new Exception("faild to load pic");
|
|
||||||
}
|
|
||||||
// store genre ids for parsing later
|
|
||||||
$genres = $dta->genre_ids;
|
|
||||||
} else {
|
|
||||||
// nothing found with tmdb
|
|
||||||
echo "my moviename: " . $moviename;
|
|
||||||
|
|
||||||
$this->writeLog("nothing found with TMDB! -- $moviename\n");
|
|
||||||
throw new Exception("nothing found with TMDB! -- $moviename");
|
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
// store genre ids for parsing later
|
||||||
echo $e->getMessage();
|
$genres = $dta->genre_ids;
|
||||||
|
} else {
|
||||||
$insert_query = "INSERT INTO videos(movie_name,movie_url,thumbnail,quality,length)
|
// nothing found with tmdb
|
||||||
VALUES ('" . mysqli_real_escape_string($this->conn, $moviename) . "',
|
echo "my moviename: " . $moviename;
|
||||||
'" . mysqli_real_escape_string($this->conn, $this->videopath . $filename) . "',
|
$this->writeLog("nothing found with TMDB! -- $moviename\n");
|
||||||
'$backpic64',
|
|
||||||
'$width',
|
|
||||||
'$duration')";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user