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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
<?php
class AnyLoader {
function __construct($host = "localhost", $port = 8964)
{
$this->socket = @pfsockopen($host, $port, $errno, $errmsg);
if (!$this->socket)
die($errmsg);
}
private function request() {
$args = func_get_args();
$request = implode("|", $args);
fwrite($this->socket, $request."\n");
fflush($this->socket);
$response = trim(fgets($this->socket));
if ($response == "||||||||") {
$fullText = "";
while (($response = fgets($this->socket)) != "||||||||\n")
$fullText .= $response;
return $fullText;
} else if ($response == "|||||||||||||") {
$entries = array();
while (($response = trim(fgets($this->socket))) != "|||||||||||||")
$entries[] = $this->parseLine($response);
return $entries;
} else
return $this->parseLine($response);
}
private function parseLine($line)
{
if ($line == "error")
return false;
elseif ($line == "success")
return true;
elseif (strpos($line, "|") !== false)
return explode("|", $line);
elseif ($line == "1")
return true;
elseif ($line == "0")
return false;
else
return $line;
}
public function getTitleInformation($movieTitle) {
return $this->request("getTitleInformation", $movieTitle);
}
public function getTitles() {
$ret = $this->request("getTitles");
if ($ret === false)
return array();
$all = array();
foreach ($ret as $structure) {
$all[] = (object)array(
"title" => $structure[0],
"hasRipped" => ($structure[1] == "1" ? true : false),
"hasEncoded" => ($structure[2] == "1" ? true : false),
"hasUploaded" => ($structure[3] == "1" ? true : false),
"videoTrack" => (int)$structure[4],
"audioTrack" => (int)$structure[5]
);
}
return $all;
}
public function addISO($fileName) {
return $this->request("addISO", $fileName);
}
public function addRecursiveISOs($dirName) {
return $this->request("addRecursiveISOs", $dirName);
}
public function setVideoTrack($movieTitle, $videoTrack) {
return $this->request("setVideoTrack", $movieTitle, $videoTrack);
}
public function setAudioTrack($movieTitle, $audioTrack) {
return $this->request("setAudioTrack", $movieTitle, $audioTrack);
}
public function ripStatus() {
return $this->request("ripStatus");
}
public function encodeStatus() {
return $this->request("encodeStatus");
}
public function uploadStatus() {
return $this->request("uploadStatus");
}
public function terminateRip() {
return $this->request("terminateRip");
}
public function terminateEncode() {
return $this->request("terminateEncode");
}
public function terminateUpload() {
return $this->request("terminateUpload");
}
public function startTerminatedTasks() {
return $this->request("startTerminatedTasks");
}
public function removeMovie($movieTitle) {
return $this->request("removeMovie", $movieTitle);
}
public function isRippingEnabled() {
return $this->request("isRippingEnabled");
}
}
?>
|