Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class SukebeiNyaaEngine extends commonEngine
- {
- public $defaults = array( "public"=>true, "page_size"=>25 );
- 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',
- 'Real Life'=>'8_0', 'Real Life - Photobooks & Pictures'=>'8_31', 'Real Live - Videos'=>'8_30' );
- public function action($what,$cat,&$ret,$limit,$useGlobalCats)
- {
- $added = 0;
- $url = 'http://sukebei.nyaa.se';
- if($useGlobalCats)
- $categories = array( 'all'=>'', 'movies'=>'', 'tv'=>'', 'music'=>'', 'games'=>'', 'anime'=>'', 'software'=>'', 'pictures'=>'', 'books'=>'' );
- else
- $categories = &$this->categories;
- if(!array_key_exists($cat,$categories))
- $cat = $categories['All categories'];
- else
- $cat = $categories[$cat];
- for($pg = 1; $pg<11; $pg++)
- {
- $cli = $this->fetch( $url.'/?page=search&cats='.$cat.'&filter=0&sort=1&order=1&term='.$what.'&offset='.$pg );
- if( ($cli==false) || (strpos($cli->results, "<b>No torrents found.</b>")!==false) )
- break;
- $res = preg_match_all('`<td class="tlisticon"><a.*title="(?P<cat>.*)"><img.*</a></td>.*'.
- '<td class="tlistname"><a href="http://sukebei.nyaa.se/\?page=view&#38;tid=(?P<id>.*)">(?P<name>.*)</a></td>.*'.
- '<td class=".*">.*</td>'.
- '<td class="tlistsize">(?P<size>.*)</td>.*'.
- '(<td class="tlistsn">(?P<seeds>.*)</td><td class="tlistln">(?P<leech>.*)</td>.*|<td class="tlistfailed" colspan="2">Status unknown</td>)'.
- '<td class=".*">.*</td>.*'.
- '<td class=".*">.*</td>'.
- '`siU', $cli->results, $matches);
- if($res)
- {
- for($i=0; $i<$res; $i++)
- {
- $link = $url."/?page=download&tid=".$matches["id"][$i];
- if(!array_key_exists($link,$ret))
- {
- $item = $this->getNewEntry();
- $item["desc"] = $url."/?page=view&tid=".$matches["id"][$i];
- $item["name"] = self::removeTags($matches["name"][$i]);
- $item["cat"] = self::removeTags($matches["cat"][$i]);
- $item["size"] = self::formatSize($matches["size"][$i]);
- $item["seeds"] = intval(self::removeTags($matches["seeds"][$i]));
- $item["peers"] = intval(self::removeTags($matches["leech"][$i]));
- $ret[$link] = $item;
- $added++;
- if($added>=$limit)
- return;
- }
- }
- }
- else
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement