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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
<?php
/* This is a mashup of FlickrExploreBridge by sebsauvage and FlickrTagBridge
* by erwang.providing the functionality of both in one.
*/
class YGGTorrentBridge extends BridgeAbstract
{
const MAINTAINER = 'teromene';
const NAME = 'Yggtorrent Bridge';
const URI = 'https://www3.yggtorrent.qa';
const DESCRIPTION = 'Returns torrent search from Yggtorrent';
const PARAMETERS = [
[
'cat' => [
'name' => 'category',
'type' => 'list',
'values' => [
'Toutes les catégories' => 'all.all',
'Film/Vidéo - Toutes les sous-catégories' => '2145.all',
'Film/Vidéo - Animation' => '2145.2178',
'Film/Vidéo - Animation Série' => '2145.2179',
'Film/Vidéo - Concert' => '2145.2180',
'Film/Vidéo - Documentaire' => '2145.2181',
'Film/Vidéo - Émission TV' => '2145.2182',
'Film/Vidéo - Film' => '2145.2183',
'Film/Vidéo - Série TV' => '2145.2184',
'Film/Vidéo - Spectacle' => '2145.2185',
'Film/Vidéo - Sport' => '2145.2186',
'Film/Vidéo - Vidéo-clips' => '2145.2186',
'Audio - Toutes les sous-catégories' => '2139.all',
'Audio - Karaoké' => '2139.2147',
'Audio - Musique' => '2139.2148',
'Audio - Podcast Radio' => '2139.2150',
'Audio - Samples' => '2139.2149',
'Jeu vidéo - Toutes les sous-catégories' => '2142.all',
'Jeu vidéo - Autre' => '2142.2167',
'Jeu vidéo - Linux' => '2142.2159',
'Jeu vidéo - MacOS' => '2142.2160',
'Jeu vidéo - Microsoft' => '2142.2162',
'Jeu vidéo - Nintendo' => '2142.2163',
'Jeu vidéo - Smartphone' => '2142.2165',
'Jeu vidéo - Sony' => '2142.2164',
'Jeu vidéo - Tablette' => '2142.2166',
'Jeu vidéo - Windows' => '2142.2161',
'eBook - Toutes les sous-catégories' => '2140.all',
'eBook - Audio' => '2140.2151',
'eBook - Bds' => '2140.2152',
'eBook - Comics' => '2140.2153',
'eBook - Livres' => '2140.2154',
'eBook - Mangas' => '2140.2155',
'eBook - Presse' => '2140.2156',
'Emulation - Toutes les sous-catégories' => '2141.all',
'Emulation - Emulateurs' => '2141.2157',
'Emulation - Roms' => '2141.2158',
'GPS - Toutes les sous-catégories' => '2141.all',
'GPS - Applications' => '2141.2168',
'GPS - Cartes' => '2141.2169',
'GPS - Divers' => '2141.2170'
]
],
'nom' => [
'name' => 'Nom',
'description' => 'Nom du torrent',
'type' => 'text',
'exampleValue' => 'matrix'
],
'description' => [
'name' => 'Description',
'description' => 'Description du torrent',
'type' => 'text'
],
'fichier' => [
'name' => 'Fichier',
'description' => 'Fichier du torrent',
'type' => 'text'
],
'uploader' => [
'name' => 'Uploader',
'description' => 'Uploader du torrent',
'type' => 'text'
],
]
];
public function collectData()
{
$catInfo = explode('.', $this->getInput('cat'));
$category = $catInfo[0];
$subcategory = $catInfo[1];
$html = getSimpleHTMLDOM(self::URI . '/engine/search?name='
. $this->getInput('nom')
. '&description='
. $this->getInput('description')
. '&file='
. $this->getInput('fichier')
. '&uploader='
. $this->getInput('uploader')
. '&category='
. $category
. '&sub_category='
. $subcategory
. '&do=search&order=desc&sort=publish_date');
$count = 0;
$results = $html->find('.results', 0);
if (!$results) {
return;
}
foreach ($results->find('tr') as $row) {
$count++;
if ($count == 1) {
continue; // Skip table header
}
if ($count == 22) {
break; // Stop processing after 21 items (20 + 1 table header)
}
$item = [];
$item['timestamp'] = $row->find('.hidden', 1)->plaintext;
$item['title'] = $row->find('a#torrent_name', 0)->plaintext;
$item['uri'] = $this->processLink($row->find('a#torrent_name', 0)->href);
$item['seeders'] = $row->find('td', 7)->plaintext;
$item['leechers'] = $row->find('td', 8)->plaintext;
$item['size'] = $row->find('td', 5)->plaintext;
$item = array_merge($item, $this->collectTorrentData($item['uri']));
$this->items[] = $item;
}
}
/**
* Convert special characters like é to %C3%A9 in the url
*/
private function processLink($url)
{
$url = explode('/', $url);
foreach ($url as $index => $value) {
// Skip https://{self::URI}/
if ($index < 3) {
continue;
}
// Decode first so that characters like + are not encoded
$url[$index] = urlencode(urldecode($value));
}
return implode('/', $url);
}
private function collectTorrentData($url)
{
$page = defaultLinkTo(getSimpleHTMLDOMCached($url), self::URI);
$author = $page->find('.informations tr', 5)->find('td', 1)->plaintext;
$content = $page->find('.default', 1);
return ['author' => $author, 'content' => $content];
}
}
|