MacOSNeXt

Shell Script to Queue Random Song in MOC from an m3u playlist

#!/bin/sh

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# BEGIN CONFIG %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PROCNAME="mocp" #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PLAYLIST="$HOME/.moc/00-music-library.m3u" #%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# END CONFIG #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%boredprogrammer%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# check if mocp daemon exists.

OUTPUT=`ps -e|grep mocp|wc -l`

if $OUTPUT -eq ]
then
    echo "But MOC isn't running!"
    exit 0
fi
#load our playlist file

#PLAYLIST_COUNT=`wc -l $PLAYLIST | cut -d' ' -sf1`
#echo $PLAYLIST_COUNT

DONE=0
while $DONE -eq ]
do
    LETS_PLAY=`shuf $PLAYLIST | tail -n1`

    #DONE=`test `head -c1 $LETS_PLAY` -ne '#'`
    #echo $LETS_PLAY
    if `echo $LETS_PLAY | head -c1` != '#' ]
    then
        DONE=1
    fi
done

echo "queued $LETS_PLAY"
mocp --enqueue "$LETS_PLAY"



Tags: free software, moc, random mp3, shell scripts, unix

Rate This Article:

MacOSNeXt


Home Site Map



Privacy Policy | Copyright/Trademark Notification