MPD
Welcome, Guest. Please login or register.
September 02, 2010, 10:12:13 am

Login with username, password and session length
Search:     Advanced search
8507 Posts in 1934 Topics by 1469 Members
Latest Member: georgesmith83
* Home Help Search Login Register
+  MPD
|-+  Music Player Daemon
| |-+  Tips, Tricks, and Hacks
| | |-+  html playlist generation
« previous next »
Pages: [1] Print
Author Topic: html playlist generation  (Read 3470 times)
Anonymous
Guest
« on: October 08, 2004, 10:28:44 pm »

i heard thread wrote one of these already in php (maybe?) but i didn't find that out until i had completed this:

the mpd->html-playlist shell script! all it needs to run is mpd, mpc, and sed.

the script (playlist.sh):

Code:

#!/bin/sh
rm playlist.html
touch playlist.html
echo -en "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n" >> playlist.html
echo -en "<html>\n<head>\n\t<title>playlist</title>\n\t<style type=\"text/css\">\n\t\t@import url('playlist.css');\n\t</style>\n</head>\n<body>\n" >> playlist.html
echo -en "<h1>mpd playlist</h1>\n<table border=\"0\">\n" >> playlist.html
echo -en "\t<tr>\n\t\t<th class=\"a\">#</th>\n\t\t<th class=\"b\">artist</th>\n\t\t<th class=\"c\">album</th>\n\t\t<th class=\"d\">track</th>\n\t\t<th class=\"e\">title</th>\n\t\t<th class=\"f\">time</th>\n\t</tr>\n" >> playlist.html
mpc --format "[[<td class=\"b\">[%artist%]</td>\n\t\t<td class=\"c\">[%album%]</td>\n\t\t<td class=\"d\">[%track%]</td>\n\t\t<td class=\"e\">[%title%]</td>]|[<td class=\"g\" colspan=\"4\">[%file%]</td>]]\n\t\t<td class=\"f\">[%time%]</td>\n\t</tr>" playlist | sed -e "s/^#\([0-9]\+\)) /\t<tr>\n\t\t<td class=\"a\">\1<\/td>\n\t\t/g" | sed -e "s/\\\n/\n/g" | sed -e "s/\\\t/\t/g" | sed -e "s/&/&amp;/g" >> playlist.html
echo -en "</table>\n</body>\n</html>\n" >> playlist.html



my sample stylesheet file to use with the playlist (playlist.css):

Code:

body {
font : 0.8em Verdana, sans-serif;
color : #111;
background : #EEE;
margin : 1em;
}
h1 {
font : bold 2em Verdana, sans-serif;
}
table {
border : 1px solid black;
}
td {
border : 1px solid black;
padding : 0.2em 1em 0.2em 1em;
}
td.a, td.d, td.f {
text-align : right;
background: #DDD;
}
td.g {
text-align : center;
background: #CCC;
}



visit http://machbox.ath.cx/playlist.html for a sample output. it even validates, that is depending on your filename and id3 content.. invalid unicode characters get balked at.
Logged
mattswell
Newbie
*
Posts: 6



View Profile
« Reply #1 on: October 08, 2004, 10:29:43 pm »

oh yeah i need to login so i can claim that post..
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!