returnError('You must specify a keyword (?q=...)', 400);
$html = file_get_html('https://thepiratebay.se/search/'.rawurlencode($param['q']).'/0/99/0') or $this->returnError('Could not request TPB.', 404);
if($html->find('table#searchResult', 0) == FALSE)
$this->returnError('No result for this query', 404);
foreach($html->find('tr') as $element) {
$item = new \Item();
$item->uri = 'https://thepiratebay.se/'.$element->find('a.detLink',0)->href;
$item->id = $item->uri;
$item->timestamp = time();
$item->title = $element->find('a.detLink',0)->plaintext;
$item->seeders = (int)$element->find('td',2)->plaintext;
$item->leechers = (int)$element->find('td',3)->plaintext;
$item->content = $element->find('font',0)->plaintext.'
seeders: '.$item->seeders.' | leechers: '.$item->leechers.'
download';
if(!empty($item->title))
$this->items[] = $item;
}
}
public function getName(){
return 'The Pirate Bay';
}
public function getURI(){
return 'https://thepiratebay.se/';
}
public function getCacheDuration(){
return 3600; // 1 hour
}
}