fix: do not error out on a missing blacklisted_images.txt file
This commit is contained in:
@@ -158,7 +158,12 @@ if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" && isse
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read the blacklisted image ids from the file into an array
|
// Read the blacklisted image ids from the file into an array
|
||||||
$blacklisted_ids = array_map('trim', file($home."/BirdNET-Pi/scripts/blacklisted_images.txt"));
|
$blacklisted_file = file($home."/BirdNET-Pi/scripts/blacklisted_images.txt");
|
||||||
|
if ($blacklisted_file !== false) {
|
||||||
|
$blacklisted_ids = array_map('trim', $blacklisted_file);
|
||||||
|
} else {
|
||||||
|
$blacklisted_ids = [];
|
||||||
|
}
|
||||||
|
|
||||||
// Make the API call
|
// Make the API call
|
||||||
$flickrjson = json_decode(file_get_contents("https://www.flickr.com/services/rest/?method=flickr.photos.search&api_key=".$config["FLICKR_API_KEY"]."&text=".str_replace(" ", "%20", $engname).$comnameprefix."&sort=relevance".$args."&per_page=5&media=photos&format=json&nojsoncallback=1"), true)["photos"]["photo"];
|
$flickrjson = json_decode(file_get_contents("https://www.flickr.com/services/rest/?method=flickr.photos.search&api_key=".$config["FLICKR_API_KEY"]."&text=".str_replace(" ", "%20", $engname).$comnameprefix."&sort=relevance".$args."&per_page=5&media=photos&format=json&nojsoncallback=1"), true)["photos"]["photo"];
|
||||||
|
|||||||
@@ -285,7 +285,12 @@ if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Read the blacklisted image ids from the file into an array
|
// Read the blacklisted image ids from the file into an array
|
||||||
$blacklisted_ids = array_map('trim', file($home."/BirdNET-Pi/scripts/blacklisted_images.txt"));
|
$blacklisted_file = file($home."/BirdNET-Pi/scripts/blacklisted_images.txt");
|
||||||
|
if ($blacklisted_file) {
|
||||||
|
$blacklisted_ids = array_map('trim', $blacklisted_file);
|
||||||
|
} else {
|
||||||
|
$blacklisted_ids = [];
|
||||||
|
}
|
||||||
|
|
||||||
// Make the API call
|
// Make the API call
|
||||||
$flickrjson = json_decode(file_get_contents("https://www.flickr.com/services/rest/?method=flickr.photos.search&api_key=".$config["FLICKR_API_KEY"]."&text=".str_replace(" ", "%20", $engname).$comnameprefix."&sort=relevance".$args."&per_page=5&media=photos&format=json&nojsoncallback=1"), true)["photos"]["photo"];
|
$flickrjson = json_decode(file_get_contents("https://www.flickr.com/services/rest/?method=flickr.photos.search&api_key=".$config["FLICKR_API_KEY"]."&text=".str_replace(" ", "%20", $engname).$comnameprefix."&sort=relevance".$args."&per_page=5&media=photos&format=json&nojsoncallback=1"), true)["photos"]["photo"];
|
||||||
|
|||||||
Reference in New Issue
Block a user