rarbg parser

This commit is contained in:
2016-08-30 19:26:48 +02:00
parent 5ef595df2a
commit 9918a0eb4d

146
standalone/rarbg.php Normal file
View File

@@ -0,0 +1,146 @@
<?php
class Settings
{
const DEBUG = true;
const TEXT_ENC = 'UTF-8';
}
require_once '../class_management.php';
require_once '../inc/rss.php';
function getCurl($sUrl, $bHeader=false, $asPostData=array())
{
$oCurl = curl_init();
curl_setopt($oCurl, CURLOPT_URL, $sUrl);
curl_setopt($oCurl, CURLOPT_HEADER, $bHeader);
if(!empty($asPostData))
{
curl_setopt($oCurl, CURLOPT_POST, count($asPostData));
curl_setopt($oCurl, CURLOPT_POSTFIELDS, $asPostData);
}
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, true);
//Fake browser
curl_setopt($oCurl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
//if($this->sReferer!='') curl_setopt($oCurl, CURLOPT_REFERER, $this->sReferer);
curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, false);
//if($bHeader) curl_setopt($oCurl, CURLOPT_FOLLOWLOCATION, true);
//Cookies
//$sCookies = $this->getCookies();
//if($sCookies!='') curl_setopt($oCurl, CURLOPT_COOKIE, $sCookies);
//curl_setopt($oCurl, CURLOPT_COOKIEJAR, $this->fCookieJar);
//curl_setopt($oCurl, CURLOPT_COOKIEFILE, $this->fCookieJar);
$sContent = curl_exec($oCurl);
curl_close($oCurl);
//$this->sReferer = $sUrl;
return $sContent;
}
function parseTop10()
{
$asDesc = array
(
'title'=>'Rarbg RSS Feed',
'link'=>'',
'copyright'=>'Powered by Franzz. RSS Feed Generator under GPLv3 License',
'description'=>'Rarbg RSS Feed',
'language'=>'en',
'webmaster_mail'=>'franzz@gmail.com'
);
$oFeed = new Feed($asDesc);
$sDomain = 'https://rarbg.to';
$oDom = new DOMDocument();
$sContent = getCurl($sDomain.'/torrents.php?category=14;17;42;44;45;46;47;48&search=&order=seeders&by=DESC');
//$sContent = file_get_contents('test.html');
@$oDom->loadHTML($sContent);
$oBody = $oDom->getElementsByTagName('body')->item(0);
$aoLines = $oDom->getElementsByTagName('tr');
foreach($aoLines as $oLine)
{
if($oLine->getAttribute('class')=='lista2')
{
$asArticle = array();
$aoCols = $oLine->getElementsByTagName('td');
foreach($aoCols as $iIndex=>$oCol)
{
switch($iIndex)
{
case 1:
$aoLinks = $oCol->getElementsByTagName('a');
foreach($aoLinks as $oLink)
{
$sHref = $oLink->getAttribute('href');
switch(substr($sHref, 0, 9))
{
//Title & link
case '/torrent/':
$iCount = '|'.$sHref;
$asArticle['title'] = $oLink->nodeValue;
$sLinkPath = str_replace('#comments', '', $sHref);
$asArticle['link'] = $sDomain.$sLinkPath;
$asArticle['guid'] = substr($sLinkPath, -7);
$sHover = $oLink->getAttribute('onmouseover');//return overlib('<img src=\'//dyncdn.me/static/over/1c74b4cde890fc95be77ac253297c45e50a05f98.jpg\' border=0>')
preg_match('/'.preg_quote('src=\\\'').'(?P<url>.+)'.preg_quote('\\\' border').'/', $sHover, $asMatch);
$sImg = 'https:'.$asMatch['url'];
break;
//Author
case '/torrents': // /torrents.php?imdb=tt3647498
$sMovieSearchLink = $sHref;
break;
}
}
$aoSpans = $oLine->getElementsByTagName('span');
foreach($aoSpans as $oSpan)
{
if($oSpan->getAttribute('style')=='color:DarkSlateGray')
{
$sMovieType = $oSpan->nodeValue;
$sImdb = strstr($sMovieType, 'IMDB');
$asArticle['category'] = trim(strstr($sMovieType, 'IMDB', true));
}
}
break;
case 2:
$asArticle['pub_date'] = $oCol->nodeValue;
break;
case 3:
$sSize = $oCol->nodeValue;
break;
case 4:
$iSeeder = $oCol->nodeValue;
break;
case 5:
$iLeecher = $oCol->nodeValue;
break;
case 7:
$asArticle['author'] = $oCol->nodeValue;
break;
}
}
$asArticle['description'] = '<img src="'.$sImg.'" />'.
'<br />'.$sMovieType.
'<br />'.$sImdb.
'<br />Size: '.$sSize.
'<br />S/L: <span style="color:green;">'.$iSeeder.'</span>/<span style="color:orange;">'.$iLeecher.'</span>'.
'<br /><a href="'.$sDomain.$sMovieSearchLink.'" target="_blank">Movie search</a>';
//die(print_r($asArticle, true));
$oFeed->addItem($asArticle);
}
}
return $oFeed->getFeed();
}
echo parseTop10();
?>