delete delted movies from db and show db size
This commit is contained in:
parent
e2024e3b11
commit
b1efcd823a
@ -25,7 +25,7 @@
|
|||||||
<script src="js/index.js"></script>
|
<script src="js/index.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>lukis pornhub</h1>
|
<h1>lukis hub</h1>
|
||||||
<div class="videopagewrapper hideit">
|
<div class="videopagewrapper hideit">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-2">
|
<div class="col-sm-2">
|
||||||
|
@ -7,6 +7,7 @@ $arr = scandir("../videos/prn/");
|
|||||||
|
|
||||||
$all = 0;
|
$all = 0;
|
||||||
$added = 0;
|
$added = 0;
|
||||||
|
$deleted = 0;
|
||||||
$failed = 0;
|
$failed = 0;
|
||||||
|
|
||||||
foreach ($arr as $elem) {
|
foreach ($arr as $elem) {
|
||||||
@ -14,6 +15,8 @@ foreach ($arr as $elem) {
|
|||||||
|
|
||||||
$query = "SELECT * FROM videos WHERE movie_name = '" . mysqli_real_escape_string($conn, $elem) . "'";
|
$query = "SELECT * FROM videos WHERE movie_name = '" . mysqli_real_escape_string($conn, $elem) . "'";
|
||||||
$result = $conn->query($query);
|
$result = $conn->query($query);
|
||||||
|
|
||||||
|
// insert if not available in db
|
||||||
if (!mysqli_fetch_assoc($result)) {
|
if (!mysqli_fetch_assoc($result)) {
|
||||||
$pic = shell_exec("ffmpeg -hide_banner -loglevel panic -ss 00:04:00 -i \"../videos/prn/$elem\" -vframes 1 -q:v 2 -f singlejpeg pipe:1 2>/dev/null");
|
$pic = shell_exec("ffmpeg -hide_banner -loglevel panic -ss 00:04:00 -i \"../videos/prn/$elem\" -vframes 1 -q:v 2 -f singlejpeg pipe:1 2>/dev/null");
|
||||||
|
|
||||||
@ -27,15 +30,58 @@ foreach ($arr as $elem) {
|
|||||||
if ($conn->query($query) === TRUE) {
|
if ($conn->query($query) === TRUE) {
|
||||||
echo('successfully added ' . $elem . " to video gravity\n");
|
echo('successfully added ' . $elem . " to video gravity\n");
|
||||||
$added++;
|
$added++;
|
||||||
|
$all++;
|
||||||
} else {
|
} else {
|
||||||
echo('{"data":"' . $conn->error . '"}');
|
echo('errored item: ' . $elem . "\n");
|
||||||
|
echo('{"data":"' . $conn->error . '"}\n');
|
||||||
$failed++;
|
$failed++;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
$all++;
|
$all++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = "SELECT COUNT(*) as count FROM videos";
|
||||||
|
$result = $conn->query($query);
|
||||||
|
$r = mysqli_fetch_assoc($result);
|
||||||
|
|
||||||
|
if ($all < $r['count']) {
|
||||||
|
echo "should be in gravity: " . $all . "\n";
|
||||||
|
echo "really in gravity: " . $r['count'] . "\n";
|
||||||
|
echo "cleaning up gravity\n";
|
||||||
|
|
||||||
|
$query = "SELECT movie_id,movie_url FROM videos";
|
||||||
|
$result = $conn->query($query);
|
||||||
|
|
||||||
|
while ($r = mysqli_fetch_assoc($result)) {
|
||||||
|
if (!file_exists("../" . $r['movie_url'])) {
|
||||||
|
$query = "DELETE FROM videos WHERE movie_id='" . $r['movie_id'] . "'";
|
||||||
|
if ($conn->query($query) === TRUE) {
|
||||||
|
echo('successfully deleted ' . $r['movie_url'] . " from video gravity\n");
|
||||||
|
$deleted++;
|
||||||
|
} else {
|
||||||
|
echo "failed to delete " . $r['movie_url'] . " from gravity: " . $conn->error . "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// calculate size of databse here
|
||||||
|
$size = -1;
|
||||||
|
$query = "SELECT table_schema AS \"Database\",
|
||||||
|
ROUND(SUM(data_length + index_length) / 1024 / 1024, 3) AS \"Size\"
|
||||||
|
FROM information_schema.TABLES
|
||||||
|
WHERE TABLE_SCHEMA='hub'
|
||||||
|
GROUP BY table_schema;";
|
||||||
|
$result = $conn->query($query);
|
||||||
|
if ($result->num_rows == 1) {
|
||||||
|
$row = $result->fetch_assoc();
|
||||||
|
$size = $row["Size"];
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "Total gravity: " . $all . "\n";
|
echo "Total gravity: " . $all . "\n";
|
||||||
|
echo "Size of Databse is: " . $size . "MB\n";
|
||||||
echo "added in this run: " . $added . "\n";
|
echo "added in this run: " . $added . "\n";
|
||||||
|
echo "deleted in this run: " . $deleted . "\n";
|
||||||
echo "errored in this run: " . $failed . "\n";
|
echo "errored in this run: " . $failed . "\n";
|
Loading…
Reference in New Issue
Block a user