mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-04 18:14:44 +02:00
[core] extract BridgeAbstract methods to make them functions
- returnError, returnServerError, returnClientError ,debugMessage are moved to lib/error.php - getContents, getSimpleHTMLDOM, getSimpleHTMLDOMCached are moved to lib/contents.php Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
parent
ad534444fa
commit
f1fb95b257
111 changed files with 485 additions and 477 deletions
|
@ -208,21 +208,21 @@ class IsoHuntBridge extends BridgeAbstract{
|
|||
private function get_movie_torrents($html){
|
||||
$container = $html->find('div#w0', 0);
|
||||
if(!$container)
|
||||
$this->returnServerError('Unable to find torrent container!');
|
||||
returnServerError('Unable to find torrent container!');
|
||||
|
||||
$torrents = $container->find('article');
|
||||
if(!$torrents)
|
||||
$this->returnServerError('Unable to find torrents!');
|
||||
returnServerError('Unable to find torrents!');
|
||||
|
||||
foreach($torrents as $torrent){
|
||||
|
||||
$anchor = $torrent->find('a', 0);
|
||||
if(!$anchor)
|
||||
$this->returnServerError('Unable to find anchor!');
|
||||
returnServerError('Unable to find anchor!');
|
||||
|
||||
$date = $torrent->find('small', 0);
|
||||
if(!$date)
|
||||
$this->returnServerError('Unable to find date!');
|
||||
returnServerError('Unable to find date!');
|
||||
|
||||
$item = array();
|
||||
|
||||
|
@ -243,11 +243,11 @@ class IsoHuntBridge extends BridgeAbstract{
|
|||
private function get_latest_hot_torrents($html){
|
||||
$container = $html->find('div#serps', 0);
|
||||
if(!$container)
|
||||
$this->returnServerError('Unable to find torrent container!');
|
||||
returnServerError('Unable to find torrent container!');
|
||||
|
||||
$torrents = $container->find('tr');
|
||||
if(!$torrents)
|
||||
$this->returnServerError('Unable to find torrents!');
|
||||
returnServerError('Unable to find torrents!');
|
||||
|
||||
// Remove first element (header row)
|
||||
$torrents = array_slice($torrents, 1);
|
||||
|
@ -256,11 +256,11 @@ class IsoHuntBridge extends BridgeAbstract{
|
|||
|
||||
$cell = $torrent->find('td', 0);
|
||||
if(!$cell)
|
||||
$this->returnServerError('Unable to find cell!');
|
||||
returnServerError('Unable to find cell!');
|
||||
|
||||
$element = $cell->find('a', 0);
|
||||
if(!$element)
|
||||
$this->returnServerError('Unable to find element!');
|
||||
returnServerError('Unable to find element!');
|
||||
|
||||
$item = array();
|
||||
|
||||
|
@ -281,11 +281,11 @@ class IsoHuntBridge extends BridgeAbstract{
|
|||
private function get_latest_news($html){
|
||||
$container = $html->find('div#postcontainer', 0);
|
||||
if(!$container)
|
||||
$this->returnServerError('Unable to find post container!');
|
||||
returnServerError('Unable to find post container!');
|
||||
|
||||
$posts = $container->find('div.index-post');
|
||||
if(!$posts)
|
||||
$this->returnServerError('Unable to find posts!');
|
||||
returnServerError('Unable to find posts!');
|
||||
|
||||
foreach($posts as $post){
|
||||
$item = array();
|
||||
|
@ -303,7 +303,7 @@ class IsoHuntBridge extends BridgeAbstract{
|
|||
private function latest_news_extract_author($post){
|
||||
$author = $post->find('small', 0);
|
||||
if(!$author)
|
||||
$this->returnServerError('Unable to find author!');
|
||||
returnServerError('Unable to find author!');
|
||||
|
||||
// The author is hidden within a string like: 'Posted by {author} on {date}'
|
||||
preg_match('/Posted\sby\s(.*)\son/i', $author->innertext, $matches);
|
||||
|
@ -314,7 +314,7 @@ class IsoHuntBridge extends BridgeAbstract{
|
|||
private function latest_news_extract_timestamp($post){
|
||||
$date = $post->find('small', 0);
|
||||
if(!$date)
|
||||
$this->returnServerError('Unable to find date!');
|
||||
returnServerError('Unable to find date!');
|
||||
|
||||
// The date is hidden within a string like: 'Posted by {author} on {date}'
|
||||
preg_match('/Posted\sby\s.*\son\s(.*)/i', $date->innertext, $matches);
|
||||
|
@ -332,7 +332,7 @@ class IsoHuntBridge extends BridgeAbstract{
|
|||
private function latest_news_extract_title($post){
|
||||
$title = $post->find('a', 0);
|
||||
if(!$title)
|
||||
$this->returnServerError('Unable to find title!');
|
||||
returnServerError('Unable to find title!');
|
||||
|
||||
return $title->plaintext;
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ class IsoHuntBridge extends BridgeAbstract{
|
|||
private function latest_news_extract_uri($post){
|
||||
$uri = $post->find('a', 0);
|
||||
if(!$uri)
|
||||
$this->returnServerError('Unable to find uri!');
|
||||
returnServerError('Unable to find uri!');
|
||||
|
||||
return $uri->href;
|
||||
}
|
||||
|
@ -348,7 +348,7 @@ class IsoHuntBridge extends BridgeAbstract{
|
|||
private function latest_news_extract_content($post){
|
||||
$content = $post->find('div', 0);
|
||||
if(!$content)
|
||||
$this->returnServerError('Unable to find content!');
|
||||
returnServerError('Unable to find content!');
|
||||
|
||||
// Remove <h2>...</h2> (title)
|
||||
foreach($content->find('h2') as $element){
|
||||
|
@ -370,11 +370,11 @@ class IsoHuntBridge extends BridgeAbstract{
|
|||
private function get_latest_torrents($html){
|
||||
$container = $html->find('div#serps', 0);
|
||||
if(!$container)
|
||||
$this->returnServerError('Unable to find torrent container!');
|
||||
returnServerError('Unable to find torrent container!');
|
||||
|
||||
$torrents = $container->find('tr[data-key]');
|
||||
if(!$torrents)
|
||||
$this->returnServerError('Unable to find torrents!');
|
||||
returnServerError('Unable to find torrents!');
|
||||
|
||||
foreach($torrents as $torrent){
|
||||
$item = array();
|
||||
|
@ -392,11 +392,11 @@ class IsoHuntBridge extends BridgeAbstract{
|
|||
private function latest_torrents_extract_title($torrent){
|
||||
$cell = $torrent->find('td.title-row', 0);
|
||||
if(!$cell)
|
||||
$this->returnServerError('Unable to find title cell!');
|
||||
returnServerError('Unable to find title cell!');
|
||||
|
||||
$title = $cell->find('span', 0);
|
||||
if(!$title)
|
||||
$this->returnServerError('Unable to find title!');
|
||||
returnServerError('Unable to find title!');
|
||||
|
||||
return $title->plaintext;
|
||||
}
|
||||
|
@ -404,11 +404,11 @@ class IsoHuntBridge extends BridgeAbstract{
|
|||
private function latest_torrents_extract_uri($torrent){
|
||||
$cell = $torrent->find('td.title-row', 0);
|
||||
if(!$cell)
|
||||
$this->returnServerError('Unable to find title cell!');
|
||||
returnServerError('Unable to find title cell!');
|
||||
|
||||
$uri = $cell->find('a', 0);
|
||||
if(!$uri)
|
||||
$this->returnServerError('Unable to find uri!');
|
||||
returnServerError('Unable to find uri!');
|
||||
|
||||
return $this->fix_relative_uri($uri->href);
|
||||
}
|
||||
|
@ -420,7 +420,7 @@ class IsoHuntBridge extends BridgeAbstract{
|
|||
|
||||
$user = $cell->find('a', 0);
|
||||
if(!$user)
|
||||
$this->returnServerError('Unable to find user!');
|
||||
returnServerError('Unable to find user!');
|
||||
|
||||
return $user->plaintext;
|
||||
}
|
||||
|
@ -428,7 +428,7 @@ class IsoHuntBridge extends BridgeAbstract{
|
|||
private function latest_torrents_extract_timestamp($torrent){
|
||||
$cell = $torrent->find('td.date-row', 0);
|
||||
if(!$cell)
|
||||
$this->returnServerError('Unable to find date cell!');
|
||||
returnServerError('Unable to find date cell!');
|
||||
|
||||
return strtotime('-' . $cell->plaintext, time());
|
||||
}
|
||||
|
@ -438,9 +438,9 @@ class IsoHuntBridge extends BridgeAbstract{
|
|||
#region Generic helper functions
|
||||
|
||||
private function load_html($uri){
|
||||
$html = $this->getSimpleHTMLDOM($uri);
|
||||
$html = getSimpleHTMLDOM($uri);
|
||||
if(!$html)
|
||||
$this->returnServerError('Unable to load ' . $uri . '!');
|
||||
returnServerError('Unable to load ' . $uri . '!');
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue