2nd commit

This commit is contained in:
2025-02-05 10:37:30 +01:00
parent 7d023b94fe
commit 7e0bd02867
3 changed files with 643 additions and 1 deletions

View File

@@ -69,12 +69,114 @@ getinfo_photos() {
comments=$(echo "$info_photo" | jq -r '.photo .comments | ._content')
tags=$(echo "$info_photo" | jq -r '.photo .tags | .tag[].raw' | tr '\n' ',')
urls=$(echo "$info_photo" | jq -r '.photo .urls | .url[] | ._content')
url=$(echo "$info_photo" | jq -r '.photo .urls | .url[] | ._content')
: <<'END_COMMENT2'
#echo "Photo ID: $id - Title: $title"
echo "Description: $description"
echo "Posted: $posted - Taken: $taken"
echo "View: $view - Comments: $comments"
echo "Tags: $tags"
echo
END_COMMENT2
}
###################################################
# #
# Get contexts for the given photo. #
# flickr.photos.getAllContexts #
# #
###################################################
getAllContexts_photos() {
params=("$@")
#contexts_photo=$(curl -s "https://www.flickr.com/services/rest/?method=flickr.photos.getAllContexts&api_key=$api_key&photo_id=$photo_id&format=json&nojsoncallback=1")
contexts_photo=$(curl -s "https://www.flickr.com/services/rest/?method=flickr.photos.getAllContexts&api_key=$1&photo_id=$2&format=json&nojsoncallback=1")
albums=$(echo "$contexts_photo" | jq -r '.set')
groups=$(echo "$contexts_photo" | jq -r '.pool')
if [ "$albums" != "null" ]; then
title_alb=$(echo "$albums" | jq -r '.[].title' | tr '\n' ';')
id_alb=$(echo "$albums" | jq -r '.[].id' | tr '\n' ';')
else
title_alb=""
id_alb=""
fi
if [ "$groups" != "null" ]; then
title_gro=$(echo "$groups" | jq -r '.[].title' | tr '\n' ';')
id_gro=$(echo "$groups" | jq -r '.[].id' | tr '\n' ';')
url_gro=$(echo "$groups" | jq -r '.[].url' | tr '\n' ';')
else
title_gro=""
id_gro=""
url_gro=""
fi
: <<'END_COMMENT2'
echo "ID: $id_alb"
echo "Albums: $title_alb"
echo
echo "ID: $id_gro"
echo "Groups: $title_gro"
echo "URL: $url_flickr$url_gro"
END_COMMENT2
}
###################################################
# #
# Get favorites for the given photo. #
# flickr.photos.getFavorites #
# #
###################################################
getFavorites_photos() {
params=("$@")
favorites_photo=$(curl -s "https://www.flickr.com/services/rest/?method=flickr.photos.getFavorites&api_key=$1&photo_id=$2&format=json&nojsoncallback=1")
favorites=$(echo "$favorites_photo" | jq -r '.photo .total')
}
search_photos() {
# tags, tag_mode (OR/AND), text (-exclude)
# min_upload_date, max_upload_date, min_taken_date, max_taken_date (timestamp or mysql datetime)
# sort (date-posted-asc, date-posted-desc, date-taken-asc, date-taken-desc, interestingness-desc, interestingness-asc, and relevance.)
# group_id, user_id, media (all/photos/videos), has_geo
# extras (description, license, date_upload, date_taken, owner_name, icon_server, original_format, last_update, geo, tags, machine_tags, o_dims, views, media, path_alias, url_sq, url_t, url_s, url_q, url_m, url_n, url_z, url_c, url_l, url_o)
params=("$@")
search_photo=$(curl -s "https://www.flickr.com/services/rest/?method=flickr.photos.search&api_key=$1&user_id=$2&$3&format=json&nojsoncallback=1")
search=$(echo "$search_photo" | jq -r '.photos .photo')
counter=0
while read -r id && read -r title; do
echo -e "${BOLD}Photo ID: ${id}\t Title: ${title}${COLOR_RESET}"
photo_id=$(echo "${id}" | sed "s/'/''/g")
photo_title=$(echo "${title}" | sed "s/'/''/g")
ID+=(${id})
((++counter))
done < <(jq -r -c '.[] | .id, .title' <<< "$search")
request="${request//+/ }"
request="${request//%3A/:}"
echo -e "${COLOR_GREEN}Found $counter public photos for request (${request//+/ }) on Flickr.${COLOR_RESET}"
}