Dernière activité 1 week ago

helper script to curl from copyparty server with password from file

Révision 0db78471ebc3764dccf045827b298811b36810af

media.sh Brut
1#!/bin/bash
2
3set -e
4
5PW=
6PW_FILE="${HOME}/.mediapw"
7BASE_URL="https://fs.noahro.at"
8
9function get_pw {
10 cat "$PW_FILE"
11}
12
13function main {
14 PW="$( get_pw )"
15
16 local path="$1"
17 fetch "$path"
18}
19
20function 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
29function pathencode {
30 #jq --slurp --raw-input --raw-output @uri <<<"$@"
31
32 sed -E 's/ /%20/g' <<<"$@" | \
33 sed -E 's/,/%2C/g'
34}
35
36main "$@"
play-album.sh Brut
1#!/bin/bash
2
3set -e
4
5function play_album {
6 local album_path="$1"
7 [ -z "$album_path" ] && album_path="CrystalCastles/CrystalCastlesI"
8
9 local song_names=
10 #mapfile -t song_names < <( \
11 # ./media.sh "music/${album_path}" | grep --color=never -Eo '[^ ]+\.mp3$' \
12 #)
13 mapfile -t song_names < <( \
14 ./media.sh "music/${album_path}" | tail -n+4 | cut -d' ' -f3- \
15 )
16
17 for song_name in "${song_names[@]}"; do
18 echo "Playing: ${song_name}"
19 ./media.sh "music/${album_path}/${song_name}" | mpv --quiet -
20 done
21}
22
23function main {
24 while [ $# -gt 0 ]; do
25 echo "Playing album: $1"
26 play_album "$1"
27 shift
28 done
29}
30
31main "$@"
32