[YGGTorrentBridge] URL encode the first parts of the requests.

This commit is contained in:
teromene 2018-04-26 22:57:18 +01:00
parent e60b5ab193
commit df33dcff4e

View file

@ -105,7 +105,10 @@ class YGGTorrentBridge extends BridgeAbstract {
or returnServerError("Unable to query Yggtorrent !"); or returnServerError("Unable to query Yggtorrent !");
$count = 0; $count = 0;
foreach($html->find(".results", 0)->find("tr") as $row) { $results = $html->find(".results", 0);
if(!$results) return;
foreach($results->find("tr") as $row) {
$count++; $count++;
if($count == 1) continue; if($count == 1) continue;
if($count == 12) break; if($count == 12) break;
@ -118,6 +121,7 @@ class YGGTorrentBridge extends BridgeAbstract {
$item["seeders"] = $row->find("td", 7)->plaintext; $item["seeders"] = $row->find("td", 7)->plaintext;
$item["leechers"] = $row->find("td", 8)->plaintext; $item["leechers"] = $row->find("td", 8)->plaintext;
$item["size"] = $row->find("td", 5)->plaintext; $item["size"] = $row->find("td", 5)->plaintext;
$this->items[] = $item; $this->items[] = $item;
} }
@ -127,9 +131,10 @@ class YGGTorrentBridge extends BridgeAbstract {
//For weird reason, the link we get can be invalid, we fix it. //For weird reason, the link we get can be invalid, we fix it.
$url_full = explode("/", $url); $url_full = explode("/", $url);
$url_full[4] = urlencode($url_full[4]);
$url_full[5] = urlencode($url_full[5]);
$url_full[6] = urlencode($url_full[6]); $url_full[6] = urlencode($url_full[6]);
$url = implode("/", $url_full); $url = implode("/", $url_full);
$page = getSimpleHTMLDOM($url) or returnServerError("Unable to query Yggtorrent page !"); $page = getSimpleHTMLDOM($url) or returnServerError("Unable to query Yggtorrent page !");
$author = $page->find(".informations", 0)->find("a", 4)->plaintext; $author = $page->find(".informations", 0)->find("a", 4)->plaintext;
$content = $page->find(".default", 1); $content = $page->find(".default", 1);