Just as I finished neatly merging a few scripts I had been using all this time, I found the aforementioned encoding issue, unsucking Songbird in what appears to be a fairly permanent way. *sigh* I'm just not elitist or bullheaded enough (most of the time) to cling to the terminal when better options exist.
Nevertheless, if you wish to play a mixture of formats over SSH, this may just be what you're looking for.
Click to expand code
#!/bin/bash
#
# FILENAME: playdir.sh
# LAST UPDATE: jds - 02/27/10
# DESCRIPTION: Plays mp3s, flacs, and m4as using mpg321, flac123, and afplay,
# respectively. This was written in OS X, hence afplay. Most
# everything should work under Linux, though.
#
FIND='/usr/bin/find'
shuffle=0
playlist=""
player=""
if [ "$1" == "-s" ]; then
shuffle=1
shift
fi
function chplayer
{
# OCD tidiness where possible
local MPG321='/opt/local/bin/mpg321'
local FLAC123='/usr/local/bin/flac123'
local AFPLAY='/usr/bin/afplay'
local filename="$1"
case "$filename" in
*.mp3)
player="$MPG321";;
*.flac)
player="$FLAC123";;
*.m4a)
player="$AFPLAY";;
esac
}
function shufflelist
{
playlist=$(while read i; do
echo "$RANDOM $i"
done < <(echo "$playlist") | sort | sed -E 's/^[0-9]+ //')
}
function playdir
{
# Choose player and play file.
while read file; do
echo "$file"
chplayer "$file"
${player} "$file" 2>/dev/null 1>/dev/null
done < <(echo "$playlist")
}
# Create playlist
while (( "$#" )); do
dir="$1"
pattern='.*\.mp3|.*\.flac|.*\.m4a'
playlist="`echo \"$playlist\"
${FIND} -Es \"$dir\" -iregex $pattern`"
shift
done
playlist="`echo \"$playlist\" | tail -n +2`" #Chop empty line off top
if [ "$shuffle" -eq "1" ]; then
shufflelist
fi
playdir
#
# FILENAME: playdir.sh
# LAST UPDATE: jds - 02/27/10
# DESCRIPTION: Plays mp3s, flacs, and m4as using mpg321, flac123, and afplay,
# respectively. This was written in OS X, hence afplay. Most
# everything should work under Linux, though.
#
FIND='/usr/bin/find'
shuffle=0
playlist=""
player=""
if [ "$1" == "-s" ]; then
shuffle=1
shift
fi
function chplayer
{
# OCD tidiness where possible
local MPG321='/opt/local/bin/mpg321'
local FLAC123='/usr/local/bin/flac123'
local AFPLAY='/usr/bin/afplay'
local filename="$1"
case "$filename" in
*.mp3)
player="$MPG321";;
*.flac)
player="$FLAC123";;
*.m4a)
player="$AFPLAY";;
esac
}
function shufflelist
{
playlist=$(while read i; do
echo "$RANDOM $i"
done < <(echo "$playlist") | sort | sed -E 's/^[0-9]+ //')
}
function playdir
{
# Choose player and play file.
while read file; do
echo "$file"
chplayer "$file"
${player} "$file" 2>/dev/null 1>/dev/null
done < <(echo "$playlist")
}
# Create playlist
while (( "$#" )); do
dir="$1"
pattern='.*\.mp3|.*\.flac|.*\.m4a'
playlist="`echo \"$playlist\"
${FIND} -Es \"$dir\" -iregex $pattern`"
shift
done
playlist="`echo \"$playlist\" | tail -n +2`" #Chop empty line off top
if [ "$shuffle" -eq "1" ]; then
shufflelist
fi
playdir
Great script! Thanks for sharing - I'll definitely put it to use.
ReplyDeleteThanks! It's precarious, but it works.
ReplyDeletehttps://saglamproxy.com
ReplyDeletemetin2 proxy
proxy satın al
knight online proxy
mobil proxy satın al
YJP0BM