Fandom

Music Player Daemon Community Wiki

Hack:play

525pages on
this wiki
Add New Page
Talk0 Share
  • Description: Just make sure you have agrep installed, then adapt the filepaths if necessary. This script works fine in a mpd configuration where your mpd music directory contains directories which represent an album each.
  • Homepage: http://rochel.dyndns.info/play
  • Maintainer(s): Jan Rochel < jan PERIOD rochel POLLIWOG stud POINT uka FULLSTOP de >
#!/bin/sh

# Needed tools: mpc, mktemp, and agrep. Set them below

MKTEMP="mktemp -t play"
MPC=mpc
AGREP=tre-agrep

# Create a temporary file
tmp=`$MKTEMP`
# Fill the temporary file with all available albums
$MPC ls | tr _ ' ' > $tmp
# Clear the current playlist
$MPC clear > /dev/null
# Extract the album(s) from the temporary file that match our query best,
# and add them to the (empty) playlist.
$AGREP -BS 9 -D 9 "`echo $@`" $tmp | $MPC add > /dev/null
# Delete the temporary file
rm $tmp
# Start playback
$MPC play > /dev/null
# Print a nice summary of the current album to the terminal
$MPC playlist | column
  • Description: I've made some changes to this script. My version works with collections stored in every possible way.
  • Author: Przemyslaw Gierski pgierski[re2mo4ve^th2i3s]AT o2 DOT pl
#!/bin/sh

# Works well when you have music collection with album name somewhere in filename

# Needed tools: mpc, mktemp, grep, and agrep. Set them below:

MKTEMP="mktemp -t albumXXXXXXXXXXXX"
MPC=mpc
AGREP=agrep
GREP=grep

# Creates some temporary files
albums_list=`$MKTEMP`
files_list=`$MKTEMP`

# Lists all albums to a temporary file
$MPC list album > $albums_list

# Takes arguments and do some search, in every loop it filters previous match with next argument. It temporary uses files_list, but it's done only to prevent writing new data to used file
for opt in $@; do
 $AGREP -i -BS 9 -D 9 "`echo $opt`" $albums_list > $files_list
 cat $files_list > $albums_list
done

# Fill the temporary file with all available albums
$MPC listall > $files_list

# Clear the current playlist
$MPC clear > /dev/null

# Changes new line delimiter from " " to new line character
IFS="
"

# Find using grep file names for found album name. Grep is much faster then agrep.
for opt in `cat $albums_list`; do
$GREP -i "`echo $opt`" $files_list | $MPC add > /dev/null
done

# If playlist is empty tries agrep.
# Sometimes (when album name has some odd characters grep cannot find file name) agrep comes handy.
if [ -z "`mpc playlist`" ]; then
 echo Falling into agrep, grep failed to find file names. This will take a while.
 for opt in `cat $albums_list`; do
  $AGREP -i -BS 9 -D 9 "`echo $opt`" $files_list | $MPC add > /dev/null
 done
fi

# Start playback
$MPC play > /dev/null

# Print a nice summary of the current album to the terminal
$MPC playlist | column

# Delete temporary files
rm $albums_list
rm $files_list

You can also change it to find an artist just by changing:

$MPC list album > $albums_list

to

$MPC list artist > $albums_list

I also suggest Picard (free soft from MusicBrainz) for file tagging, it works great.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random Wiki