1st commit
This commit is contained in:
60
info_user.sh
Executable file
60
info_user.sh
Executable file
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#api_key=
|
||||
#user_id=
|
||||
|
||||
### Variables for self updating
|
||||
ScriptArgs=( "$@" )
|
||||
ScriptPath="$(readlink -f "$0")" # /Users/bruno/Documents/Scripts/bashbirds/bashbirds.sh
|
||||
ScriptWorkDir="$(dirname "$ScriptPath")" # /Users/bruno/Documents/Scripts/bashbirds
|
||||
|
||||
dotenv () {
|
||||
set -a
|
||||
# shellcheck disable=SC1091
|
||||
[ -f "$ScriptWorkDir/.env" ] && . "$ScriptWorkDir/.env" || { echo -e "${red}\nNo .env file found ! No API key for Flickr.'.${reset}"; exit 1; }
|
||||
set +a
|
||||
}
|
||||
|
||||
dotenv
|
||||
|
||||
perpage=500
|
||||
|
||||
###################################################
|
||||
# #
|
||||
# Get info for the given user. #
|
||||
# flickr.people.getInfo #
|
||||
# #
|
||||
###################################################
|
||||
|
||||
getinfo_people() {
|
||||
params=("$@")
|
||||
#info_user=$(curl "https://www.flickr.com/services/rest/?method=flickr.people.getInfo&api_key=$api_key&user_id=$user_id&format=json&nojsoncallback=1")
|
||||
info_user=$(curl -s "https://www.flickr.com/services/rest/?method=flickr.people.getInfo&api_key=$1&user_id=$2&format=json&nojsoncallback=1")
|
||||
|
||||
id=$(echo "$info_user" | jq -r '.person | .id')
|
||||
username=$(echo "$info_user" | jq -r '.person | .username ._content')
|
||||
ispro=$(echo "$info_user" | jq -r '.person | .ispro')
|
||||
path_alias=$(echo "$info_user" | jq -r '.person | .path_alias')
|
||||
|
||||
count=$(echo "$info_user" | jq -r '.person .photos | .count ._content')
|
||||
q=$(((count / perpage) + 1))
|
||||
|
||||
firstdatetaken=$(echo "$info_user" | jq -r '.person .photos | .firstdatetaken ._content')
|
||||
photosurl=$(echo "$info_user" | jq -r '.person | .photosurl ._content')
|
||||
profileurl=$(echo "$info_user" | jq -r '.person | .profileurl ._content')
|
||||
|
||||
echo $id
|
||||
echo $username
|
||||
echo $ispro
|
||||
echo $path_alias
|
||||
|
||||
echo $count
|
||||
echo $q
|
||||
|
||||
echo $firstdatetaken
|
||||
echo $photosurl
|
||||
echo $profileurl
|
||||
}
|
||||
|
||||
params_info=("$api_key" "$user_id")
|
||||
getinfo_people "${params_info[@]}"
|
||||
Reference in New Issue
Block a user