1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Blacklight\processing\adult; |
4
|
|
|
|
5
|
|
|
use voku\helper\SimpleHtmlDomNodeBlank; |
6
|
|
|
|
7
|
|
|
class ADM extends AdultMovies |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* Override if 18 years+ or older |
11
|
|
|
* Define Adult DVD Marketplace url |
12
|
|
|
* Needed Search Queries Constant. |
13
|
|
|
*/ |
14
|
|
|
private const ADMURL = 'http://www.adultdvdmarketplace.com'; |
15
|
|
|
private const TRAILINGSEARCH = '/xcart/adult_dvd/advanced_search.php?sort_by=relev&title='; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Define a cookie file location for curl. |
19
|
|
|
* @var string string |
20
|
|
|
*/ |
21
|
|
|
public $cookie = ''; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Direct Link given from outside url doesn't do a search. |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
protected $directLink = ''; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Set this for what you are searching for. |
31
|
|
|
* @var string |
32
|
|
|
*/ |
33
|
|
|
protected $searchTerm = ''; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Sets the directurl for the return results array. |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
protected $_directUrl = ''; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Results returned from each method. |
43
|
|
|
* |
44
|
|
|
* @var array |
45
|
|
|
*/ |
46
|
|
|
protected $_res = []; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Curl Raw Html. |
50
|
|
|
*/ |
51
|
|
|
protected $_response; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Add this to popurl to get results. |
55
|
|
|
* @var string |
56
|
|
|
*/ |
57
|
|
|
protected $_trailUrl = ''; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* This is set in the getAll method. |
61
|
|
|
* |
62
|
|
|
* @var string |
63
|
|
|
*/ |
64
|
|
|
protected $_title = ''; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Get Box Cover Images. |
68
|
|
|
* @return array - boxcover,backcover |
69
|
|
|
*/ |
70
|
|
|
protected function covers() |
71
|
|
|
{ |
72
|
|
|
$baseUrl = 'http://www.adultdvdmarketplace.com/'; |
73
|
|
|
if ($ret = $this->_html->find('a[rel=fancybox-button]', 0)) { |
74
|
|
|
if (isset($ret->href) && preg_match('/images\/.*[\d]+\.jpg$/i', $ret->href, $matches)) { |
|
|
|
|
75
|
|
|
$this->_res['boxcover'] = $baseUrl.$matches[0]; |
76
|
|
|
$this->_res['backcover'] = $baseUrl.str_ireplace('/front/i', 'back', $matches[0]); |
77
|
|
|
} |
78
|
|
|
} elseif ($ret = $this->_html->find('img[rel=license]', 0)) { |
79
|
|
|
if (preg_match('/images\/.*[\d]+\.jpg$/i', $ret->src, $matches)) { |
80
|
|
|
$this->_res['boxcover'] = $baseUrl.$matches[0]; |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
return $this->_res; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Gets the synopsis. |
89
|
|
|
* |
90
|
|
|
* @return array |
91
|
|
|
*/ |
92
|
|
|
protected function synopsis() |
93
|
|
|
{ |
94
|
|
|
$this->_res['synopsis'] = 'N/A'; |
95
|
|
|
foreach ($this->_html->find('h3') as $heading) { |
96
|
|
|
if (trim($heading->plaintext) === 'Description') { |
97
|
|
|
$this->_res['synopsis'] = trim($heading->next_sibling()->plaintext); |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
return $this->_res; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Get Product Information and Director. |
106
|
|
|
* |
107
|
|
|
* |
108
|
|
|
* @param bool $extras |
109
|
|
|
* |
110
|
|
|
* @return array |
111
|
|
|
*/ |
112
|
|
|
protected function productInfo($extras = false) |
113
|
|
|
{ |
114
|
|
|
foreach ($this->_html->find('ul.list-unstyled li') as $li) { |
115
|
|
|
$category = explode(':', $li->plaintext); |
116
|
|
|
switch (trim($category[0])) { |
117
|
|
|
case 'Director': |
118
|
|
|
$this->_res['director'] = trim($category[1]); |
119
|
|
|
break; |
120
|
|
|
case 'Format': |
121
|
|
|
case 'Studio': |
122
|
|
|
case 'Released': |
123
|
|
|
case 'SKU': |
124
|
|
|
$this->_res['productinfo'][trim($category[0])] = trim($category[1]); |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
return $this->_res; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* Gets the cast members. |
133
|
|
|
* @return array |
134
|
|
|
*/ |
135
|
|
|
protected function cast() |
136
|
|
|
{ |
137
|
|
|
$cast = []; |
138
|
|
|
foreach ($this->_html->find('h3') as $heading) { |
139
|
|
|
if (trim($heading->plaintext) === 'Cast') { |
140
|
|
|
foreach ($heading->nextSibling() as $next) { |
141
|
|
|
if (! $next instanceof SimpleHtmlDomNodeBlank && $next->nodeName !== 'h3') { |
142
|
|
|
$next = $next->nextSibling(); |
143
|
|
|
} |
144
|
|
|
if (preg_match_all('/search_performerid/', $next->href, $matches)) { |
145
|
|
|
$cast[] = trim($next->plaintext); |
146
|
|
|
} |
147
|
|
|
} |
148
|
|
|
} |
149
|
|
|
} |
150
|
|
|
$this->_res['cast'] = array_unique($cast); |
151
|
|
|
|
152
|
|
|
return $this->_res; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* Gets categories. |
157
|
|
|
* @return array |
158
|
|
|
*/ |
159
|
|
|
protected function genres() |
160
|
|
|
{ |
161
|
|
|
$genres = []; |
162
|
|
|
foreach ($this->_html->find('ul.list-unstyled') as $li) { |
163
|
|
|
$category = explode(':', $li->plaintext); |
164
|
|
|
if (trim($category[0]) === 'Category') { |
165
|
|
|
foreach (explode(',', $category[1]) as $genre) { |
166
|
|
|
$genres[] = trim($genre); |
167
|
|
|
} |
168
|
|
|
$this->_res['genres'] = $genres; |
169
|
|
|
} |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
return $this->_res; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
/** |
176
|
|
|
* Searches for match against searchterm. |
177
|
|
|
* |
178
|
|
|
* @param $movie |
179
|
|
|
* |
180
|
|
|
* @return bool - true if search = 100% |
181
|
|
|
*/ |
182
|
|
|
public function processSite($movie) |
183
|
|
|
{ |
184
|
|
|
$result = false; |
185
|
|
|
if (! empty($movie)) { |
186
|
|
|
$this->_trailUrl = self::TRAILINGSEARCH.urlencode($movie); |
187
|
|
|
$this->_response = getRawHtml(self::ADMURL.$this->_trailUrl, $this->cookie); |
188
|
|
|
if ($this->_response !== false) { |
189
|
|
|
$check = $this->_html->loadHtml($this->_response)->find('img[rel=license]'); |
190
|
|
|
if (\count($check) > 0) { |
191
|
|
|
foreach ($check as $ret) { |
192
|
|
|
if (isset($ret->alt)) { |
193
|
|
|
$title = trim($ret->alt, '"'); |
194
|
|
|
$title = str_replace('/XXX/', '', $title); |
195
|
|
|
$comparetitle = preg_replace('/[\W]/', '', $title); |
196
|
|
|
$comparesearch = preg_replace('/[\W]/', '', $movie); |
197
|
|
|
similar_text($comparetitle, $comparesearch, $p); |
198
|
|
|
if ($p >= 90 && preg_match('/\/(?<sku>\d+)\.jpg$/i', $ret->src, $matches)) { |
199
|
|
|
$this->_title = trim($title); |
200
|
|
|
$this->_trailUrl = '/dvd_view_'.$matches['sku'].'.html'; |
201
|
|
|
$this->_directUrl = self::ADMURL.$this->_trailUrl; |
202
|
|
|
unset($this->_response); |
203
|
|
|
$this->_response = getRawHtml($this->_directUrl, $this->cookie); |
204
|
|
|
$this->_html->loadHtml($this->_response); |
|
|
|
|
205
|
|
|
$result = true; |
206
|
|
|
} |
207
|
|
|
} |
208
|
|
|
} |
209
|
|
|
} |
210
|
|
|
} |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
return $result; |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
protected function trailers() |
217
|
|
|
{ |
218
|
|
|
// TODO: Implement trailers() method. |
219
|
|
|
|
220
|
|
|
return false; |
221
|
|
|
} |
222
|
|
|
} |
223
|
|
|
|