3 Pitchfork Music Player Daemon Client
4 Copyright (C) 2007 Roger Bystrøm
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; version 2 of the License.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 /* This is a slightly hidden feature
21 * Also goes to show how impractical it is to program against pitchfork core,
22 * but then again that never was the point :)
24 * usage: curl -s http://yourmpdhost/path/player/nowplaying.php
26 * in irssi you would do:
27 * /alias np exec - -o curl -s http://..
29 * Never invoke it directly using php command, should always go through web-server
30 * (think of permissions!)
34 /* If you're using a password you have a little case with specifying the password thing
35 * The only solution as of yet is to not require a password to see now playing
37 * This does not grant access to anything else though
39 * Just uncomment this line if that is something you want to do, I might add this option to the
40 * configure screen some day though
43 $no_require_login = "true";
47 require_once("../inc/base.php");
49 require_once("../player/metadata.php");
50 header("Content-Type: text/plain");
54 $info = $pl->getCurrentSong();
59 if(isset($info['Artist'])&&isset($info['Title'])) {
60 $file = get_lyric_filename($info['Artist'], $info['Title']);
62 if(file_exists($file)) {
63 $lyric = _get_lyric_cache($file, $info['file']);
66 $lyric = @_get_lyric_lyricwiki($info['Artist'], $info['Title'], $info['file']);
70 $lyric = simplexml_load_string($lyric);
71 if($lyric&&$lyric->result->lyric) {
72 $lyric = (string) $lyric->result->lyric;
73 $lyric = explode("\n", $lyric);
74 $lines = count($lyric);
76 /* try until we hit something */
77 while(strlen($tmp)<=0&&$lines>0) {
78 $tmp = $lyric[rand(0, count($lyric)-1)];
80 $rlyric = substr(trim($tmp), 0, 60);
82 $rlyric = " -~\"" . $rlyric . "\"";
90 echo "np: " . $info['Artist'] . " - " . $info['Title'] . $rlyric;
94 if( isset($info['Artist']))
95 echo $info['Artist'] . " - ";
96 if(isset($info['Title']))
97 echo $info['Title'] . " - ";
98 if(isset($info['file']))
100 else echo "not playing";
103 catch(PEARException $e) {
104 echo "error contacting mpd";