From 84bec4756fc671fa5df9dd7f0b84e973510be5c8 Mon Sep 17 00:00:00 2001 From: mcguirepr89 Date: Mon, 14 Feb 2022 11:23:33 -0500 Subject: [PATCH] adding image retrieval --- scripts/get_citation.sh | 9 +++++++++ scripts/get_image.sh | 10 ++++++++++ scripts/stats.php | 26 ++++++++++++++++++++------ scripts/viewdb.php | 2 +- 4 files changed, 40 insertions(+), 7 deletions(-) create mode 100755 scripts/get_citation.sh create mode 100755 scripts/get_image.sh diff --git a/scripts/get_citation.sh b/scripts/get_citation.sh new file mode 100755 index 0000000..5452d62 --- /dev/null +++ b/scripts/get_citation.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +# testing getting images dynamically +first_call=$(lynx -dump -listonly "https://commons.wikimedia.org/w/index.php?search=${1//_/+}&title=Special:MediaSearch&go=Go&type=image") +lynx -dump -nonumbers $(lynx -dump \ + $(echo "$first_call" \ + | sed '11q;d' \ + | awk '{print $2}' ) \ + | awk -F'. ' '/Cite/ {print $2}' \ + | xargs echo -n) 2>&1 | grep -A10 'Chicago style' | grep -A10 -e '^$' | grep -B10 'CBE' | grep -B10 -e '^$' diff --git a/scripts/get_image.sh b/scripts/get_image.sh new file mode 100755 index 0000000..132df45 --- /dev/null +++ b/scripts/get_image.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +# testing getting images dynamically +first_call=$(lynx -dump -listonly "https://commons.wikimedia.org/w/index.php?search=${1//_/+}&title=Special:MediaSearch&go=Go&type=image") +lynx -dump -listonly \ + $(echo "$first_call" \ + | sed '11q;d' \ + | awk '{print $2}' ) \ + | awk '/thumb/ {print $2}' \ + | head -1 \ + | xargs echo -n diff --git a/scripts/stats.php b/scripts/stats.php index 2f1d405..b03be6d 100644 --- a/scripts/stats.php +++ b/scripts/stats.php @@ -119,6 +119,16 @@ a { text-align: center; } +img { + width:75%; +} + +.center { + display: block; + margin-left: auto; + margin-right: auto; +} + select { font-size:large; width: 60%; @@ -148,7 +158,7 @@ form { float: none; width: 100%; } - input, label { + input, label, img { width:100%; { } @@ -226,19 +236,23 @@ while($rows=$stats ->fetch_assoc()) while($rows = $specificstats->fetch_assoc()) { $dbname = preg_replace('/ /', '_', $rows['Com_Name']); $dbsciname = preg_replace('/ /', '_', $rows['Sci_Name']); + $imagelink = shell_exec("/home/pi/BirdNET-Pi/scripts/get_image.sh $dbname"); + $imagecitation = shell_exec("/home/pi/BirdNET-Pi/scripts/get_citation.sh $dbname"); echo " ";echo "";echo $rows['Com_Name']; echo " ";echo "";echo $rows['Sci_Name']; echo " ";echo $rows['COUNT(*)'];echo " ";echo $rows['MAX(Confidence)'];echo " - Wikipedia, All About Birds - "; -}} -?> + Wikipedia, All About Birds + + +
";echo $imagecitation;echo "
- +"; +}} +?> diff --git a/scripts/viewdb.php b/scripts/viewdb.php index 18672e0..d1bcc7d 100644 --- a/scripts/viewdb.php +++ b/scripts/viewdb.php @@ -114,7 +114,7 @@ while($rows=$mosttable ->fetch_assoc()) - All About Birds, Wikipedia + All About Birds, Wikipedia