Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class NyaaEngine extends commonEngine
- {
- public $defaults = array( "public"=>true, "page_size"=>25 );
- public $categories = array( 'All categories'=>'0_0', 'Anime'=>'1_0', 'Anime - Anime Music Video'=>'1_32', 'Anime - English-translated Anime'=>'1_37', 'Anime - Non-English-translated Anime'=>'1_38', 'Anime - Raw Anime'=>'1_11',
- 'Audio'=>'3_0', 'Audio - Lossless Audio'=>'3_14', 'Audio - Lossy Audio'=>'3_15',
- 'Literature'=>'2_0', 'Literature - English-translated Literature'=>'2_12', 'Literature - Non-English-translated Literature'=>'2_39', 'Literature - Raw Literature'=>'2_13',
- 'Live Action'=>'5_0', 'Live Action - English-translated Live Action'=>'5_19', 'Live Action - Live Action Promotional Video'=>'5_22', 'Live Action - Non-English-translated Live Action'=>'5_21', 'Live Action - Raw Live Action'=>'5_20',
- 'Pictures'=>'4_0', 'Pictures - Graphics'=>'4_18', 'Pictures - Photos'=>'4_17',
- 'Software'=>'6_0', 'Software - Applications'=>'6_23', 'Software - Games'=>'6_24' );
- public function action($what,$cat,&$ret,$limit,$useGlobalCats)
- {
- $added = 0;
- $url = 'http://www.nyaa.se';
- if($useGlobalCats)
- $categories = array( 'all'=>'0_0', 'movies'=>'0_0', 'tv'=>'5_0', 'music'=>'3_0', 'games'=>'6_23', 'anime'=>'1_0', 'software'=>'6_0', 'pictures'=>'4_0', 'books'=>'2_0' );
- 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://www.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