Added functions to convert filename to URI and to enqueue urls to
mediaplayer.
This commit is contained in:
parent
1df3fa9c91
commit
ad62fbf87a
@ -52,4 +52,56 @@ epoch2date() {
|
||||
date -d "@$string"
|
||||
}
|
||||
|
||||
# inspired by
|
||||
# https://unix.stackexchange.com/questions/59501/convert-file-path-to-uri-in-bash
|
||||
# https://www.unix.com/shell-programming-and-scripting/159863-how-store-files-names-directory-array.html
|
||||
file2uri() {
|
||||
local root=${1:-.}
|
||||
local filter=${2:-*}
|
||||
|
||||
if ! python3 --version &> /dev/null
|
||||
then
|
||||
echo "python not available!"
|
||||
return 2
|
||||
fi
|
||||
|
||||
echo "get files for $root"
|
||||
#for f in "$root/*"; do
|
||||
# echo "checking $f"
|
||||
# if [ -f $f ]; then
|
||||
# echo "is a file: $f"
|
||||
# python -c "import sys, pathlib; print(pathlib.Path(input()).resolve().as_uri())" <<< "$f"
|
||||
# fi
|
||||
#done
|
||||
|
||||
# arr_uris=(`ls $root/*.ma4`)
|
||||
|
||||
arr=()
|
||||
for f in $root/*.m4a; do
|
||||
echo "f: $f"
|
||||
echo python3 -c "import sys, pathlib; print(pathlib.Path(input()).resolve().as_uri())" <<< "$f"
|
||||
uri=$(python3 -c "import sys, pathlib; print(pathlib.Path(input()).resolve().as_uri())" <<< "$f")
|
||||
arr[${#arr[@]}]="$uri"
|
||||
done
|
||||
for a in "${arr[@]}"; do
|
||||
echo "$a"
|
||||
done
|
||||
}
|
||||
|
||||
enqueueFiles() {
|
||||
local root="${1:-.}"
|
||||
|
||||
if ! rhythmbox-client --version &> /dev/null
|
||||
then
|
||||
echo "No rhythmbox-client available!"
|
||||
return 3
|
||||
fi
|
||||
|
||||
file2uri "$root"
|
||||
# echo "Array is ${arr[*]}"
|
||||
for a in "${arr[@]}"; do
|
||||
echo rhythmbox-client --no-start --enqueue $a
|
||||
done
|
||||
}
|
||||
|
||||
PATH=$PATH:$HOME/bin
|
||||
|
||||
Loading…
Reference in New Issue
Block a user