/
LimeTorrents.php
61 lines (48 loc) · 1.35 KB
/
LimeTorrents.php
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
namespace pxgamer\TorrentParser;
use Illuminate\Support\Collection;
use pxgamer\TorrentParser\Traits\Parser;
/**
* Class LimeTorrents
*/
class LimeTorrents
{
use Parser;
const BASE_URL = 'https://limetorrents.info';
/**
* Get the latest torrents
*
* @return Collection
*/
public static function latest()
{
$data = self::get(self::BASE_URL . '/rss/');
return self::createCollection($data);
}
/**
* Create a new Collection of Torrent instances
*
* @param array $responseData
* @return Collection
*/
private static function createCollection($responseData)
{
$collection = new Collection();
foreach ($responseData as $element) {
$torrent = new Torrent();
$torrent->title = $element['title'] ?? null;
$torrent->link = $element['link'] ?? null;
$torrent->category = $element['category'] ?? null;
$torrent->size = $element['size'] ?? null;
$torrent->date = $element['pubDate'] ?? null;
if ($torrent->size) {
$torrent->size = (int)$torrent->size;
}
if ($torrent->date) {
$torrent->date = new \DateTime($torrent->date);
}
$collection[] = $torrent;
}
return $collection;
}
}