-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnyaa.class.php
More file actions
38 lines (33 loc) · 1.09 KB
/
nyaa.class.php
File metadata and controls
38 lines (33 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
/**
* Class api Nyaa
*/
class NYAA
{
const NYAA_URL = 'https://nyaa.si/';
private $path = '?page=rss&c=0_0&f=0&q=%s';
public function getListSearch($search)
{
sprintf($this->path, urlencode($search));
$content = preg_replace("/nyaa:/", "nyaa", file_get_contents(self::NYAA_URL.sprintf($this->path, urlencode($search))));
$a = new SimpleXMLElement($content);
$tab = [];
foreach($a->channel->item as $key => $entry) {
$datePub = date("Y-m-d H:i:s",strtotime($entry->pubDate->__toString()));
$idTorrent = preg_replace("/https:\/\/nyaa.si\/view\//", "", $entry->guid->__toString());;
$tab[] = array(
'title' => $entry->title->__toString(),
'download' => $entry->link->__toString(),
'page' => $entry->guid->__toString(),
'datetime' => $datePub,
'size' => $entry->nyaasize->__toString(),
'hash' => $idTorrent,
'seeds' => $entry->nyaaseeders->__toString(),
'leechs' => $entry->nyaaleechers->__toString(),
'category' => $entry->nyaacategory->__toString()
);
}
return $tab;
}
}
?>