1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Blacklight\processing\adult; |
4
|
|
|
|
5
|
|
|
class Popporn extends AdultMovies |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* Define a cookie file location for curl. |
9
|
|
|
* |
10
|
|
|
* @var string string |
11
|
|
|
*/ |
12
|
|
|
public $cookie = ''; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Set this for what you are searching for. |
16
|
|
|
* |
17
|
|
|
* @var string |
18
|
|
|
*/ |
19
|
|
|
protected $searchTerm = ''; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Override if 18 years+ or older |
23
|
|
|
* Define PopPorn url |
24
|
|
|
* Needed Search Queries Constant. |
25
|
|
|
*/ |
26
|
|
|
private const IF18 = 'https://www.popporn.com/popporn/4'; |
27
|
|
|
private const POPURL = 'https://www.popporn.com'; |
28
|
|
|
private const TRAILINGSEARCH = '/search&q='; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Sets the directurl for the return results array. |
32
|
|
|
* |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
protected $_directUrl = ''; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Curl Raw Html. |
39
|
|
|
*/ |
40
|
|
|
protected $_response; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Results returned from each method. |
44
|
|
|
* |
45
|
|
|
* @var array |
46
|
|
|
*/ |
47
|
|
|
protected $_res = []; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* This is set in the getAll method. |
51
|
|
|
* |
52
|
|
|
* @var string |
53
|
|
|
*/ |
54
|
|
|
protected $_title = ''; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Add this to popurl to get results. |
58
|
|
|
* |
59
|
|
|
* @var string |
60
|
|
|
*/ |
61
|
|
|
protected $_trailUrl = ''; |
62
|
|
|
|
63
|
|
|
private $_postParams; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Get Box Cover Images. |
67
|
|
|
* |
68
|
|
|
* @return array - boxcover,backcover |
69
|
|
|
*/ |
70
|
|
|
protected function covers(): array |
71
|
|
|
{ |
72
|
|
|
if ($ret = $this->_html->find('div[id=box-art], a[rel=box-art]', 1)) { |
73
|
|
|
$this->_res['boxcover'] = trim($ret->href); |
|
|
|
|
74
|
|
|
if (false !== stripos(trim($ret->href), '_aa')) { |
75
|
|
|
$this->_res['backcover'] = str_ireplace('_aa', '_bb', trim($ret->href)); |
76
|
|
|
} else { |
77
|
|
|
$this->_res['backcover'] = str_ireplace('.jpg', '_b.jpg', trim($ret->href)); |
78
|
|
|
} |
79
|
|
|
} else { |
80
|
|
|
if ($ret = $this->_html->findOne('img.front')) { |
81
|
|
|
$this->_res['boxcover'] = $ret->src; |
82
|
|
|
} |
83
|
|
|
if ($ret = $this->_html->findOne('img.back')) { |
84
|
|
|
$this->_res['backcover'] = $ret->src; |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
return $this->_res; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @return array|mixed |
93
|
|
|
*/ |
94
|
|
|
protected function synopsis() |
95
|
|
|
{ |
96
|
|
|
if ($ret = $this->_html->find('div[id=product-info] ,h3[class=highlight]', 1)) { |
97
|
|
|
if ($ret->next_sibling()->plaintext) { |
|
|
|
|
98
|
|
|
if (stripos(trim($ret->next_sibling()->plaintext), 'POPPORN EXCLUSIVE') === false) { |
99
|
|
|
$this->_res['synopsis'] = trim($ret->next_sibling()->plaintext); |
100
|
|
|
} else { |
101
|
|
|
if ($ret->next_sibling()->next_sibling()) { |
102
|
|
|
$this->_res['synopsis'] = trim($ret->next_sibling()->next_sibling()->next_sibling()->plaintext); |
103
|
|
|
} else { |
104
|
|
|
$this->_res['synopsis'] = 'N/A'; |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
return $this->_res; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @return array|mixed |
115
|
|
|
*/ |
116
|
|
|
protected function trailers() |
117
|
|
|
{ |
118
|
|
|
if ($ret = $this->_html->findOne('input#thickbox-trailer-link')) { |
119
|
|
|
$ret->value = trim($ret->value); |
|
|
|
|
120
|
|
|
$ret->value = str_replace('..', '', $ret->value); |
121
|
|
|
$tmprsp = $this->_response; |
122
|
|
|
$this->_trailUrl = $ret->value; |
123
|
|
|
if (preg_match_all('/productID="\+(?<id>\d+),/', $this->_response, $matches)) { |
124
|
|
|
$productid = $matches['id'][0]; |
125
|
|
|
$random = ((float) mt_rand() / (float) mt_getrandmax()) * 5400000000000000; |
126
|
|
|
$this->_trailUrl = '/com/tlavideo/vod/FlvAjaxSupportService.cfc?random='.$random; |
127
|
|
|
$this->_postParams = 'method=pipeStreamLoc&productID='.$productid; |
128
|
|
|
$ret = json_decode(json_decode($this->_response, true), true); |
129
|
|
|
$this->_res['trailers']['baseurl'] = self::POPURL.'/flashmediaserver/trailerPlayer.swf'; |
130
|
|
|
$this->_res['trailers']['flashvars'] = 'subscribe=false&image=&file='.self::POPURL.'/'.$ret['LOC'].'&autostart=false'; |
131
|
|
|
unset($this->_response); |
132
|
|
|
$this->_response = $tmprsp; |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
return $this->_res; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @param bool $extras |
141
|
|
|
* |
142
|
|
|
* @return array|mixed |
143
|
|
|
*/ |
144
|
|
|
protected function productInfo($extras = false) |
145
|
|
|
{ |
146
|
|
|
$country = false; |
147
|
|
|
if ($ret = $this->_html->findOne('div#lside')) { |
148
|
|
|
foreach ($ret->find('text') as $e) { |
149
|
|
|
$e = trim($e->innertext); |
150
|
|
|
$e = str_replace([', ', '...', ' '], '', $e); |
151
|
|
|
if (stripos($e, 'Country:') !== false) { |
152
|
|
|
$country = true; |
153
|
|
|
} |
154
|
|
|
if ($country === true) { |
155
|
|
|
if (stripos($e, 'addthis_config') === false) { |
156
|
|
|
if (! empty($e)) { |
157
|
|
|
$this->_res['productinfo'][] = $e; |
158
|
|
|
} |
159
|
|
|
} else { |
160
|
|
|
break; |
161
|
|
|
} |
162
|
|
|
} |
163
|
|
|
} |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
$this->_res['productinfo'] = array_chunk($this->_res['productinfo'], 2, false); |
167
|
|
|
|
168
|
|
|
if ($extras === true) { |
169
|
|
|
$features = false; |
170
|
|
|
if ($this->_html->findOne('ul.stock-information')) { |
171
|
|
|
foreach ($this->_html->find('ul.stock-information') as $ul) { |
172
|
|
|
foreach ($ul->find('li') as $e) { |
173
|
|
|
$e = trim($e->plaintext); |
174
|
|
|
if ($e === 'Features:') { |
175
|
|
|
$features = true; |
176
|
|
|
$e = null; |
177
|
|
|
} |
178
|
|
|
if ($features === true) { |
179
|
|
|
if (! empty($e)) { |
180
|
|
|
$this->_res['extras'][] = $e; |
181
|
|
|
} |
182
|
|
|
} |
183
|
|
|
} |
184
|
|
|
} |
185
|
|
|
} |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
return $this->_res; |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* @return array|mixed |
193
|
|
|
*/ |
194
|
|
|
protected function cast() |
195
|
|
|
{ |
196
|
|
|
$cast = false; |
197
|
|
|
$director = false; |
198
|
|
|
$er = []; |
199
|
|
|
if ($ret = $this->_html->findOne('div#lside')) { |
200
|
|
|
foreach ($ret->find('text') as $e) { |
201
|
|
|
$e = trim($e->innertext); |
202
|
|
|
$e = str_replace([',', ' '], '', $e); |
203
|
|
|
if (stripos($e, 'Cast') !== false) { |
204
|
|
|
$cast = true; |
205
|
|
|
} |
206
|
|
|
$e = str_replace('Cast:', '', $e); |
207
|
|
|
if ($cast === true) { |
208
|
|
|
if (stripos($e, 'Director:') !== false) { |
209
|
|
|
$director = true; |
210
|
|
|
$e = null; |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
if ($director === true) { |
214
|
|
|
if (! empty($e)) { |
215
|
|
|
$this->_res['director'] = $e; |
216
|
|
|
$director = false; |
217
|
|
|
$e = null; |
218
|
|
|
} |
219
|
|
|
} |
220
|
|
|
if (stripos($e, 'Country:') === false) { |
221
|
|
|
if (! empty($e)) { |
222
|
|
|
$er[] = $e; |
223
|
|
|
} |
224
|
|
|
} else { |
225
|
|
|
break; |
226
|
|
|
} |
227
|
|
|
} |
228
|
|
|
} |
229
|
|
|
} |
230
|
|
|
$this->_res['cast'] = $er; |
231
|
|
|
|
232
|
|
|
return $this->_res; |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* Gets categories. |
237
|
|
|
* |
238
|
|
|
* @return array |
239
|
|
|
*/ |
240
|
|
|
protected function genres() |
241
|
|
|
{ |
242
|
|
|
$genres = []; |
243
|
|
|
if ($ret = $this->_html->find('div[id=thekeywords], p[class=keywords]', 1)) { |
244
|
|
|
foreach ($ret->find('a') as $e) { |
245
|
|
|
$genres[] = trim($e->plaintext); |
246
|
|
|
} |
247
|
|
|
} |
248
|
|
|
$this->_res['genres'] = $genres; |
249
|
|
|
|
250
|
|
|
return $this->_res; |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
/** |
254
|
|
|
* Searches for match against searchterm. |
255
|
|
|
* |
256
|
|
|
* @param string $movie |
257
|
|
|
* |
258
|
|
|
* @return bool , true if search >= 90% |
259
|
|
|
*/ |
260
|
|
|
public function processSite($movie): bool |
261
|
|
|
{ |
262
|
|
|
if (! empty($movie)) { |
263
|
|
|
$this->_trailUrl = self::TRAILINGSEARCH.$movie; |
264
|
|
|
$this->_response = getRawHtml(self::POPURL.$this->_trailUrl, $this->cookie); |
265
|
|
|
if ($this->_response !== false) { |
266
|
|
|
if ($ret = $this->_html->loadHtml($this->_response)->find('div.product-info, div.title', 1)) { |
267
|
|
|
$this->_title = trim($ret->plaintext); |
268
|
|
|
$title = str_replace('XXX', '', $ret->plaintext); |
269
|
|
|
$title = trim(preg_replace('/\(.*?\)|[._-]/i', ' ', $title)); |
270
|
|
|
similar_text(strtolower($movie), strtolower($title), $p); |
271
|
|
|
if ($p >= 90) { |
272
|
|
|
if ($ret = $ret->findOne('a')) { |
|
|
|
|
273
|
|
|
$this->_trailUrl = trim($ret->href); |
|
|
|
|
274
|
|
|
unset($this->_response); |
275
|
|
|
$this->_response = getRawHtml(self::POPURL.$this->_trailUrl, $this->cookie); |
276
|
|
|
if ($this->_response !== false) { |
277
|
|
|
$this->_html->loadHtml($this->_response); |
278
|
|
|
if ($ret = $this->_html->findOne('#link-to-this')) { |
279
|
|
|
$this->_directUrl = trim($ret->href); |
280
|
|
|
unset($this->_response); |
281
|
|
|
$this->_response = getRawHtml($this->_directUrl, $this->cookie); |
282
|
|
|
$this->_html->loadHtml($this->_response); |
|
|
|
|
283
|
|
|
|
284
|
|
|
return true; |
285
|
|
|
} |
286
|
|
|
|
287
|
|
|
return false; |
288
|
|
|
} |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
return true; |
292
|
|
|
} |
293
|
|
|
} |
294
|
|
|
} else { |
295
|
|
|
$this->_response = getRawHtml(self::IF18, $this->cookie); |
296
|
|
|
if ($this->_response !== false) { |
297
|
|
|
$this->_html->loadHtml($this->_response); |
298
|
|
|
|
299
|
|
|
return true; |
300
|
|
|
} |
301
|
|
|
|
302
|
|
|
return false; |
303
|
|
|
} |
304
|
|
|
|
305
|
|
|
return false; |
306
|
|
|
} |
307
|
|
|
|
308
|
|
|
return false; |
309
|
|
|
} |
310
|
|
|
} |
311
|
|
|
|