-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdaemon.php
More file actions
executable file
·46 lines (41 loc) · 997 Bytes
/
daemon.php
File metadata and controls
executable file
·46 lines (41 loc) · 997 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
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
#nclude("GrooveShark_PHP/grooveshark.class.php");
include("assets/includes/sonicflow.php");
#$gs = new GrooveShark();
$failcount = 0;
echo("Daemon started.\n");
while (true) {
try {
$next = getNext();
if ($next[0] == '') {
$failcount = 0;
sleep(2);
} else {
$id = $next[0];
$song = $next[1];
$songId = $song->id;
if ($song != null) {
$failcount = 0;
if ($next[2] != CACHE_IN_PROGRESS) {
$cmd = "mplayer -cache 8192 /var/www/SonicFlow/assets/songs/" . $id . ".mp3";
passthru($cmd);
removeSongFromQueue($id);
}
} else {
echo "\n\nFailed to retrieve URL for $song->title by $song->artist!\n\n";
$failcount++;
if ($failcount >= 3) {
fixBadId($id);
$failcount = 0;
}
}
sleep(2);
}
} catch (Exception $e) {
echo "\n\nException happened! with $song->title by $song->artist\n\n";
sleep(2);
}
}
?>