@@ -92,12 +92,9 @@ public function search($query, $category="all") {
9292 }
9393 }
9494 }
95- return $ response ;
96- } else
97- {
98- // no results found
99- return $ response ;
10095 }
96+ // Return resonse
97+ return $ response ;
10198 }
10299
103100
@@ -108,7 +105,7 @@ public function search($query, $category="all") {
108105 *
109106 * @return array
110107 */
111- public function film ($ query ) {
108+ public function film ($ query, $ techSpecs = false ) {
112109 // Define response array
113110 $ response = [
114111 "title " => "" ,
@@ -117,7 +114,8 @@ public function film($query) {
117114 "rating " => "" ,
118115 "poster " => "" ,
119116 "plot " => "" ,
120- "cast " => []
117+ "cast " => [],
118+ "technical_specs " => []
121119 ];
122120 // Set filmId to querry
123121 $ filmId = $ query ;
@@ -157,6 +155,7 @@ public function film($query) {
157155 $ response ["poster " ] = $ film_page ->find ('.poster img ' )->src ;
158156 $ response ["plot " ] = $ this ->textClean ($ film_page ->find ('.plot_summary .summary_text ' )->text );
159157
158+
160159 // Get all cast list
161160 $ cast_list_all = $ film_page ->find ('table.cast_list tr ' );
162161 if (count ($ cast_list_all ) > 0 ) {
@@ -207,6 +206,35 @@ public function film($query) {
207206 }
208207 }
209208
209+ // Fetch technical specs
210+ if ($ techSpecs )
211+ {
212+ // Load technical specs page
213+ $ film_techSpecs_url = $ film_url . "technical " ;
214+ $ film_techSpecs = $ this ->loadDom ($ film_techSpecs_url );
215+
216+ // Search dom for techspecs table
217+ $ techSpecs_table = $ film_techSpecs ->find ('.dataTable tr ' );
218+ // If table exists
219+ if (count ($ techSpecs_table ) > 0 )
220+ {
221+ // Loop each row within table
222+ foreach ($ techSpecs_table as $ techSpecs_row )
223+ {
224+ // Get row title
225+ $ row_title = $ this ->textClean ($ techSpecs_row ->find ('td ' )[0 ]->text );
226+ // Get row value
227+ $ row_value = str_replace (" " , " <br> " , $ this ->textClean ($ techSpecs_row ->find ('td ' )[1 ]->text ));
228+
229+ // Create response var
230+ $ row = [$ row_title , $ row_value ];
231+
232+ // Add row to technical specs
233+ array_push ($ response ["technical_specs " ], $ row );
234+ }
235+ }
236+ }
237+
210238 return $ response ;
211239 }
212240
@@ -241,7 +269,7 @@ private function extractImdbId($str) {
241269 // '/yyxxxxxxx'
242270 preg_match ('/\/[A-Za-z]{2}[0-9]+/ ' , $ str , $ imdbIds );
243271 $ id = substr ($ imdbIds [0 ], 1 );
244- if ($ id == null || $ id == undefined || count ( $ id ) == 0 )
272+ if ($ id == NULL )
245273 {
246274 throw new Exception ("No id found " );
247275 }
0 commit comments