4
0
Эх сурвалжийг харах

Merge pull request #1718 from TehMuffinMoo/patch-2

Update getuTorrentToken to use PHPHtmlParser\Dom
causefx 4 жил өмнө
parent
commit
c62fe7ab2f
1 өөрчлөгдсөн 38 нэмэгдсэн , 17 устгасан
  1. 38 17
      api/homepage/utorrent.php

+ 38 - 17
api/homepage/utorrent.php

@@ -117,11 +117,11 @@ trait uTorrentHomepageItem
 				$options = array_merge($options, $credentials);
 			}
 			$response = Requests::post($url, [], $data, $options);
-			$doc = new DOMDocument();
-			$doc->loadHTML($response->body);
-			$id = $doc->getElementById('token');
+			$dom = new PHPHtmlParser\Dom;
+			$dom->loadStr($response->body);
+			$id = $dom->getElementById('token')->text;
 			$uTorrentConfig = new stdClass();
-			$uTorrentConfig->uTorrentToken = $id->textContent;
+			$uTorrentConfig->uTorrentToken = $id;
 			$reflection = new ReflectionClass($response->cookies);
 			$cookie = $reflection->getProperty("cookies");
 			$cookie->setAccessible(true);
@@ -182,18 +182,39 @@ trait uTorrentHomepageItem
 					} else if ($this->config['uTorrentHideCompleted'] && $Status == "Finished") {
 						// Do Nothing
 					} else {
-						$value = array(
-							'Name' => $keyArr[2],
-							'Labels' => $keyArr[11],
-							'Percent' => str_replace(' ', '', $matches['Percentage']),
-							'Status' => $Status,
-							'Availability' => $keyArr[4],
-							'Done' => $keyArr[5],
-							'Size' => $keyArr[3],
-							'upSpeed' => $keyArr[8],
-							'downSpeed' => $keyArr[9],
-							'Message' => $keyArr[21],
-						);
+                                                $value = array(
+                                                        'Hash' => $keyArr[0],
+                                                        'TorrentStatus' => $keyArr[1],
+                                                        'Name' => $keyArr[2],
+                                                        'Size' => $keyArr[3],
+                                                        'Progress' => $keyArr[4],
+                                                        'Downloaded' => $keyArr[5],
+                                                        'Uploaded' => $keyArr[6],
+                                                        'Ratio' => $keyArr[7],
+                                                        'upSpeed' => $keyArr[8],
+                                                        'downSpeed' => $keyArr[9],
+                                                        'eta' => $keyArr[10],
+                                                        'Labels' => $keyArr[11],
+                                                        'PeersConnected' => $keyArr[12],
+                                                        'PeersInSwarm' => $keyArr[13],
+                                                        'SeedsConnected' => $keyArr[14],
+                                                        'SeedsInSwarm' => $keyArr[15],
+                                                        'Availability' => $keyArr[16],
+                                                        'TorrentQueueOrder' => $keyArr[17],
+                                                        'Remaining' => $keyArr[18],
+                                                        'DownloadUrl' => $keyArr[19],
+                                                        'RssFeedUrl' => $keyArr[20],
+                                                        'Message' => $keyArr[21],
+                                                        'StreamId' => $keyArr[22],
+                                                        'DateAdded' => $keyArr[23],
+                                                        'DateCompleted' => $keyArr[24],
+                                                        'AppUpdateUrl' => $keyArr[25],
+                                                        'RootDownloadPath' => $keyArr[26],
+                                                        'Unknown27' => $keyArr[27],
+                                                        'Unknown28' => $keyArr[28],
+                                                        'Status' => $Status,
+                                                        'Percent' => str_replace(' ', '', $matches['Percentage']),
+                                                );
 						array_push($valueArray, $value);
 					}
 				}
@@ -210,4 +231,4 @@ trait uTorrentHomepageItem
 	}
 	
 	
-}
+}