function update_with_api()
{
    error_log("Update triggered...");
    $client = new Google_Client();
    global $api_key;
    $client->setDeveloperKey($api_key);
    $youtube = new Google_Service_YouTube($client);
    global $greyChannelIDs, $bradyChannelIDs;
    $vids = array();
    foreach ($greyChannelIDs as $channelID) {
        $vids = array_merge($vids, getUploads($channelID, $youtube, 1));
    }
    foreach ($bradyChannelIDs as $channelID) {
        $vids = array_merge($vids, getUploads($channelID, $youtube, 20));
    }
    foreach ($vids as $vid) {
        // If this video is already in the database, delete it (we need the updated view count)
        addVideoReplacing($vid);
    }
    // Delete unnecessary videos from both creators.
    deleteExtraneousVids();
    // Record the time
    recordUpdate();
    // Clear the cache (so this update will apply)
    refresh();
    error_log("Updated successfully!");
}
Example #2
0
                $candiscuss = isset($_POST['discuss']) ? 1 : 0;
                $canrate = isset($_POST['rate']) ? 1 : 0;
                $keywords = preg_replace('/\\s+/', '', $_POST['keywords']);
                //$keywords = '';
                //foreach( $_POST['keyword'] as $word) {
                //  $keywords .= $Keywords[$word]. ',';
                //}
                //insert into media table
                addMedia($title, $username, $type, $catetory, $sharetype, $sharedfriends, $path, $detail, $candiscuss, $canrate, $keywords);
                $result = "0";
                $errortext = "successfully uploaded file";
                chmod($upfile, 0644);
            }
        } else {
            $result = "7";
            //upload file failed
            $errortext = "failed to upload file, error code is {$result}";
        }
        //}
    }
    //You can process the error code of the $result here.
    $myUploads = getUploads($_SESSION["username"]);
    render("upload_template.php", ["errortext" => $errortext, "titile" => "Uploads", "keywords" => $Keywords, "myuploads" => $myUploads]);
} else {
    $myUploads = getUploads($_SESSION["username"]);
    render("upload_template.php", ["errortext" => $errortext, "titile" => "Uploads", "keywords" => $Keywords, "myuploads" => $myUploads]);
}
$db->sql_close();
?>