function FetchSaveMovie($id, $lookup) { $debug = 0; $video = runSQL('SELECT * FROM ' . TBL_DATA . ' WHERE id = ' . $id); // get fields (according to list) from db to be saved later if ($debug) { echo "\n=================== Video DB Data ============================\n"; print_r($video[0]); echo "\n=================== Video DB Data ============================\n"; } $imdbID = $video[0]['imdbID']; echo "Movie/imdb -- " . $video[0]['title'] . "/" . $video[0]['imdbID'] . "\n"; if (empty($imdbID)) { echo "No imdbID\n"; return; } if (empty($engine)) { $engine = engineGetEngine($imdbID); } if ($debug) { echo "IMDBID = {$imdbID}, engine = {$engine}\n"; } $imdbdata = engineGetData($imdbID, $engine); # removed due to performance issues of is_utf8 // fix erroneous IMDB encoding issues if (!is_utf8($imdbdata)) { echo "Applying encoding fix\n"; $imdbdata = fix_utf8($imdbdata); } if (empty($imdbdata[title])) { echo "Fetch failed , try again...\n"; $imdbdata = engineGetData($imdbID, $engine); } if (empty($imdbdata[title])) { echo "Fetch failed again , next movie"; return; } if ($debug) { echo "\n=================== IMDB Data ============================\n"; print_r($imdbdata); echo "\n=================== IMDB Data ============================\n"; } if (!empty($imdbdata[title])) { // // NOTE: comment out any of the following lines if you do not want them updated // $video[0][title] = $imdbdata[title]; $video[0][subtitle] = $imdbdata[subtitle]; $video[0][year] = $imdbdata[year]; $video[0][imgurl] = $imdbdata[coverurl]; $video[0][runtime] = $imdbdata[runtime]; $video[0][director] = $imdbdata[director]; $video[0][rating] = $imdbdata[rating]; $video[0][country] = $imdbdata[country]; $video[0][language] = $imdbdata[language]; $video[0][actors] = $imdbdata[cast]; $video[0][plot] = $imdbdata[plot]; } if (count($genres) == 0 || $lookup > 1) { $genres = array(); $gnames = $imdbdata['genres']; if (isset($gnames)) { foreach ($gnames as $gname) { // check if genre is found- otherwise fail silently if (is_numeric($genre = getGenreId($gname))) { $genres[] = $genre; } else { echo "MISSING GENRE {$gname}\n"; } } } } // custom filds , not working for now for ($i = 1; $i <= 4; $i++) { $custom = 'custom' . $i; $type = $config[$custom . 'type']; if (!empty($type)) { // copy imdb data into corresponding custom field $video[0][$custom] = $imdbdata[$type]; echo "CUSTOM {$custom} {$type} = {$imdbdata[$type]}\n"; } } // -------- SAVE $SETS = prepareSQL($video[0]); if ($debug) { echo "\n=================== Final Data ============================\n"; echo "SETS = {$SETS} \n"; echo "\n=================== Final Data ============================\n"; } $id = updateDB($SETS, $id); // save genres setItemGenres($id, $genres); // set seen for currently logged in user set_userseen($id, $seen); }
$genres = getItemGenres($copyid); } // save data if ($save) { // uncomment the following line to provide simple protection for your own public access videoDB //if (!preg_match('/[0-9]{2+}/', $id)) break; // implicit owner id if not set if (!$owner_id) { $owner_id = get_current_user_id(); } // generate diskid if (empty($diskid) && $config['autoid'] && $mediatype != MEDIA_WISHLIST) { $diskid = getDiskId(); } // write videodata table $SETS = prepareSQL($GLOBALS); $id = updateDB($SETS, $id, $oldmediatype == MEDIA_WISHLIST && $mediatype != MEDIA_WISHLIST); // save genres setItemGenres($id, $genres); // set seen for currently logged in user set_userseen($id, $seen); // uploaded cover? processUpload($id, $_FILES['coverupload']['tmp_name'], $_FILES['coverupload']['type'], $_FILES['coverupload']['name']); // make sure no artifacts $smarty->clearCache('list.tpl'); $smarty->clearCache('show.tpl', get_current_user_id() . '|' . $id); // add another? if ($add_flag) { // remove id to prevent edit mode instead of new $id = ''; $smarty->assign('add_flag', $add_flag);