Last active
September 28, 2023 14:41
-
-
Save spvkgn/d297314d7808fb14945fbc54bab0bf04 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export MPD_HOST=$HOME/.config/mpd/socket | |
#MIME_CMD="file -bL --mime-type" | |
MIME_CMD="mimetype -biL" | |
[ -z "$1" ] || tmpfile=$(mktemp) | |
add_file() { | |
$MIME_CMD "$file" | grep -q 'audio' && \ | |
echo "file://$(readlink -f "$file")" >> "$tmpfile" | |
} | |
for arg in "$@" ; do | |
if [ -f "$arg" ] ; then # file | |
file=$arg | |
add_file "$file" | |
elif [ -d "$arg" ] ; then # files in directory | |
find "$arg" ! -regex ".*\.\(m3u8?\|part\)$" -print | sort -f | while read -r file ; do | |
add_file "$file" | |
done | |
fi | |
done | |
[ -s "$tmpfile" ] && mpc add < "$tmpfile" | |
rm -f "$tmpfile" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment