improved filextension check when reindexing and disable foreign key constraint check when deleting movies
This commit is contained in:
parent
1eddddcbac
commit
15ede7821e
@ -3,6 +3,9 @@ require 'Database.php';
|
|||||||
require 'TMDBMovie.php';
|
require 'TMDBMovie.php';
|
||||||
require 'SSettings.php';
|
require 'SSettings.php';
|
||||||
|
|
||||||
|
// allow UTF8 characters
|
||||||
|
setlocale(LC_ALL, 'en_US.UTF-8');
|
||||||
|
|
||||||
writeLog("starting extraction!\n");
|
writeLog("starting extraction!\n");
|
||||||
|
|
||||||
$ffmpeg = 'ffmpeg'; //or: /usr/bin/ffmpeg , or /usr/local/bin/ffmpeg - depends on your installation (type which ffmpeg into a console to find the install path)
|
$ffmpeg = 'ffmpeg'; //or: /usr/bin/ffmpeg , or /usr/local/bin/ffmpeg - depends on your installation (type which ffmpeg into a console to find the install path)
|
||||||
@ -23,8 +26,8 @@ $deleted = 0;
|
|||||||
$failed = 0;
|
$failed = 0;
|
||||||
|
|
||||||
foreach ($arr as $elem) {
|
foreach ($arr as $elem) {
|
||||||
if ($elem != "." && $elem != "..") {
|
$ext = pathinfo($elem, PATHINFO_EXTENSION);
|
||||||
if (strpos($elem, '.mp4') !== false) {
|
if ($ext == "mp4") {
|
||||||
$moviename = substr($elem, 0, -4);
|
$moviename = substr($elem, 0, -4);
|
||||||
|
|
||||||
$query = "SELECT * FROM videos WHERE movie_name = '" . mysqli_real_escape_string($conn, $moviename) . "'";
|
$query = "SELECT * FROM videos WHERE movie_name = '" . mysqli_real_escape_string($conn, $moviename) . "'";
|
||||||
@ -158,7 +161,6 @@ foreach ($arr as $elem) {
|
|||||||
echo($elem . " does not contain a .mp4 extension! - skipping \n");
|
echo($elem . " does not contain a .mp4 extension! - skipping \n");
|
||||||
writeLog($elem . " does not contain a .mp4 extension! - skipping \n");
|
writeLog($elem . " does not contain a .mp4 extension! - skipping \n");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// auto cleanup db entries
|
// auto cleanup db entries
|
||||||
@ -179,7 +181,7 @@ if ($all < $r['count']) {
|
|||||||
|
|
||||||
while ($r = mysqli_fetch_assoc($result)) {
|
while ($r = mysqli_fetch_assoc($result)) {
|
||||||
if (!file_exists("../" . $r['movie_url'])) {
|
if (!file_exists("../" . $r['movie_url'])) {
|
||||||
$query = "DELETE FROM videos WHERE movie_id='" . $r['movie_id'] . "'";
|
$query = "SET foreign_key_checks = 0; DELETE FROM videos WHERE movie_id='" . $r['movie_id'] . "'";
|
||||||
if ($conn->query($query) === TRUE) {
|
if ($conn->query($query) === TRUE) {
|
||||||
echo('successfully deleted ' . $r['movie_url'] . " from video gravity\n");
|
echo('successfully deleted ' . $r['movie_url'] . " from video gravity\n");
|
||||||
writeLog('successfully deleted ' . $r['movie_url'] . " from video gravity\n");
|
writeLog('successfully deleted ' . $r['movie_url'] . " from video gravity\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user