diff options
author | friendica <info@friendica.com> | 2014-06-18 22:29:04 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2014-06-18 22:33:28 -0700 |
commit | c012c648e0691868370a5a8c1eb468020fef6330 (patch) | |
tree | 18e33384112d9f42e49e2b5b64ac94ab05391a22 /util/shredder | |
parent | 224a2b9ddf38b6fa52fef3f0d8cbe4299e651c47 (diff) | |
download | volse-hubzilla-c012c648e0691868370a5a8c1eb468020fef6330.tar.gz volse-hubzilla-c012c648e0691868370a5a8c1eb468020fef6330.tar.bz2 volse-hubzilla-c012c648e0691868370a5a8c1eb468020fef6330.zip |
wherein I revive some of my 30+year old shell scripting skills so that we can process arbitrary api endpoints which generate arbitrary json and be able to crunch all of these on the command line. Getting the arbitrary query arguments into a form where they could be signed as part of the oauth packet was a challenge. (It still might be - I haven't tried querying any Chinese photo album names yet).
But you can now do something like
for a in `util/shredder/shredder -c red/photos -q album=2013 | jshon -e photos -a -e src` ; do wget $a; done
and download all the photos in your 2013 album
Diffstat (limited to 'util/shredder')
-rwxr-xr-x | util/shredder/ShredOAuth.sh | 23 | ||||
-rwxr-xr-x | util/shredder/shredder | 6 |
2 files changed, 24 insertions, 5 deletions
diff --git a/util/shredder/ShredOAuth.sh b/util/shredder/ShredOAuth.sh index 76858d73c..9e808a2d6 100755 --- a/util/shredder/ShredOAuth.sh +++ b/util/shredder/ShredOAuth.sh @@ -174,17 +174,34 @@ FO_statuses_home_timeline () { FO_command () { local command="$1" - + local opts="$2" local params=( $(OAuth_param 'screen_name' $screen_name) $(OAuth_param 'count' $count) ) +#echo ${opts[@]} + + convscreen=$(OAuth_PE "$screen_name"); + data="screen_name=${convscreen}&count=${count}" + + if [ ${#opts[@]} != 0 ]; then + for b in ${opts[@]}; do + lhs=`echo $b | awk -F= '{print $1};'` + rhs=`echo $b | awk -F= '{print $2};'` + params=("${params[@]}" $(OAuth_param $lhs $rhs)) + data=$data"&"$lhs=$rhs + done + fi + +#echo ${params[@]} + +#echo $data + local auth_header=$(OAuth_authorization_header 'Authorization' "$redmatrix_url" '' '' 'GET' "${redmatrix_url}/api/${command}.json" ${params[@]}) - convscreen=$(OAuth_PE "$screen_name"); - FO_ret=$(curl -s --get "${redmatrix_url}/api/${command}.json" --data "screen_name=${convscreen}&count=${count}" --header "${auth_header}") + FO_ret=$(curl -s --get "${redmatrix_url}/api/${command}.json" --data "${data}" --header "${auth_header}") FO_rval=$? return $FO_rval diff --git a/util/shredder/shredder b/util/shredder/shredder index b8d298175..c46dfe0ec 100755 --- a/util/shredder/shredder +++ b/util/shredder/shredder @@ -158,8 +158,9 @@ main () { fcli_file= fcli_help_flag= JS_Fields=() + fcli_opts= - while getopts "C:c:s:r:f:h:i" name + while getopts "C:c:s:r:f:i:q:h" name do case $name in c) fcli_command="$OPTARG";; @@ -168,6 +169,7 @@ main () { r) fcli_in_reply_to_status_id="$OPTARG";; f) fcli_file="$OPTARG";; h) fcli_help_flag="1";; + q) fcli_opts=("${fcli_opts[@]}" "$OPTARG");; i) JS_Fields=("${JS_Fields[@]}" "$OPTARG");; ?) usage exit 2;; @@ -216,7 +218,7 @@ main () { return $FO_rval ;; *) - FO_command $fcli_command + FO_command $fcli_command ${fcli_opts[@]} echo $FO_ret |