Flickr now uses English names
This is totally the right way to add files to a folder that's in .gitignore. Right? _Right..._ @mcguirepr89
This commit is contained in:
@@ -17,6 +17,10 @@ if (file_exists('./scripts/thisrun.txt')) {
|
||||
$config = parse_ini_file('./scripts/firstrun.ini');
|
||||
}
|
||||
|
||||
$user = shell_exec("awk -F: '/1000/{print $1}' /etc/passwd");
|
||||
$home = shell_exec("awk -F: '/1000/{print $6}' /etc/passwd");
|
||||
$home = trim($home);
|
||||
|
||||
if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" && isset($_GET['previous_detection_identifier'])) {
|
||||
|
||||
$statement4 = $db->prepare('SELECT Com_Name, Sci_Name, Date, Time, Confidence, File_Name FROM detections ORDER BY Date DESC, Time DESC LIMIT 5');
|
||||
@@ -29,6 +33,7 @@ if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" && isse
|
||||
$_SESSION['images'] = [];
|
||||
}
|
||||
$iterations = 0;
|
||||
$lines;
|
||||
// hopefully one of the 5 most recent detections has an image that is valid, we'll use that one as the most recent detection until the newer ones get their images created
|
||||
while($mostrecent = $result4->fetchArray(SQLITE3_ASSOC)) {
|
||||
$comname = preg_replace('/ /', '_', $mostrecent['Com_Name']);
|
||||
@@ -58,6 +63,18 @@ if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" && isse
|
||||
if($key !== false) {
|
||||
$image = $_SESSION['images'][$key];
|
||||
} else {
|
||||
// only open the file once per script execution
|
||||
if(!isset($lines)) {
|
||||
$lines = file($home."/BirdNET-Pi/model/labels_flickr.txt");
|
||||
}
|
||||
// convert sci name to English name
|
||||
foreach($lines as $line){
|
||||
if(strpos($line, $todaytable['Sci_Name']) !== false){
|
||||
$engname = explode("_", $line)[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$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", $comname)."&license=2%2C3%2C4%2C5%2C6%2C9&sort=relevance&per_page=5&orientation=square,portrait&format=json&media=photos&nojsoncallback=1"), true)["photos"]["photo"][0];
|
||||
$modaltext = "https://flickr.com/photos/".$flickrjson["owner"]."/".$flickrjson["id"];
|
||||
$authorlink = "https://flickr.com/people/".$flickrjson["owner"];
|
||||
|
||||
Reference in New Issue
Block a user