mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 01:39:24 +02:00
Updates
This commit is contained in:
parent
8f038aaaac
commit
2c42fc64e1
2 changed files with 11 additions and 5 deletions
|
@ -3,14 +3,14 @@ require_once '../../videos/configuration.php';
|
|||
header('Content-Type: application/json');
|
||||
|
||||
if (!User::isLogged()) {
|
||||
die(json_encode(['error' => 'You must be logged in to search']));
|
||||
die(json_encode(['error' => true, 'msg'=>'You must be logged in to search']));
|
||||
}
|
||||
|
||||
$query = $_POST['query'] ?? '';
|
||||
$pageToken = $_POST['pageToken'] ?? '';
|
||||
|
||||
if (empty($query)) {
|
||||
die(json_encode(['error' => 'Search query cannot be empty']));
|
||||
die(json_encode(['error' => true, 'msg'=>'Search query cannot be empty']));
|
||||
}
|
||||
|
||||
$obj = AVideoPlugin::getObjectData("BulkEmbed");
|
||||
|
@ -23,11 +23,17 @@ if (!empty($pageToken)) {
|
|||
$youtubeApiUrl .= "&pageToken=" . $pageToken;
|
||||
}
|
||||
|
||||
$response = file_get_contents($youtubeApiUrl);
|
||||
$response = url_get_contents($youtubeApiUrl);
|
||||
$responseData = json_decode($response, true);
|
||||
|
||||
if (empty($responseData) || !isset($responseData['items'])) {
|
||||
die(json_encode(['error' => 'Failed to retrieve data from YouTube', $responseData]));
|
||||
_error_log('Failed to retrieve data from YouTube ' . $youtubeApiUrl);
|
||||
$msg = 'Failed to retrieve data from YouTube';
|
||||
if(!empty($responseData['error']) && !empty($responseData['error']['message'])){
|
||||
$msg .= '<br>'.$responseData['error']['message'];
|
||||
}
|
||||
|
||||
die(json_encode(['error' => true, 'msg'=>$msg]));
|
||||
}
|
||||
|
||||
// Prepare the result array to include the embedding status
|
||||
|
|
|
@ -199,7 +199,7 @@ $_page = new Page(array('Search'));
|
|||
},
|
||||
success: function(response) {
|
||||
if (response.error) {
|
||||
avideoAlertError(response.error);
|
||||
avideoAlertError(response.msg);
|
||||
} else {
|
||||
processData(response.data);
|
||||
// Store search results globally
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue