i made some changes now the update works on 2.9
but will create two records without info
and it gives some error i think is because the script is trying to create a record with same value
im not expert with php anyone could help?
Error updating record: Duplicate entry '4021-1' for key
$conn = new mysqli($servername, $username, $password, $dbname, $port);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$dir = "/home/movies/";
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($titulocompleto = readdir($dh)) !== false) {
// echo "Titulo Completo: $titulocompleto \n";
list($titulo) = explode('.elimino', $titulocompleto);
$titulo = preg_replace('/\./', ' ', $titulo);
$sql = "INSERT INTO `streams` (`id`, `type`, `category_id`, `stream_display_name`, `stream_source`, `stream_icon`, `notes`, `created_channel_location`, `enable_transcode`, `transcode_attributes`, `custom_ffmpeg`, `movie_propeties`, `movie_subtitles`, `read_native`, `target_container`, `stream_all`, `remove_subtitles`, `custom_sid`, `epg_id`, `channel_id`, `epg_lang`, `order`, `auto_restart`, `transcode_profile_id`, `pids_create_channel`, `cchannel_rsources`, `gen_timestamps`, `added`, `series_no`, `direct_source`, `tv_archive_duration`, `tv_archive_server_id`, `tv_archive_pid`, `movie_symlink`, `redirect_stream`, `rtmp_output`, `number`, `allow_record`, `probesize_ondemand`, `custom_map`, `external_push`, `delay_minutes`) VALUES(NULL, 2, 2, '$titulo', '[\"s:$loco:\\/home\\/vod\\/vod$ano\\/$titulocompleto\"]', '', '', NULL, 0, '[]', '', '{\"kinopoisk_url\":\"\",\"tmdb_id\":\"\",\"name\":\"teste\",\"o_name\":\"teste\",\"cover_big\":\"\",\"movie_image\":\"\",\"releasedate\":\"\",\"episode_run_time\":\"\",\"youtube_trailer\":\"\",\"director\":\"\",\"actors\":\"\",\"cast\":\"\",\"description\":\"\",\"plot\":\"\",\"age\":\"\",\"mpaa_rating\":\"\",\"rating_count_kinopoisk\":0,\"country\":\"\",\"genre\":\"\",\"backdrop_path\":[\"\"],\"duration_secs\":0,\"duration\":\"00:00:00\",\"video\":[],\"audio\":[],\"bitrate\":0,\"rating\":\"\"}', '[]', 1, '[\"mp4\"]', 0, 0, '', NULL, NULL, NULL, 0, '[]', 0, '', '', 1, 1572628798, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 128000, '', '[]', 0)";
if ($conn->query($sql) === TRUE) {
echo "Record updated successfully \n";
} else {
echo "Error updating record: " . $conn->error;
}
$sql = "SELECT * FROM streams WHERE stream_display_name = '{$titulo}'";
$resultado = $conn->query($sql);
if ($resultado = $resultado->fetch_array(MYSQLI_ASSOC)) {
$stream_id = $resultado['id'];
} else {
echo "Error updating record: " . $conn->error;
}
$sql = "INSERT INTO `streams_sys` (`server_stream_id`, `stream_id`, `server_id`, `parent_id`, `pid`, `to_analyze`, `stream_status`, `stream_started`, `stream_info`, `monitor_pid`, `current_source`, `bitrate`, `progress_info`, `on_demand`, `delay_pid`, `delay_available_at`) VALUES (NULL, $stream_id, 1, NULL, NULL, 0, 0, NULL, '', NULL, NULL, NULL, '', 1, NULL, 0)";
if ($conn->query($sql) === TRUE) {
echo "Record updated successfully \n";
} else {
echo "Error updating record: " . $conn->error;
}
}
}
}
$conn->close();
closedir($dh);
?>