2016-08-14 21:27:07 +02:00
|
|
|
<?php
|
|
|
|
class IsoHuntBridge extends BridgeAbstract{
|
2016-08-27 21:03:26 +02:00
|
|
|
public $maintainer = 'logmanoriginal';
|
|
|
|
public $name = 'isoHunt Bridge'; // Is replaced later!
|
|
|
|
public $uri = 'https://isohunt.to'; // Is replaced later!
|
|
|
|
public $description = 'Returns the latest results by category or search result';
|
2016-08-14 21:27:07 +02:00
|
|
|
|
2016-08-27 21:03:26 +02:00
|
|
|
public $parameters = array(
|
2016-08-14 21:27:07 +02:00
|
|
|
/*
|
2016-08-27 21:03:26 +02:00
|
|
|
* Get feeds for one of the "latest" categories
|
|
|
|
* Notice: The categories "News" and "Top Searches" are received from the main page
|
|
|
|
* Elements are sorted by name ascending!
|
|
|
|
*/
|
|
|
|
'By "Latest" category' => array(
|
|
|
|
'latest_category'=>array(
|
|
|
|
'name'=>'Latest category',
|
|
|
|
'type'=>'list',
|
|
|
|
'required'=>true,
|
|
|
|
'title'=>'Select your category',
|
|
|
|
'defaultValue'=>'News',
|
|
|
|
'values'=>array(
|
|
|
|
'Hot Torrents'=>'hot_torrents',
|
|
|
|
'News'=>'news',
|
|
|
|
'Releases'=>'releases',
|
|
|
|
'Torrents'=>'torrents'
|
|
|
|
)
|
2016-08-22 01:25:56 +02:00
|
|
|
)
|
2016-08-27 21:03:26 +02:00
|
|
|
),
|
2016-08-14 21:27:07 +02:00
|
|
|
|
|
|
|
/*
|
2016-08-27 21:03:26 +02:00
|
|
|
* Get feeds for one of the "torrent" categories
|
|
|
|
* Make sure to add new categories also to get_torrent_category_index($)!
|
|
|
|
* Elements are sorted by name ascending!
|
|
|
|
*/
|
|
|
|
'By "Torrent" category' => array(
|
|
|
|
'torrent_category'=>array(
|
|
|
|
'name'=>'Torrent category',
|
|
|
|
'type'=>'list',
|
|
|
|
'required'=>true,
|
|
|
|
'title'=>'Select your category',
|
|
|
|
'defaultValue'=>'Anime',
|
|
|
|
'values'=>array(
|
|
|
|
'Adult'=>'adult',
|
|
|
|
'Anime'=>'anime',
|
|
|
|
'Books'=>'books',
|
|
|
|
'Games'=>'games',
|
|
|
|
'Movies'=>'movies',
|
|
|
|
'Music'=>'music',
|
|
|
|
'Other'=>'other',
|
|
|
|
'Series & TV'=>'series_tv',
|
|
|
|
'Software'=>'software'
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'torrent_popularity'=>array(
|
|
|
|
'name'=>'Sort by popularity',
|
|
|
|
'type'=>'checkbox',
|
|
|
|
'title'=>'Activate to receive results by popularity'
|
2016-08-22 01:25:56 +02:00
|
|
|
)
|
2016-08-27 21:03:26 +02:00
|
|
|
),
|
2016-08-14 21:27:07 +02:00
|
|
|
|
|
|
|
/*
|
2016-08-27 21:03:26 +02:00
|
|
|
* Get feeds for a specific search request
|
|
|
|
*/
|
|
|
|
'Search torrent by name' => array(
|
|
|
|
'search_name'=>array(
|
|
|
|
'name'=>'Name',
|
|
|
|
'required'=>true,
|
|
|
|
'title'=>'Insert your search query',
|
|
|
|
'exampleValue'=>'Bridge'
|
|
|
|
),
|
|
|
|
'search_category'=>array(
|
|
|
|
'name'=>'Category',
|
|
|
|
'type'=>'list',
|
|
|
|
'title'=>'Select your category',
|
|
|
|
'defaultValue'=>'All',
|
|
|
|
'values'=>array(
|
|
|
|
'Adult'=>'adult',
|
|
|
|
'All'=>'all',
|
|
|
|
'Anime'=>'anime',
|
|
|
|
'Books'=>'books',
|
|
|
|
'Games'=>'games',
|
|
|
|
'Movies'=>'movies',
|
|
|
|
'Music'=>'music',
|
|
|
|
'Other'=>'other',
|
|
|
|
'Series & TV'=>'series_tv',
|
|
|
|
'Software'=>'software'
|
|
|
|
)
|
2016-08-22 01:25:56 +02:00
|
|
|
)
|
2016-08-27 21:03:26 +02:00
|
|
|
)
|
|
|
|
);
|
2016-08-14 21:27:07 +02:00
|
|
|
|
2016-08-25 01:24:53 +02:00
|
|
|
public function collectData(){
|
2016-08-14 21:27:07 +02:00
|
|
|
$request_path = '/'; // We'll request the main page by default
|
|
|
|
|
2016-08-28 20:38:01 +02:00
|
|
|
if($this->getInput('latest_category')){ // Requesting one of the latest categories
|
2016-08-28 01:25:33 +02:00
|
|
|
$this->request_latest_category($this->getInput('latest_category'));
|
2016-08-28 20:38:01 +02:00
|
|
|
} elseif($this->getInput('torrent_category')){ // Requesting one of the torrent categories
|
2016-08-14 21:27:07 +02:00
|
|
|
$order_popularity = false;
|
|
|
|
|
2016-08-28 20:38:01 +02:00
|
|
|
if($this->getInput('torrent_popularity'))
|
2016-08-28 01:25:33 +02:00
|
|
|
$order_popularity = $this->getInput('torrent_popularity');
|
2016-08-14 21:27:07 +02:00
|
|
|
|
2016-08-28 01:25:33 +02:00
|
|
|
$this->request_torrent_category($this->getInput('torrent_category'), $order_popularity);
|
2016-08-28 20:38:01 +02:00
|
|
|
} else if($this->getInput('search_name')){ // Requesting search
|
|
|
|
if($this->getInput('search_category'))
|
2016-08-28 01:25:33 +02:00
|
|
|
$this->request_search($this->getInput('search_name'), $this->getInput('search_category'));
|
2016-08-14 21:27:07 +02:00
|
|
|
else
|
2016-08-28 01:25:33 +02:00
|
|
|
$this->request_search($this->getInput('search_name'));
|
2016-08-14 21:27:07 +02:00
|
|
|
} else {
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnClientError('Unknown request!');
|
2016-08-14 21:27:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCacheDuration(){
|
|
|
|
return 300; // 5 minutes
|
|
|
|
}
|
|
|
|
|
|
|
|
#region Helper functions for "By "Torrent" category"
|
|
|
|
|
|
|
|
private function request_torrent_category($category, $order_popularity){
|
|
|
|
$category_name = $this->get_torrent_category_name($category);
|
|
|
|
$category_index = $this->get_torrent_category_index($category);
|
|
|
|
|
|
|
|
$this->name = 'Category: ' . $category_name . ' - ' . $this->name;
|
|
|
|
$this->uri .= $this->build_category_uri($category_index, $order_popularity);
|
|
|
|
|
|
|
|
$html = $this->load_html($this->uri);
|
|
|
|
|
|
|
|
if(strtolower(trim($category)) === 'movies') // This one is special (content wise)
|
|
|
|
$this->get_movie_torrents($html);
|
|
|
|
else
|
|
|
|
$this->get_latest_torrents($html);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function get_torrent_category_name($category){
|
2016-08-22 01:25:56 +02:00
|
|
|
$parameter = $this->parameters['By "Torrent" category'];
|
|
|
|
$languages = $parameter['torrent_category']['values'];
|
|
|
|
|
|
|
|
foreach($languages as $name=>$value)
|
|
|
|
if(strtolower(trim($value)) === strtolower(trim($category)))
|
|
|
|
return $name;
|
2016-08-14 21:27:07 +02:00
|
|
|
|
|
|
|
return 'Unknown category';
|
|
|
|
}
|
|
|
|
|
|
|
|
private function get_torrent_category_index($category){
|
|
|
|
switch(strtolower(trim($category))){
|
|
|
|
case 'anime': return 1;
|
|
|
|
case 'software' : return 2;
|
|
|
|
case 'games' : return 3;
|
|
|
|
case 'adult' : return 4;
|
|
|
|
case 'movies' : return 5;
|
|
|
|
case 'music' : return 6;
|
|
|
|
case 'other' : return 7;
|
|
|
|
case 'series_tv' : return 8;
|
|
|
|
case 'books': return 9;
|
|
|
|
default: return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
private function request_latest_category($category){
|
|
|
|
switch($category){
|
2016-08-22 19:37:18 +02:00
|
|
|
case 'hot_torrents': // This is a special case! (that's why return)
|
2016-08-14 21:27:07 +02:00
|
|
|
$this->name = 'Latest hot torrents - ' . $this->name;
|
|
|
|
$this->uri .= '/statistic/hot/torrents';
|
2016-08-22 19:37:18 +02:00
|
|
|
$html = $this->load_html($this->uri);
|
|
|
|
$this->get_latest_hot_torrents($html);
|
|
|
|
return;
|
|
|
|
case 'news': // This is a special case! (that's why return)
|
2016-08-14 21:27:07 +02:00
|
|
|
$this->name = 'Latest news - ' . $this->name;
|
|
|
|
$this->uri .= '/';
|
2016-08-22 19:37:18 +02:00
|
|
|
$html = $this->load_html($this->uri);
|
|
|
|
$this->get_latest_news($html);
|
|
|
|
return;
|
2016-08-22 01:25:56 +02:00
|
|
|
case 'releases':
|
2016-08-14 21:27:07 +02:00
|
|
|
$this->name = 'Latest releases - ' . $this->name;
|
|
|
|
$this->uri .= '/releases.php';
|
|
|
|
break;
|
2016-08-22 01:25:56 +02:00
|
|
|
case 'torrents':
|
2016-08-14 21:27:07 +02:00
|
|
|
$this->name = 'Latest torrents - ' . $this->name;
|
|
|
|
$this->uri .= '/latest.php';
|
|
|
|
break;
|
|
|
|
default: // No category applies
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnClientError('Undefined category: ' . $category . '!');
|
2016-08-14 21:27:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$html = $this->load_html($this->uri);
|
|
|
|
$this->get_latest_torrents($html);
|
|
|
|
}
|
|
|
|
|
|
|
|
#region Helper functions for "Search torrent by name"
|
|
|
|
|
|
|
|
private function request_search($name, $category = 'all'){
|
|
|
|
$category_name = $this->get_search_category_name($category);
|
|
|
|
$category_index = $this->get_search_category_index($category);
|
|
|
|
|
|
|
|
$this->name = 'Search: "' . $name . '" in category: ' . $category_name . ' - ' . $this->name;
|
|
|
|
$this->uri .= $this->build_category_uri($category_index);
|
|
|
|
|
|
|
|
if(strtolower(trim($category)) === 'movies'){ // This one is special (content wise)
|
|
|
|
$html = $this->load_html($this->uri);
|
|
|
|
$this->get_movie_torrents($html);
|
|
|
|
} else {
|
|
|
|
$this->uri .= '&ihq=' . urlencode($name);
|
|
|
|
$html = $this->load_html($this->uri);
|
|
|
|
$this->get_latest_torrents($html);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private function get_search_category_name($category){
|
2016-08-22 01:25:56 +02:00
|
|
|
$parameter = $this->parameters['Search torrent by name'];
|
|
|
|
$languages = $parameter['search_category']['values'];
|
|
|
|
|
|
|
|
foreach($languages as $name=>$value)
|
|
|
|
if(strtolower(trim($value)) === strtolower(trim($category)))
|
|
|
|
return $name;
|
2016-08-14 21:27:07 +02:00
|
|
|
|
|
|
|
return 'Unknown category';
|
|
|
|
}
|
|
|
|
|
|
|
|
private function get_search_category_index($category){
|
|
|
|
switch(strtolower(trim($category))){
|
|
|
|
case 'all': return 0;
|
|
|
|
default: return $this->get_torrent_category_index($category); // Uses the same index
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Helper functions for "Movie Torrents"
|
|
|
|
|
|
|
|
private function get_movie_torrents($html){
|
|
|
|
$container = $html->find('div#w0', 0);
|
|
|
|
if(!$container)
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnServerError('Unable to find torrent container!');
|
2016-08-14 21:27:07 +02:00
|
|
|
|
|
|
|
$torrents = $container->find('article');
|
|
|
|
if(!$torrents)
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnServerError('Unable to find torrents!');
|
2016-08-14 21:27:07 +02:00
|
|
|
|
|
|
|
foreach($torrents as $torrent){
|
|
|
|
|
|
|
|
$anchor = $torrent->find('a', 0);
|
|
|
|
if(!$anchor)
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnServerError('Unable to find anchor!');
|
2016-08-14 21:27:07 +02:00
|
|
|
|
|
|
|
$date = $torrent->find('small', 0);
|
|
|
|
if(!$date)
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnServerError('Unable to find date!');
|
2016-08-14 21:27:07 +02:00
|
|
|
|
2016-08-22 18:55:59 +02:00
|
|
|
$item = array();
|
2016-08-14 21:27:07 +02:00
|
|
|
|
2016-08-22 18:55:59 +02:00
|
|
|
$item['uri'] = $this->fix_relative_uri($anchor->href);
|
|
|
|
$item['title'] = $anchor->title;
|
|
|
|
// $item['author'] =
|
|
|
|
$item['timestamp'] = strtotime($date->plaintext);
|
|
|
|
$item['content'] = $this->fix_relative_uri($torrent->innertext);
|
2016-08-14 21:27:07 +02:00
|
|
|
|
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Helper functions for "Latest Hot Torrents"
|
|
|
|
|
|
|
|
private function get_latest_hot_torrents($html){
|
|
|
|
$container = $html->find('div#serps', 0);
|
|
|
|
if(!$container)
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnServerError('Unable to find torrent container!');
|
2016-08-14 21:27:07 +02:00
|
|
|
|
|
|
|
$torrents = $container->find('tr');
|
|
|
|
if(!$torrents)
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnServerError('Unable to find torrents!');
|
2016-08-14 21:27:07 +02:00
|
|
|
|
|
|
|
// Remove first element (header row)
|
|
|
|
$torrents = array_slice($torrents, 1);
|
|
|
|
|
|
|
|
foreach($torrents as $torrent){
|
|
|
|
|
|
|
|
$cell = $torrent->find('td', 0);
|
|
|
|
if(!$cell)
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnServerError('Unable to find cell!');
|
2016-08-14 21:27:07 +02:00
|
|
|
|
|
|
|
$element = $cell->find('a', 0);
|
|
|
|
if(!$element)
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnServerError('Unable to find element!');
|
2016-08-14 21:27:07 +02:00
|
|
|
|
2016-08-22 18:55:59 +02:00
|
|
|
$item = array();
|
2016-08-14 21:27:07 +02:00
|
|
|
|
2016-08-22 18:55:59 +02:00
|
|
|
$item['uri'] = $element->href;
|
|
|
|
$item['title'] = $element->plaintext;
|
|
|
|
// $item['author'] =
|
|
|
|
// $item['timestamp'] =
|
|
|
|
// $item['content'] =
|
2016-08-14 21:27:07 +02:00
|
|
|
|
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Helper functions for "Latest News"
|
|
|
|
|
|
|
|
private function get_latest_news($html){
|
|
|
|
$container = $html->find('div#postcontainer', 0);
|
|
|
|
if(!$container)
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnServerError('Unable to find post container!');
|
2016-08-14 21:27:07 +02:00
|
|
|
|
|
|
|
$posts = $container->find('div.index-post');
|
|
|
|
if(!$posts)
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnServerError('Unable to find posts!');
|
2016-08-14 21:27:07 +02:00
|
|
|
|
|
|
|
foreach($posts as $post){
|
2016-08-22 18:55:59 +02:00
|
|
|
$item = array();
|
2016-08-14 21:27:07 +02:00
|
|
|
|
2016-08-22 18:55:59 +02:00
|
|
|
$item['uri'] = $this->latest_news_extract_uri($post);
|
|
|
|
$item['title'] = $this->latest_news_extract_title($post);
|
|
|
|
$item['author'] = $this->latest_news_extract_author($post);
|
|
|
|
$item['timestamp'] = $this->latest_news_extract_timestamp($post);
|
|
|
|
$item['content'] = $this->latest_news_extract_content($post);
|
2016-08-14 21:27:07 +02:00
|
|
|
|
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private function latest_news_extract_author($post){
|
|
|
|
$author = $post->find('small', 0);
|
|
|
|
if(!$author)
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnServerError('Unable to find author!');
|
2016-08-14 21:27:07 +02:00
|
|
|
|
|
|
|
// The author is hidden within a string like: 'Posted by {author} on {date}'
|
|
|
|
preg_match('/Posted\sby\s(.*)\son/i', $author->innertext, $matches);
|
|
|
|
|
|
|
|
return $matches[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
private function latest_news_extract_timestamp($post){
|
|
|
|
$date = $post->find('small', 0);
|
|
|
|
if(!$date)
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnServerError('Unable to find date!');
|
2016-08-14 21:27:07 +02:00
|
|
|
|
|
|
|
// The date is hidden within a string like: 'Posted by {author} on {date}'
|
|
|
|
preg_match('/Posted\sby\s.*\son\s(.*)/i', $date->innertext, $matches);
|
|
|
|
|
|
|
|
$timestamp = strtotime($matches[1]);
|
|
|
|
|
|
|
|
// Make sure date is not in the future (dates are given like 'Nov. 20' without year)
|
|
|
|
if($timestamp > time()){
|
|
|
|
$timestamp = strtotime('-1 year', $timestamp);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $timestamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function latest_news_extract_title($post){
|
|
|
|
$title = $post->find('a', 0);
|
|
|
|
if(!$title)
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnServerError('Unable to find title!');
|
2016-08-14 21:27:07 +02:00
|
|
|
|
|
|
|
return $title->plaintext;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function latest_news_extract_uri($post){
|
|
|
|
$uri = $post->find('a', 0);
|
|
|
|
if(!$uri)
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnServerError('Unable to find uri!');
|
2016-08-14 21:27:07 +02:00
|
|
|
|
|
|
|
return $uri->href;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function latest_news_extract_content($post){
|
|
|
|
$content = $post->find('div', 0);
|
|
|
|
if(!$content)
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnServerError('Unable to find content!');
|
2016-08-22 01:25:56 +02:00
|
|
|
|
2016-08-14 21:27:07 +02:00
|
|
|
// Remove <h2>...</h2> (title)
|
|
|
|
foreach($content->find('h2') as $element){
|
|
|
|
$element->outertext = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove <small>...</small> (author)
|
|
|
|
foreach($content->find('small') as $element){
|
|
|
|
$element->outertext = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $content->innertext;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Helper functions for "Latest Torrents", "Latest Releases" and "Torrent Category"
|
|
|
|
|
|
|
|
private function get_latest_torrents($html){
|
|
|
|
$container = $html->find('div#serps', 0);
|
|
|
|
if(!$container)
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnServerError('Unable to find torrent container!');
|
2016-08-14 21:27:07 +02:00
|
|
|
|
|
|
|
$torrents = $container->find('tr[data-key]');
|
|
|
|
if(!$torrents)
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnServerError('Unable to find torrents!');
|
2016-08-14 21:27:07 +02:00
|
|
|
|
|
|
|
foreach($torrents as $torrent){
|
2016-08-22 18:55:59 +02:00
|
|
|
$item = array();
|
2016-08-14 21:27:07 +02:00
|
|
|
|
2016-08-22 18:55:59 +02:00
|
|
|
$item['uri'] = $this->latest_torrents_extract_uri($torrent);
|
|
|
|
$item['title'] = $this->latest_torrents_extract_title($torrent);
|
|
|
|
$item['author'] = $this->latest_torrents_extract_author($torrent);
|
|
|
|
$item['timestamp'] = $this->latest_torrents_extract_timestamp($torrent);
|
|
|
|
$item['content'] = ''; // There is no valuable content
|
2016-08-14 21:27:07 +02:00
|
|
|
|
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private function latest_torrents_extract_title($torrent){
|
|
|
|
$cell = $torrent->find('td.title-row', 0);
|
|
|
|
if(!$cell)
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnServerError('Unable to find title cell!');
|
2016-08-22 01:25:56 +02:00
|
|
|
|
2016-08-14 21:27:07 +02:00
|
|
|
$title = $cell->find('span', 0);
|
|
|
|
if(!$title)
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnServerError('Unable to find title!');
|
2016-08-14 21:27:07 +02:00
|
|
|
|
|
|
|
return $title->plaintext;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function latest_torrents_extract_uri($torrent){
|
|
|
|
$cell = $torrent->find('td.title-row', 0);
|
|
|
|
if(!$cell)
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnServerError('Unable to find title cell!');
|
2016-08-22 01:25:56 +02:00
|
|
|
|
2016-08-14 21:27:07 +02:00
|
|
|
$uri = $cell->find('a', 0);
|
|
|
|
if(!$uri)
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnServerError('Unable to find uri!');
|
2016-08-14 21:27:07 +02:00
|
|
|
|
|
|
|
return $this->fix_relative_uri($uri->href);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function latest_torrents_extract_author($torrent){
|
|
|
|
$cell = $torrent->find('td.user-row', 0);
|
|
|
|
if(!$cell)
|
|
|
|
return; // No author
|
2016-08-22 01:25:56 +02:00
|
|
|
|
2016-08-14 21:27:07 +02:00
|
|
|
$user = $cell->find('a', 0);
|
|
|
|
if(!$user)
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnServerError('Unable to find user!');
|
2016-08-14 21:27:07 +02:00
|
|
|
|
|
|
|
return $user->plaintext;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function latest_torrents_extract_timestamp($torrent){
|
|
|
|
$cell = $torrent->find('td.date-row', 0);
|
|
|
|
if(!$cell)
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnServerError('Unable to find date cell!');
|
2016-08-14 21:27:07 +02:00
|
|
|
|
|
|
|
return strtotime('-' . $cell->plaintext, time());
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Generic helper functions
|
|
|
|
|
|
|
|
private function load_html($uri){
|
2016-08-19 11:06:20 +02:00
|
|
|
$html = $this->getSimpleHTMLDOM($uri);
|
2016-08-14 21:27:07 +02:00
|
|
|
if(!$html)
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnServerError('Unable to load ' . $uri . '!');
|
2016-08-22 01:25:56 +02:00
|
|
|
|
2016-08-14 21:27:07 +02:00
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function fix_relative_uri($uri){
|
|
|
|
return preg_replace('/\//i', 'https://isohunt.to/', $uri, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function build_category_uri($index, $order_popularity = false){
|
|
|
|
return '/torrents/?iht=' . $index . '&ihs=' . ($order_popularity ? 1 : 0) . '&age=0';
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|