jump to navigation

mplayer genre playlist

#!/bin/bash

# `genre` is used to play through the entire directory of music for a specific genre using mplayer.
#  http://www.mplayerhq.hu/

# Author:  Kathryn S. Marks <kathryn.linux@gmail.com>
# Creation Date:  December 30, 2007
# Last Modified:  December 31, 2007

# Thanks to Eric Myers for a starting point.

# Directory structure is as follows
# /Data/My Music/Genre/Artist/Album/Track

# Define our variables
# GENRE is the directory containing a specific type of music (e.g. Classical, Pop, etc)
# LIST is the complete list of tracks within each genre directory
# SHUFFLE is whether or not to shuffle the tracks.

cd /Data/”My Music”/

GENRE=

echo -n “What do you want to listen to?  \
Type the genre name or L for a list. > “

read GENRE

#if GENRE=L
#    then echo `ls -D`
#    else `cd $GENRE`
#fi

cd “$GENRE”

#SHUFFLE=

#echo -n “Do you want shuffle mode? Y or N > “

#read SHUFFLE

LIST=`find . -name “*.mp3″ -or -name “*.m4a” -print > /tmp/playlist.$$`

#if SHUFFLE=N
#    then `mplayer -playlist $LIST`
#    else `mplayer -shuffle -playlist $LIST`
#fi

mplayer -playlist /tmp/playlist.$$

rm /tmp/playlist.$$

# EOF

Comments»

1. SEb - April 12, 2008

Hey, I came across your script while I was looking for a way to get mplayer play bundles of music together. I am just discovering the fascinating world of Linux and I am starting to write some scripts. I hope it’s okay if I use your code to play my music; I’ve only made one or two minor changes. Thanks for this script, it was just what I was looking for!!!

2. gnukathryn - April 12, 2008

You’re more than welcome to use it :-)

It’s totally broken as it’s written here and I’ve not had the motivation to debug it properly.

I ended up throwing a bunch of music in a “Random Stuff” directory and passing the shuffle flag to mplayer. I occasionally switch songs in and out to keep things fresh.

Lazy? Yeah. But it lets me get other stuff done.