Hello,
After I loose all my works/files couple days ago, I am trying to fix them with old backups.
Below I call a php file with shell script and it injects processed data into related database in mysql .
Current process gives below output:
http://127.0.0.1/vod-www/Top Gun 1986.mkv
But I wish to have get:
http://127.0.0.1/vod-www/TopGun.mkv
I am starting to explain... A bit big file, I am sorry...
I have run.sh, imdb.class.php, inject.php and list_of_movies.txt file
./run.sh
run.sh
while read -r line;do
php 44.php $line
sleep 2
done<list_of_movies.txt
list_of_movies.txt
TopGun.mkv
44.php
<?php
include_once 'imdb.class.php';
//mysql config.
$servername = "127.0.0.1";
$username = "root";
$password = "my_password";
$dbname = "stalker_db";
$dbport = "3306";
//open mysql connection.
$conn = new mysqli($servername, $username, $password, $dbname, $dbport);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
//read video database to array.
$sql = mysqli_query($conn, "select * from video ORDER BY name ASC");
while ($row = mysqli_fetch_assoc($sql)) {
$video[] = $row;
}
#################################################################
# $aTests = [
# '$argv',
# ];
#################################################################
//grab info from imdb.
$i = 1 ;
#foreach ($aTests as $sMovie) { #--------!!!
foreach($argv as $sMovie) {
$i++;
$IMDB = new IMDB($sMovie);
if ($IMDB->isReady) {
$title = $IMDB->getTitle($bForceLocal = true);
$description = mysqli_real_escape_string($conn, $IMDB->getDescription());
$plot = mysqli_real_escape_string($conn, $IMDB->getPlot($iLimit = 0));
..
..
..#to make it shorter, had to delete other lines###
if (!isset($last_id)) {
$adddate = date('y-m-d H:i:s');
$sql = "INSERT INTO video (name, o_name, cost, time, protocol, category_id, cat_genre_id_1, accessed, status, description, director, country, year, actors, added, rating_kinopoisk, rating_mpaa)
VALUES ('$title $year', '$title $year', '0', '$runtime', '', '2030', '459', '1', '1', '$description', '$director', '$country', '$year', '$cast', '$adddate', '$rating', '$mpaa')";
if ($conn->query($sql) !== TRUE) {
echo '<p style="text-align: center;">Error: ' . $sql . '<br>' . $conn->error . '</p>';
} else {
$last_id = $conn->insert_id;
}
//get next id for screenshots table.
$sql = mysqli_query($conn, "SHOW TABLE STATUS LIKE 'screenshots'");
$next_screenshot = mysqli_fetch_assoc($sql)['Auto_increment'];
//now we will add poster to movie.
$screenshot_file = $next_screenshot . '.jpeg';
if (!copy("/root/$poster", "/var/www/stalker_portal/screenshots/136/$screenshot_file")) {
echo "failed to copy $screenshot_file...\n";
}
$sql = "INSERT INTO screenshots (name, type, media_id)
VALUES ('$screenshot_file', 'image/jpeg', '$last_id')";
if ($conn->query($sql) !== TRUE) {
echo '<p style="text-align: center;">Error: ' . $sql . '<br>' . $conn->error . '</p>';
}
//add file under movie directory.
$url = 'http://127.0.0.1/vod-www/'.$title.'.'.$year.'.mkv';
..
..
#then insert into sql commands follow....
$result = mysqli_query($conn, "SELECT * FROM video_series_files WHERE url='$url'");
The problem is related to this field:
//add file under movie directory.
$url = 'http://127.0.0.1/vod-www/'.$title.'.'.$year.'.mkv';
The data injected into mysql table is:
http://127.0.0.1/vod-www/Top Gun 1986.mkv
But I wish to have get:
http://127.0.0.1/vod-www/TopGun.mkv
I replaced:
$url = 'http://127.0.0.1/vod-www/'.$title.'.'.$year.'.mkv';
by
$url = 'http://127.0.0.1/vod-www/'$xargv'.';
but did not work. Also tried different variations but no luck.
I have checked my previous posts and I do not remember how I solved it earlier.
Thank you
Boris
Solved now:
I assumed that I should create a variable for filename but have just seen that a variable for that purpose was already created earlier in code..
$url = 'http://127.0.0.1/vod-www/'.$sMovie.'.mkv';
Solved the problem
Kind regards
Boris