Advertisement
jurassicplayer

Sukebei Nyaa extsearch Engine

Jul 20th, 2014
1,594
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.35 KB | None | 0 0
  1. <?php
  2.  
  3. class SukebeiNyaaEngine extends commonEngine
  4. {
  5.     public $defaults = array( "public"=>true, "page_size"=>25 );
  6.     public $categories = array( 'All categories'=>'0_0', 'Art'=>'7_0', 'Art - Anime'=>'7_25', 'Art - Doujinshi'=>'7_33', 'Art - Games'=>'7_27', 'Art - Manga'=>'7_26', 'Art - Pictures'=>'7_28',
  7.         'Real Life'=>'8_0', 'Real Life - Photobooks & Pictures'=>'8_31', 'Real Live - Videos'=>'8_30' );
  8.  
  9.     public function action($what,$cat,&$ret,$limit,$useGlobalCats)
  10.     {
  11.         $added = 0;
  12.         $url = 'http://sukebei.nyaa.se';
  13.         if($useGlobalCats)
  14.             $categories = array( 'all'=>'', 'movies'=>'', 'tv'=>'', 'music'=>'', 'games'=>'', 'anime'=>'', 'software'=>'', 'pictures'=>'', 'books'=>'' );
  15.         else
  16.             $categories = &$this->categories;
  17.         if(!array_key_exists($cat,$categories))
  18.             $cat = $categories['All categories'];
  19.         else
  20.             $cat = $categories[$cat];
  21.  
  22.         for($pg = 1; $pg<11; $pg++)
  23.         {
  24.             $cli = $this->fetch( $url.'/?page=search&cats='.$cat.'&filter=0&sort=1&order=1&term='.$what.'&offset='.$pg );
  25.             if( ($cli==false) || (strpos($cli->results, "<b>No torrents found.</b>")!==false) )
  26.                 break;
  27.             $res = preg_match_all('`<td class="tlisticon"><a.*title="(?P<cat>.*)"><img.*</a></td>.*'.
  28.                 '<td class="tlistname"><a href="http://sukebei.nyaa.se/\?page=view&#38;#38;tid=(?P<id>.*)">(?P<name>.*)</a></td>.*'.
  29.                 '<td class=".*">.*</td>'.
  30.                 '<td class="tlistsize">(?P<size>.*)</td>.*'.
  31.                 '(<td class="tlistsn">(?P<seeds>.*)</td><td class="tlistln">(?P<leech>.*)</td>.*|<td class="tlistfailed" colspan="2">Status unknown</td>)'.
  32.                 '<td class=".*">.*</td>.*'.
  33.                 '<td class=".*">.*</td>'.
  34.                 '`siU', $cli->results, $matches);
  35.             if($res)
  36.             {
  37.                 for($i=0; $i<$res; $i++)
  38.                 {
  39.                     $link = $url."/?page=download&tid=".$matches["id"][$i];
  40.                     if(!array_key_exists($link,$ret))
  41.                     {
  42.                         $item = $this->getNewEntry();
  43.                         $item["desc"] = $url."/?page=view&tid=".$matches["id"][$i];
  44.                         $item["name"] = self::removeTags($matches["name"][$i]);
  45.                         $item["cat"] = self::removeTags($matches["cat"][$i]);
  46.                         $item["size"] = self::formatSize($matches["size"][$i]);
  47.                         $item["seeds"] = intval(self::removeTags($matches["seeds"][$i]));
  48.                         $item["peers"] = intval(self::removeTags($matches["leech"][$i]));
  49.                         $ret[$link] = $item;
  50.                         $added++;
  51.                         if($added>=$limit)
  52.                             return;
  53.                     }
  54.                 }
  55.             }
  56.             else
  57.                 break;
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement