diff --git a/engines/bittorrent/1337x.php b/engines/bittorrent/1337x.php index 5dd82dd..2bf498c 100644 --- a/engines/bittorrent/1337x.php +++ b/engines/bittorrent/1337x.php @@ -3,32 +3,37 @@ function get_1337x_results($response) { - global $config; - $xpath = get_xpath($response); - $results = array(); + try { + global $config; + $xpath = get_xpath($response); + $results = array(); - foreach($xpath->query("//table/tbody/tr") as $result) - { + foreach($xpath->query("//table/tbody/tr") as $result) + { - $name = $xpath->evaluate(".//td[@class='coll-1 name']/a", $result)[1]->textContent; - $magnet = "/engines/bittorrent/get_magnet_1337x.php?url=https://1337x.to" . $xpath->evaluate(".//td[@class='coll-1 name']/a/@href", $result)[1]->textContent; - $size_unformatted = explode(" ", $xpath->evaluate(".//td[contains(@class, 'coll-4 size')]", $result)[0]->textContent); - $size = $size_unformatted[0] . " " . preg_replace("/[0-9]+/", "", $size_unformatted[1]); - $seeders = $xpath->evaluate(".//td[@class='coll-2 seeds']", $result)[0]->textContent; - $leechers = $xpath->evaluate(".//td[@class='coll-3 leeches']", $result)[0]->textContent; + $name = $xpath->evaluate(".//td[@class='coll-1 name']/a", $result)[1]->textContent; + $magnet = "/engines/bittorrent/get_magnet_1337x.php?url=https://1337x.to" . $xpath->evaluate(".//td[@class='coll-1 name']/a/@href", $result)[1]->textContent; + $size_unformatted = explode(" ", $xpath->evaluate(".//td[contains(@class, 'coll-4 size')]", $result)[0]->textContent); + $size = $size_unformatted[0] . " " . preg_replace("/[0-9]+/", "", $size_unformatted[1]); + $seeders = $xpath->evaluate(".//td[@class='coll-2 seeds']", $result)[0]->textContent; + $leechers = $xpath->evaluate(".//td[@class='coll-3 leeches']", $result)[0]->textContent; - array_push($results, - array ( - "name" => htmlspecialchars($name), - "seeders" => (int) $seeders, - "leechers" => (int) $leechers, - "magnet" => htmlspecialchars($magnet), - "size" => htmlspecialchars($size), - "source" => "1337x.tw" - ) - ); + array_push($results, + array ( + "name" => htmlspecialchars($name), + "seeders" => (int) $seeders, + "leechers" => (int) $leechers, + "magnet" => htmlspecialchars($magnet), + "size" => htmlspecialchars($size), + "source" => "1337x.tw" + ) + ); + } + + return $results; + + } catch (Error $e) { + return array(); } - - return $results; } ?> diff --git a/engines/bittorrent/nyaa.php b/engines/bittorrent/nyaa.php index e2b846d..ce88cbf 100644 --- a/engines/bittorrent/nyaa.php +++ b/engines/bittorrent/nyaa.php @@ -1,25 +1,26 @@ query("//tbody/tr") as $result) - { + foreach ($xpath->query("//tbody/tr") as $result) { $name = $xpath->evaluate(".//td[@colspan='2']//a[not(contains(@class, 'comments'))]/@title", $result)[0]->textContent; $centered = $xpath->evaluate(".//td[@class='text-center']", $result); $magnet = $xpath->evaluate(".//a[2]/@href", $centered[0])[0]->textContent; $magnet_without_tracker = explode("&tr=", $magnet)[0]; $magnet = $magnet_without_tracker . $config->bittorent_trackers; - $size = $centered[1]->textContent; - $seeders = $centered[3]->textContent; - $leechers = $centered[4]->textContent; + $size = $centered[1]->textContent; + $seeders = $centered[3]->textContent; + $leechers = $centered[4]->textContent; - array_push($results, - array ( + array_push( + $results, + array( "name" => htmlspecialchars($name), "seeders" => (int) $seeders, "leechers" => (int) $leechers, @@ -31,5 +32,8 @@ } return $results; + } catch (Error $e) { + return array(); } -?> +} +?> \ No newline at end of file diff --git a/engines/bittorrent/rutor.php b/engines/bittorrent/rutor.php index c5db2d5..5e621d3 100644 --- a/engines/bittorrent/rutor.php +++ b/engines/bittorrent/rutor.php @@ -1,26 +1,27 @@ query("//table/tr[@class='gai' or @class='tum']") as $result) - { + foreach ($xpath->query("//table/tr[@class='gai' or @class='tum']") as $result) { $name = $xpath->evaluate(".//td/a", $result)[2]->textContent; - $magnet = $xpath->evaluate(".//td/a/@href", $result)[1]->textContent; + $magnet = $xpath->evaluate(".//td/a/@href", $result)[1]->textContent; $magnet_without_tracker = explode("&tr=", $magnet)[0]; $magnet = $magnet_without_tracker . $config->bittorent_trackers; $size = $xpath->evaluate(".//td", $result)[3]->textContent; $seeders = $xpath->evaluate(".//span", $result)[0]->textContent; $leechers = $xpath->evaluate(".//span", $result)[1]->textContent; - array_push($results, - array ( + array_push( + $results, + array( "name" => htmlspecialchars($name), "seeders" => (int) remove_special($seeders), "leechers" => (int) remove_special($leechers), @@ -32,5 +33,9 @@ } return $results; + + } catch (Error $e) { + return array(); } -?> +} +?> \ No newline at end of file diff --git a/engines/bittorrent/sukebei.php b/engines/bittorrent/sukebei.php index 65fd177..a7f8838 100644 --- a/engines/bittorrent/sukebei.php +++ b/engines/bittorrent/sukebei.php @@ -1,25 +1,26 @@ query("//tbody/tr") as $result) - { + foreach ($xpath->query("//tbody/tr") as $result) { $name = $xpath->evaluate(".//td[@colspan='2']//a[not(contains(@class, 'comments'))]/@title", $result)[0]->textContent; $centered = $xpath->evaluate(".//td[@class='text-center']", $result); $magnet = $xpath->evaluate(".//a[2]/@href", $centered[0])[0]->textContent; $magnet_without_tracker = explode("&tr=", $magnet)[0]; $magnet = $magnet_without_tracker . $config->bittorent_trackers; - $size = $centered[1]->textContent; - $seeders = $centered[3]->textContent; - $leechers = $centered[4]->textContent; + $size = $centered[1]->textContent; + $seeders = $centered[3]->textContent; + $leechers = $centered[4]->textContent; - array_push($results, - array ( + array_push( + $results, + array( "name" => htmlspecialchars($name), "seeders" => (int) $seeders, "leechers" => (int) $leechers, @@ -31,5 +32,8 @@ } return $results; + } catch (Error $e) { + return array(); } -?> +} +?> \ No newline at end of file diff --git a/engines/bittorrent/thepiratebay.php b/engines/bittorrent/thepiratebay.php index 49b2476..961ce0d 100644 --- a/engines/bittorrent/thepiratebay.php +++ b/engines/bittorrent/thepiratebay.php @@ -1,22 +1,21 @@ htmlspecialchars($size), "name" => htmlspecialchars($name), "seeders" => (int) htmlspecialchars($seeders), @@ -39,6 +39,8 @@ } return $results; - + } catch (Error $e) { + return array(); } -?> +} +?> \ No newline at end of file diff --git a/engines/bittorrent/yts.php b/engines/bittorrent/yts.php index f3a588d..aef8923 100644 --- a/engines/bittorrent/yts.php +++ b/engines/bittorrent/yts.php @@ -1,31 +1,30 @@ bittorent_trackers"; + $magnet = "magnet:?xt=urn:btih:$hash&dn=$name_encoded$config->bittorent_trackers"; - array_push($results, - array ( + array_push( + $results, + array( "size" => htmlspecialchars($size), "name" => htmlspecialchars($name), "seeders" => htmlspecialchars($seeders), @@ -34,12 +33,14 @@ "source" => "yts.mx" ) ); - - } + + } } } return $results; - + } catch (Error $e) { + return array(); } -?> +} +?> \ No newline at end of file