media.sh
· 535 B · Bash
Eredeti
#!/bin/bash
set -e
PW=
PW_FILE="${HOME}/.mediapw"
BASE_URL="https://fs.noahro.at"
function get_pw {
cat "$PW_FILE"
}
function main {
PW="$( get_pw )"
local path="$1"
fetch "$path"
}
function fetch {
local path="$( pathencode "$1" )"
#local path="$1"
curl -s "${BASE_URL}/${path}?pw=${PW}&t"
#--expand-url \
#--variable %path --variable %PW \
}
function pathencode {
#jq --slurp --raw-input --raw-output @uri <<<"$@"
sed -E 's/ /%20/g' <<<"$@" | \
sed -E 's/,/%2C/g'
}
main "$@"
| 1 | #!/bin/bash |
| 2 | |
| 3 | set -e |
| 4 | |
| 5 | PW= |
| 6 | PW_FILE="${HOME}/.mediapw" |
| 7 | BASE_URL="https://fs.noahro.at" |
| 8 | |
| 9 | function get_pw { |
| 10 | cat "$PW_FILE" |
| 11 | } |
| 12 | |
| 13 | function main { |
| 14 | PW="$( get_pw )" |
| 15 | |
| 16 | local path="$1" |
| 17 | fetch "$path" |
| 18 | } |
| 19 | |
| 20 | function fetch { |
| 21 | local path="$( pathencode "$1" )" |
| 22 | #local path="$1" |
| 23 | curl -s "${BASE_URL}/${path}?pw=${PW}&t" |
| 24 | |
| 25 | #--expand-url \ |
| 26 | #--variable %path --variable %PW \ |
| 27 | } |
| 28 | |
| 29 | function pathencode { |
| 30 | #jq --slurp --raw-input --raw-output @uri <<<"$@" |
| 31 | |
| 32 | sed -E 's/ /%20/g' <<<"$@" | \ |
| 33 | sed -E 's/,/%2C/g' |
| 34 | } |
| 35 | |
| 36 | main "$@" |