Skip to content

Commit

Permalink
Return the number of results found
Browse files Browse the repository at this point in the history
  • Loading branch information
mcartoixa committed Jan 24, 2018
1 parent 67786a1 commit 80b5866
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ php:
- '5.6'

env:
- DLM_PACKAGE_VERSION=1.0.$TRAVIS_BUILD_NUMBER
- DLM_PACKAGE_VERSION=1.1.$TRAVIS_BUILD_NUMBER

install:
- php bin/composer.phar install -n
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Build status](https://travis-ci.org/mcartoixa/synology-dlm-tpb.svg?branch=master)](https://travis-ci.org/mcartoixa/synology-dlm-tpb)
# Installation
- Download the latest version of the module and install it in the [BT Search section of Download Station](https://www.synology.com/en-global/knowledgebase/DSM/help/DownloadStation/download_setup#torrent).
- Download [the latest version of the module](https://github.com/mcartoixa/synology-dlm-tpb/releases/latest) and install it in the [BT Search section of Download Station](https://www.synology.com/en-global/knowledgebase/DSM/help/DownloadStation/download_setup#torrent).

# Development
## Build
Expand Down
9 changes: 9 additions & 0 deletions dlm/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public function prepare($curl, $query)

public function parse($plugin, $response)
{
$ret = 0;

$internalErrors = libxml_use_internal_errors(true);

$dom = new DOMDocument('1.0', 'UTF-8');
Expand All @@ -36,7 +38,9 @@ public function parse($plugin, $response)
{
$titleNodes = $xpath->query('.//div[@class="detName"]/a', $resultNode);
if (empty($titleNodes))
{
continue;
}

$title = trim($titleNodes[0]->nodeValue);
if ($title!='')
Expand All @@ -47,7 +51,9 @@ public function parse($plugin, $response)
$lineNodes = $xpath->query('.//td', $resultNode);

if (empty($downloadNodes))
{
continue;
}
$download = $downloadNodes[0]->getAttribute('href');
$size = 0.0;
$datetime = '1970-01-01 00:00:00';
Expand Down Expand Up @@ -99,10 +105,13 @@ public function parse($plugin, $response)
$category = trim($categoryNodes[0]->nodeValue);

$plugin->addResult($title, $download, $size, $datetime, $page, $hash, $seeds, $leechs, $category);
$ret++;
}
}

libxml_use_internal_errors($internalErrors);

return $ret;
}
}
?>
4 changes: 2 additions & 2 deletions dlm/tests/querier.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
$response = curl_exec($curl);
if ($response===false)
{
echo 'Error: ' . curl_error($curl);
echo 'Error: ' . curl_error($curl)."\n";
} else
{
$search->parse($plugin, $response);
foreach ($plugin->results as $result)
{
printf('\t%s %s %d %d\n', $result->title, $result->datetime, $result->seeds, $result->leechs);
printf("\t%s %s %d %d\n", $result->title, $result->datetime, $result->seeds, $result->leechs);
}
}
curl_close($curl);
Expand Down

0 comments on commit 80b5866

Please sign in to comment.