Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

existing library or script to read mpd.conf and mpd.db #74

#1

How do you currently retrieve data from the mpd.conf file and the mpd database? Is there a 3rd party library available? Or did you have to create a custom interface from scratch?

My goal is to retrieve file paths from the mpd database. I was surprised to discover that it's just a gzip text file. I thought it would be sqlite since the stickers db is sqlite. Unfortunately that makes it more difficult to parse and extract data.

Here's what I'm working with so far...

// using pear Config package

require_once('Config.php');

$mpdconf = '/etc/mpd.conf';

$conf = new Config();
$root = $conf->parseConfig($mpdconf, 'genericconf', array('comment' => '#',
                                                          'equals' => '\s',
                                                          'newline' => '}'));
if (PEAR::isError($root)) {
    echo 'Error reading config: ' . $root->getMessage() . "\n";
    exit(1);
}

$item = $root->getItem('directive', 'db_file');
$dbpath = str_replace(['"', "'"], '', $item->content);

header('Content-Type: text/plain');
readgzfile($dbpath);
  • replies 1
  • views 798
  • likes 0
#2