2017-08-26 19:53:34 +02:00
|
|
|
<?php
|
|
|
|
class DemonoidBridge extends BridgeAbstract {
|
|
|
|
|
|
|
|
const MAINTAINER = 'metaMMA';
|
|
|
|
const NAME = 'Demonoid';
|
|
|
|
const URI = 'https://www.demonoid.pw/';
|
2018-04-17 15:25:02 +02:00
|
|
|
const DESCRIPTION = 'Returns results from search';
|
2017-08-26 19:53:34 +02:00
|
|
|
|
2019-01-05 12:29:26 +01:00
|
|
|
const PARAMETERS = array(
|
|
|
|
'Keywords' => array(
|
|
|
|
'q' => array(
|
|
|
|
'name' => 'keywords',
|
|
|
|
'exampleValue' => 'keyword1 keyword2…',
|
|
|
|
'required' => true,
|
|
|
|
),
|
|
|
|
'category' => array(
|
|
|
|
'name' => 'Category',
|
|
|
|
'type' => 'list',
|
|
|
|
'values' => array(
|
|
|
|
'All' => 0,
|
|
|
|
'Movies' => 1,
|
|
|
|
'Music' => 2,
|
|
|
|
'TV' => 3,
|
|
|
|
'Games' => 4,
|
|
|
|
'Applications' => 5,
|
|
|
|
'Pictures' => 8,
|
|
|
|
'Anime' => 9,
|
|
|
|
'Comics' => 10,
|
|
|
|
'Books' => 11,
|
|
|
|
'Audiobooks' => 17
|
|
|
|
)
|
2018-04-17 15:25:02 +02:00
|
|
|
)
|
2019-01-05 12:29:26 +01:00
|
|
|
),
|
|
|
|
'Category Only' => array(
|
|
|
|
'catOnly' => array(
|
|
|
|
'name' => 'Category',
|
|
|
|
'type' => 'list',
|
|
|
|
'values' => array(
|
|
|
|
'All' => 0,
|
|
|
|
'Movies' => 1,
|
|
|
|
'Music' => 2,
|
|
|
|
'TV' => 3,
|
|
|
|
'Games' => 4,
|
|
|
|
'Applications' => 5,
|
|
|
|
'Pictures' => 8,
|
|
|
|
'Anime' => 9,
|
|
|
|
'Comics' => 10,
|
|
|
|
'Books' => 11,
|
|
|
|
'Audiobooks' => 17
|
|
|
|
)
|
2018-04-17 15:25:02 +02:00
|
|
|
)
|
|
|
|
),
|
2019-01-05 12:29:26 +01:00
|
|
|
'User ID' => array(
|
|
|
|
'userid' => array(
|
|
|
|
'name' => 'user id',
|
|
|
|
'exampleValue' => '00000',
|
|
|
|
'required' => true,
|
|
|
|
'type' => 'number'
|
|
|
|
),
|
|
|
|
'category' => array(
|
|
|
|
'name' => 'Category',
|
|
|
|
'type' => 'list',
|
|
|
|
'values' => array(
|
|
|
|
'All' => 0,
|
|
|
|
'Movies' => 1,
|
|
|
|
'Music' => 2,
|
|
|
|
'TV' => 3,
|
|
|
|
'Games' => 4,
|
|
|
|
'Applications' => 5,
|
|
|
|
'Pictures' => 8,
|
|
|
|
'Anime' => 9,
|
|
|
|
'Comics' => 10,
|
|
|
|
'Books' => 11,
|
|
|
|
'Audiobooks' => 17
|
|
|
|
)
|
2018-04-17 15:25:02 +02:00
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2017-08-26 19:53:34 +02:00
|
|
|
|
|
|
|
public function collectData() {
|
|
|
|
|
2018-04-17 15:25:02 +02:00
|
|
|
if(!empty($this->getInput('q'))) {
|
2017-08-26 19:53:34 +02:00
|
|
|
|
2018-04-17 15:25:02 +02:00
|
|
|
$html = getSimpleHTMLDOM(
|
|
|
|
self::URI .
|
|
|
|
'files/?category=' .
|
|
|
|
rawurlencode($this->getInput('category')) .
|
|
|
|
'&subcategory=All&quality=All&seeded=2&external=2&query=' .
|
|
|
|
urlencode($this->getInput('q')) .
|
|
|
|
'&uid=0&sort='
|
|
|
|
) or returnServerError('Could not request Demonoid.');
|
2017-08-26 19:53:34 +02:00
|
|
|
|
2018-04-17 15:25:02 +02:00
|
|
|
} elseif(!empty($this->getInput('catOnly'))) {
|
|
|
|
|
|
|
|
$html = getSimpleHTMLDOM(
|
|
|
|
self::URI .
|
|
|
|
'files/?uid=0&category=' .
|
|
|
|
rawurlencode($this->getInput('catOnly')) .
|
|
|
|
'&subcategory=0&language=0&seeded=2&quality=0&query=&sort='
|
|
|
|
) or returnServerError('Could not request Demonoid.');
|
2017-08-26 19:53:34 +02:00
|
|
|
|
2018-04-17 15:25:02 +02:00
|
|
|
} elseif(!empty($this->getInput('userid'))) {
|
2017-08-26 19:53:34 +02:00
|
|
|
|
2018-04-17 15:25:02 +02:00
|
|
|
$html = getSimpleHTMLDOM(
|
|
|
|
self::URI .
|
|
|
|
'files/?uid=' .
|
|
|
|
rawurlencode($this->getInput('userid')) .
|
|
|
|
'&seeded=2'
|
|
|
|
) or returnServerError('Could not request Demonoid.');
|
|
|
|
|
|
|
|
} else {
|
|
|
|
returnServerError('Invalid parameters !');
|
|
|
|
}
|
|
|
|
|
|
|
|
if(preg_match('~No torrents found~', $html)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$table = $html->find('td[class=ctable_content_no_pad]', 0);
|
|
|
|
$cursorCount = 4;
|
|
|
|
$elementCount = 0;
|
|
|
|
while($elementCount != 40) {
|
|
|
|
$elementCount++;
|
|
|
|
$currentElement = $table->find('tr', $cursorCount);
|
|
|
|
if(preg_match('~items total~', $currentElement)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$item = array();
|
|
|
|
//Do we have a date ?
|
|
|
|
if(preg_match('~Added.*?(.*)~', $currentElement->plaintext, $dateStr)) {
|
2017-08-26 19:53:34 +02:00
|
|
|
if(preg_match('~today~', $dateStr[0])) {
|
|
|
|
date_default_timezone_set('UTC');
|
|
|
|
$timestamp = mktime(0, 0, 0, gmdate('n'), gmdate('j'), gmdate('Y'));
|
2018-04-17 15:25:02 +02:00
|
|
|
} else {
|
|
|
|
preg_match('~(?<=ed on ).*\d+~', $currentElement->plaintext, $fullDateStr);
|
2017-08-26 19:53:34 +02:00
|
|
|
date_default_timezone_set('UTC');
|
|
|
|
$dateObj = strptime($fullDateStr[0], '%A, %b %d, %Y');
|
|
|
|
$timestamp = mktime(0, 0, 0, $dateObj['tm_mon'] + 1, $dateObj['tm_mday'], 1900 + $dateObj['tm_year']);
|
|
|
|
}
|
2018-04-17 15:25:02 +02:00
|
|
|
$cursorCount++;
|
|
|
|
}
|
2017-08-26 19:53:34 +02:00
|
|
|
|
2018-04-17 15:25:02 +02:00
|
|
|
$content = $table->find('tr', $cursorCount)->find('a', 1);
|
|
|
|
$cursorCount++;
|
|
|
|
$torrentInfo = $table->find('tr', $cursorCount);
|
|
|
|
$item['timestamp'] = $timestamp;
|
|
|
|
$item['title'] = $content->plaintext;
|
|
|
|
$item['id'] = self::URI . $content->href;
|
|
|
|
$item['uri'] = self::URI . $content->href;
|
|
|
|
$item['author'] = $torrentInfo->find('a[class=user]', 0)->plaintext;
|
|
|
|
$item['seeders'] = $torrentInfo->find('font[class=green]', 0)->plaintext;
|
|
|
|
$item['leechers'] = $torrentInfo->find('font[class=red]', 0)->plaintext;
|
|
|
|
$item['size'] = $torrentInfo->find('td', 3)->plaintext;
|
|
|
|
$item['content'] = 'Uploaded by ' . $item['author']
|
|
|
|
. ' , Size ' . $item['size']
|
|
|
|
. '<br>seeders: '
|
|
|
|
. $item['seeders']
|
|
|
|
. ' | leechers: '
|
|
|
|
. $item['leechers']
|
|
|
|
. '<br><a href="'
|
|
|
|
. $item['id']
|
|
|
|
. '">info page</a>';
|
2017-08-26 19:53:34 +02:00
|
|
|
|
2018-04-17 15:25:02 +02:00
|
|
|
$this->items[] = $item;
|
|
|
|
|
|
|
|
$cursorCount++;
|
2017-08-26 19:53:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|