-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaycountListener.php
More file actions
33 lines (29 loc) · 912 Bytes
/
playcountListener.php
File metadata and controls
33 lines (29 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
require_once("mpdEventListener.class.php");
$srv = "192.168.1.107";
$port = 6600;
$pwd = null;
$debug = false;
$mpd = new mpd($srv, $port, $pwd, $debug);
echo "started...";
function playListener($songFile){
//echo $songFile . " was played\n";
$ret = array();
exec('python sticker.py get "'.$songFile.'" playcount', $ret);
//var_dump($ret);
if(sizeof($ret) < 1){
//echo "setting to 1";
exec('python sticker.py set "'.$songFile.'" playcount 1', $ret);
}else{
$tmp = explode("=", $ret[0], 2);
$currentCount = (int) $tmp[1];
//var_dump($currentCount);
$newCount = $currentCount + 1;
exec('python sticker.py set "'.$songFile.'" playcount '.$newCount, $ret);
var_dump($ret);
}
exec('python sticker.py set "'.$songFile.'" lastPlayed '.time(), $ret);
};
$listener = new mpdEventListener($mpd);
$listener->bind(MPDEVENTLISTENER_ONSONGCHANGE, "playListener");
$listener->startListening();