-
Notifications
You must be signed in to change notification settings - Fork 2
/
pilot.class.php
1150 lines (1068 loc) · 47.8 KB
/
pilot.class.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
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
#############################################################################
# IMDBPHP.MoviePilot (c) Itzchak Rehberg #
# written by Itzchak Rehberg <izzysoft AT qumran DOT org> #
# http://www.izzysoft.de/ #
# ------------------------------------------------------------------------- #
# This program is free software; you can redistribute and/or modify it #
# under the terms of the GNU General Public License (see doc/LICENSE) #
#############################################################################
/* $Id: pilot.class.php 481 2011-10-12 10:45:48Z izzy $ */
require_once(dirname(__FILE__)."/movie_base.class.php");
if (PILOT_IMDBFALLBACK) require_once(dirname(__FILE__)."/imdb.class.php");
#=============================================================================
#================================================[ The Pilot class itself ]===
#=============================================================================
/** Accessing MoviePilot information
* @package MoviePilot
* @class pilot
* @extends movie_base
* @author Izzy (izzysoft AT qumran DOT org)
* @copyright (c) 2009 by Itzchak Rehberg and IzzySoft
* @version $Revision: 481 $ $Date: 2011-10-12 12:45:48 +0200 (Mi, 12. Okt 2011) $
*/
class pilot extends movie_base {
#======================================================[ Common functions ]===
#-----------------------------------------------------------[ Constructor ]---
/** Initialize class
* @constructor pilot
* @param string id IMDBID to use for data retrieval
*/
function __construct($id) {
parent::__construct($id);
if ( empty($this->pilot_apikey) )
trigger_error('Please provide a valid api key or contact api@moviepilot.de.',E_USER_WARNING);
$this->revision = preg_replace('|^.*?(\d+).*$|','$1','$Revision: 481 $');
if (PILOT_IMDBFALLBACK) $this->imdb = new imdb($id);
$this->setid($id);
}
/** Setup class for a new IMDB id
* @method setid
* @param string id IMDBID of the requested movie
*/
function setid($id) {
parent::setid($id);
if (PILOT_IMDBFALLBACK) $this->imdb->setid($id);
}
#-------------------------------------------------------------[ Open Page ]---
/** Load an Pilot page into the corresponding property (variable)
* @method private openpage
* @param string wt internal name of the page
* @param optional string type whether its a "movie" (default) or a "person"
*/
function openpage ($wt,$type="pilot") {
parent::openpage($wt,$type);
if ($this->page[$wt] == "cannot open page") return;
if ($this->page[$wt] == '{"error":"please provide a valid api key or contact api@moviepilot.de"}') {
$this->debug_scalar('ERROR: invalid API key');
trigger_error('Please provide a valid api key or contact api@moviepilot.de.',E_USER_WARNING);
return;
}
$this->page[$wt] = json_decode($this->page[$wt]);
}
#------------------------------------------[ Check for valid page content ]---
/** Check if we have valid page content
* @method private invalidPage
* @param string wt internal name of the page
* @return boolean invalid
*/
function invalidPage($wt) {
if ($this->page[$wt] == "cannot open page") return TRUE;
if ($this->page[$wt] == '{"error":"please provide a valid api key or contact api@moviepilot.de"}') return TRUE;
return FALSE;
}
#-----------------------------------------------[ URL to person main page ]---
/** Set up the URL to the movie title page
* @method main_url
* @return string url full URL to the current movies main page
*/
public function main_url(){
return "http://".$this->pilotsite."/movies/imdb-id-".(int)$this->imdbid();
}
#----------------------------------------------------------[ Set Pagename ]---
/** Define page urls
* @method protected set_pagename
* @param string wt internal name of the page
* @return string urlname page URL
*/
protected function set_pagename($wt) {
switch ($wt){
case "Title" : $urlname="/movies/imdb-id-".(int)$this->imdbid().".json"; break;
case "Credits" : $urlname="/movies/imdb-id-".(int)$this->imdbid()."/casts.json"; break;
case "Trailers" : $urlname="/movies/imdb-id-".(int)$this->imdbid()."/trailer.json"; break;
case "Images" : $urlname="/movies/imdb-id-".(int)$this->imdbid()."/images.json"; break;
default :
$this->page[$wt] = "unknown page identifier";
$this->debug_scalar("Unknown page identifier: $wt");
return false;
}
return $urlname;
}
#======================================================[ Title page infos ]===
#-------------------------------------------[ Movie title (name) and year ]---
/** Get movie title
* @method title
* @return string title movie title (name)
* @see MoviePilot page / (TitlePage)
*/
public function title() {
if ($this->main_title == "") {
if ($this->page["Title"] == "") $this->openpage ("Title");
$this->main_title = $this->page["Title"]->{'display_title'};
}
return $this->main_title;
}
/** Get year
* @method year
* @return string year
* @see MoviePilot page / (TitlePage)
*/
public function year () {
if ($this->main_year == -1) {
if ($this->page["Title"] == "") $this->openpage ("Title");
$this->main_year = $this->page["Title"]->{'production_year'};
}
return $this->main_year;
}
/** Get range of years for e.g. series spanning multiple years
* This is just here for compatibility with the IMDB class - so for now start==end
* @method yearspan
* @return array yearspan [start,end] (if there was no range, start==end)
* @see MoviePilot page / (TitlePage)
*/
function yearspan() {
if ( empty($this->main_yearspan) ) {
$this->main_yearspan = array('start'=>$this->year(),'end'=>$this->year());
}
return $this->main_yearspan;
}
/** Get movie types (if any specified)
* @method movieTypes
* @return array [0..n] of strings (or empty array if no movie types specified)
* @see MoviePilot page / (TitlePage)
* @brief No data available at MoviePilot. If <code>pilot_imdbfill</code> is
* set at least to BASIC_ACCESS, it will be retrieved from IMDB.
*/
public function movieTypes() {
if ($this->pilot_imdbfill) $this->main_movietypes = $this->imdb->movieTypes();
return $this->main_movietypes;
}
/** Get movie type
* @method movietype
* @return string movietype (TV series, Movie, ...)
* @see IMDB page / (TitlePage)
* @brief No data available at MoviePilot. If <code>pilot_imdbfill</code> is
* set at least to BASIC_ACCESS, it will be retrieved from IMDB.
*/
public function movietype() {
if ($this->pilot_imdbfill) $this->main_movietype = $this->imdb->movieType();
return $this->main_movietype;
}
#---------------------------------------------------------------[ Runtime ]---
/** Get overall runtime (first one mentioned on title page)
* @method runtime
* @return mixed string runtime in minutes (if set), NULL otherwise
* @see MoviePilot page / (TitlePage)
*/
public function runtime() {
if (empty($this->movieruntimes)) {
if ($this->page["Title"] == "") $this->openpage ("Title");
$this->main_runtime = $this->page["Title"]->{'runtime'};
}
if ($this->main_runtime) return $this->main_runtime;
else return NULL;
}
/** Retrieve language specific runtimes
* @method runtimes
* @return array runtimes (array[0..n] of array[time,country,comment])
* @see MoviePilot page / (TitlePage)
* @version this is a fake
*/
public function runtimes(){
if (empty($this->movieruntimes)) {
$country = $this->country();
$runtime = $this->runtime();
if ( empty($country[0]) || empty($runtime) ) return array();
$this->movieruntimes[] = array("time"=>$runtime,"country"=>$country[0],"comment"=>"");
}
return $this->movieruntimes;
}
#----------------------------------------------------------[ Aspect Ratio ]---
/** Aspect Ratio of movie screen
* @method aspect_ratio
* @return string ratio
* @see IMDB page / (TitlePage)
* @brief If <code>pilot_imdbfill</code> is
* set at least to BASIC_ACCESS, it will be retrieved from IMDB.
* @todo Check if this is available from pilot directly
*/
public function aspect_ratio() {
if ($this->pilot_imdbfill) $this->aspectratio = $this->imdb->aspect_ratio();
return $this->aspectratio;
}
#----------------------------------------------------------[ Movie Rating ]---
/** Get movie rating
* @method rating
* @return string rating current rating as given by MoviePilot site
* @see MoviePilot page / (TitlePage)
*/
public function rating () {
if ($this->main_rating == -1) {
if ($this->page["Title"] == "") $this->openpage ("Title");
$this->main_rating = $this->page["Title"]->{'average_community_rating'};
}
return $this->main_rating;
}
/** Return votes for this movie
* @method votes
* @return string votes count of votes for this movie
* @see MoviePilot page / (TitlePage)
* @version no data provided, so we fake some
*/
public function votes () {
return 1;
//return $this->main_votes;
}
#------------------------------------------------------[ Movie Comment(s) ]---
/** Get movie main comment (from title page)
* @method comment
* @return string comment full text of movie comment from the movies main page
* @see MoviePilot page / (TitlePage)
*/
public function comment() {
if ($this->main_comment == "") {
if ($this->page["Title"] == "") $this->openpage ("Title");
$this->main_comment = html_entity_decode($this->page["Title"]->{'long_description'});
}
return $this->main_comment;
}
/** Get movie main comment (from title page - split-up variant)
* @method comment_split
* @return array comment array[string title, string date, array author, string comment]; author: array[string url, string name]
* @see MoviePilot page / (TitlePage)
* @version not yet available
*/
public function comment_split() {
//$this->split_comment = array("title"=>$match[1],"date"=>$match[2],"author"=>array("url"=>$match[3],"name"=>$match[4]),"comment"=>trim($match[5]));
return $this->split_comment;
}
#--------------------------------------------------------------[ Keywords ]---
/** Get the keywords for the movie
* @method keywords
* @return array keywords
* @see MoviePilot page / (TitlePage)
*/
public function keywords () {
if (empty($this->main_keywords)) {
if ($this->page["Title"] == "") $this->openpage ("Title");
$this->main_keywords = explode(",",$this->page["Title"]->{'plots_list'});
}
return $this->main_keywords;
}
/** Get the full keywords for the movie
* Just for compatibility with the IMDB class - result here is identical
* with pilot::keywords
* @method keywords_all
* @return array keywords
* @see MoviePilot page / (TitlePage)
*/
public function keywords_all() {
return $this->keywords();
}
#--------------------------------------------------------[ Language Stuff ]---
/** Get movies original language
* @method language
* @return string language
* @brief There is not really a main language on the IMDB sites (yet), so this
* simply returns the first one
* @see MoviePilot page / (TitlePage)
* @brief No data available at MoviePilot. AutoRetrieval from IMDB with
* <code>pilot_imdbfill</code> > BASIC_ACCESS
*/
public function language() {
if ($this->pilot_imdbfill > BASIC_ACCESS) $this->main_language = $this->imdb->language();
return $this->main_language;
}
/** Get all langauges this movie is available in
* @method languages
* @return array languages (array[0..n] of strings)
* @see MoviePilot page / (TitlePage)
* @brief No data available at MoviePilot. AutoRetrieval from IMDB with
* <code>pilot_imdbfill</code> > BASIC_ACCESS
*/
public function languages() {
if ($this->pilot_imdbfill > BASIC_ACCESS) $this->langs = $this->imdb->languages();
return $this->langs;
}
/** Get all languages this movie is available in, including details
* @method languages_detailed
* @return array languages (array[0..n] of array[string name, string code, string comment], code being the ISO-Code)
* @see IMDB page / (TitlePage)
* @brief No data available at MoviePilot. AutoRetrieval from IMDB with
* <code>pilot_imdbfill</code> > BASIC_ACCESS
*/
public function languages_detailed() {
if ($this->pilot_imdbfill > BASIC_ACCESS) $this->lang_fulls = $this->imdb->languages_detailed();
return $this->langs_full;
}
#--------------------------------------------------------------[ Genre(s) ]---
/** Get the movies main genre
* Since IMDB.COM does not really now a "Main Genre", this simply means the
* first mentioned genre will be returned.
* @method genre
* @return string genre first of the genres listed on the movies main page
* @brief There is not really a main genre on the IMDB sites (yet), so this
* simply returns the first one
* @see MoviePilot page / (TitlePage)
* @version does currently not match the IMDB genres (hopefully will in the future)
*/
public function genre () {
if (empty($this->main_genre)) {
if (empty($this->moviegenres)) $genres = $this->genres();
if (!empty($genres)) $this->main_genre = $this->moviegenres[0];
}
return $this->main_genre;
}
/** Get all genres the movie is registered for
* @method genres
* @return array genres (array[0..n] of strings)
* @see MoviePilot page / (TitlePage)
* @version does currently not match the IMDB genres (hopefully will in the future)
*/
public function genres () {
if (empty($this->moviegenres)) {
if ($this->page["Title"] == "") $this->openpage ("Title");
$this->moviegenres = explode(",",$this->page["Title"]->{'genres_list'});
}
return $this->moviegenres;
}
#----------------------------------------------------------[ Color format ]---
/** Get colors
* @method colors
* @return array colors (array[0..1] of strings)
* @see MoviePilot page / (TitlePage)
* @brief No data available at MoviePilot. AutoRetrieval from IMDB with
* <code>pilot_imdbfill</code> > BASIC_ACCESS
*/
public function colors() {
if ($this->pilot_imdbfill > BASIC_ACCESS) $this->moviecolors = $this->imdb->colors();
return $this->moviecolors;
}
#---------------------------------------------------------------[ Creator ]---
/** Get the creator of a movie (most likely for seasons only)
* @method creator
* @return array creator (array[0..n] of array[name,imdb])
* @see MoviePilot page / (TitlePage)
* @brief No data available at MoviePilot. AutoRetrieval from IMDB with
* <code>pilot_imdbfill</code> set to FULL_ACCESS
*/
public function creator() {
if ($this->pilot_imdbfill==FULL_ACCESS) $this->main_creator = $this->imdb->creator();
return $this->main_creator;
}
#---------------------------------------------------------------[ Tagline ]---
/** Get the main tagline for the movie
* @method tagline
* @return string tagline
* @see MoviePilot page / (TitlePage)
* @version no data available
* @brief No data available at MoviePilot. AutoRetrieval from IMDB with
* <code>pilot_imdbfill</code> set to FULL_ACCESS
*/
public function tagline() {
if ($this->pilot_imdbfill==FULL_ACCESS) $this->main_tagline = $this->imdb->tagline();
return $this->main_tagline;
}
#---------------------------------------------------------------[ Seasons ]---
/** Get the number of seasons or 0 if not a series
* @method seasons
* @return int seasons number of seasons
* @see MoviePilot page / (TitlePage)
* @brief No data available at MoviePilot. AutoRetrieval from IMDB with
* <code>pilot_imdbfill</code> set to FULL_ACCESS
*/
public function seasons() {
if ($this->pilot_imdbfill==FULL_ACCESS) $this->seasoncount = $this->imdb->seasons();
else return 0;
return $this->seasoncount;
}
#-----------------------------------------------[ Is it part of a serial? ]---
/** Try to figure out if this is a movie or part of a serie
* @method is_serial
* @return boolean
* @see IMDB page / (TitlePage)
*/
public function is_serial() {
if ( $this->pilot_imdbfill > NO_ACCESS ) return $this->imdb->is_serial();
}
#--------------------------------------------------------[ Plot (Outline) ]---
/** Get the main Plot outline for the movie
* @method plotoutline
* @return string plotoutline
* @see MoviePilot page / (TitlePage)
*/
public function plotoutline($fallback=FALSE) {
if ($this->main_plotoutline == "") {
if ($this->page["Title"] == "") $this->openpage ("Title");
$this->main_plotoutline = $this->page["Title"]->{'short_description'};
if ( empty($this->main_plotoutline) && $fallback ) $this->main_plotoutline = $this->storyline();
}
return $this->main_plotoutline;
}
/** Get the Storyline for the movie
* @method storyline
* @return string storyline
* @see IMDB page / (TitlePage)
*/
public function storyline () {
if ($this->pilot_imdbfill==FULL_ACCESS) return $this->imdb->storyline();
}
#--------------------------------------------------------[ Photo specific ]---
/** Setup cover photo (thumbnail and big variant)
* @method private thumbphoto
* @return boolean success (TRUE if found, FALSE otherwise)
* @see MoviePilot page / (TitlePage)
*/
private function thumbphoto() {
if ($this->page["Title"] == "") $this->openpage ("Title");
if ($this->page["Title"] == "cannot open page") return false; // no such page
if (empty($this->page["Title"]->poster)) return false; // no pics
$baseurl = $this->page["Title"]->poster->base_url.$this->page["Title"]->poster->photo_id."/"
. $this->page["Title"]->poster->file_name_base;
$this->main_photo = $baseurl.".".$this->page["Title"]->poster->extension;
$this->main_thumb = $baseurl."_poster".".".$this->page["Title"]->poster->extension;;
return true;
}
/** Get cover photo
* @method photo
* @param optional boolean thumb get the thumbnail (about 60x45px, default) or the
* original variant (FALSE).
* @return mixed photo (string url if found, FALSE otherwise)
* @see MoviePilot page / (TitlePage)
*/
public function photo($thumb=true) {
if (empty($this->main_photo)) $this->thumbphoto();
if (!$thumb && empty($this->main_photo)) return false;
if ($thumb && empty($this->main_thumb)) return false;
if ($thumb) return $this->main_thumb;
return $this->main_photo;
}
/** Save the photo to disk
* @method savephoto
* @param string path where to store the file
* @param optional boolean thumb get the thumbnail (about 60x45px, default) or the
* original variant (FALSE)
* @return boolean success
* @see MoviePilot page / (TitlePage)
*/
public function savephoto ($path,$thumb=true) {
$req = new MDB_Request("");
$photo_url = $this->photo ($thumb);
if (!$photo_url) return FALSE;
$req->setURL($photo_url);
$req->sendRequest();
if (strpos($req->getResponseHeader("Content-Type"),'image/jpeg') === 0
|| strpos($req->getResponseHeader("Content-Type"),'image/gif') === 0
|| strpos($req->getResponseHeader("Content-Type"), 'image/bmp') === 0 ){
$fp = $req->getResponseBody();
}else{
$this->debug_scalar("<BR>*photoerror* ".$photo_url.": Content Type is '".$req->getResponseHeader("Content-Type")."'<BR>");
return false;
}
$fp2 = fopen ($path, "w");
if ((!$fp) || (!$fp2)){
$this->debug_scalar("image error...<BR>");
return false;
}
fputs ($fp2, $fp);
return TRUE;
}
/** Get the URL for the movies cover photo
* @method photo_localurl
* @param optional boolean thumb get the thumbnail (about 60x45, default) or the
* original variant (FALSE)
* @return mixed url (string URL or FALSE if none)
* @see MoviePilot page / (TitlePage)
*/
public function photo_localurl($thumb=true){
if ($thumb) $ext = ""; else $ext = "_big";
if (!is_dir($this->photodir)) {
$this->debug_scalar("<BR>***ERROR*** The configured image directory does not exist!<BR>");
return false;
}
$path = $this->photodir.$this->imdbid()."${ext}.jpg";
if ( @fopen($path,"r")) return $this->photoroot.$this->imdbid()."${ext}.jpg";
if (!is_writable($this->photodir)) {
$this->debug_scalar("<BR>***ERROR*** The configured image directory lacks write permission!<BR>");
return false;
}
if ($this->savephoto($path,$thumb)) return $this->photoroot.$this->imdbid()."${ext}.jpg";
return false;
}
/** Get URLs for the pictures on the main page
* @method mainPictures
* @return array [0..n] of [imgsrc, imglink, bigsrc], where<UL>
* <LI>imgsrc is the URL of the thumbnail IMG as displayed on main page</LI>
* <LI>imglink is the link to the <b><i>page</i></b> with the "big image" (empty here - just for compatibility with the imdb class)</LI>
* <LI>bigsrc is the URL of the "big size" image itself</LI>
*/
public function mainPictures() {
if ( empty($this->main_pictures) ) {
if ( $this->page['Images'] == '' ) $this->openpage('Images');
$total_entries = count($this->page['Images']);
if ( $total_entries < 1 ) return array(); // no pics available
for ($i=0;$i<$total_entries;++$i) {
$baseurl = $this->page['Images'][$i]->base_url.$this->page['Images'][$i]->photo_id."/"
. $this->page['Images'][$i]->file_name_base;
$this->main_pictures[] = array('imgsrc'=>$baseurl."_poster.".$this->page['Images'][$i]->extension,'bigsrc'=>$baseurl.".".$this->page['Images'][$i]->extension,'imglink'=>'');
}
}
return $this->main_pictures;
}
#-------------------------------------------------[ Country of Production ]---
/** Get country of production
* @method country
* @return array country (array[0..n] of string)
* @see MoviePilot page / (TitlePage)
*/
public function country () {
if ($this->page["Title"] == "") $this->openpage ("Title");
$this->countries = explode(",",$this->page["Title"]->{'countries_list'});
return $this->countries;
}
#------------------------------------------------------------[ Movie AKAs ]---
/** Get movies alternative names
* @method alsoknow
* @return array aka array[0..n] of array[title,year,country,comment]; searching
* on akas.imdb.com will add "lang" (2-char language code) to the array
* for localized names, "comment" will hold additional countries listed
* along for these as well as comments: As these things are quite mixed
* up on the imdb sites, it's hard to tell what is an additional country
* and what is a comment...
* @see MoviePilot page / (TitlePage)
* @version no data available
* @brief No data available at MoviePilot. AutoRetrieval from IMDB with
* <code>pilot_imdbfill</code> > BASIC_ACCESS
*/
public function alsoknow() {
if ($this->pilot_imdbfill > BASIC_ACCESS) $this->akas = $this->imdb->alsoknow();
return $this->akas;
}
#---------------------------------------------------------[ Sound formats ]---
/** Get sound formats
* @method sound
* @return array sound (array[0..n] of strings)
* @see MoviePilot page / (TitlePage)
* @brief No data available at MoviePilot. AutoRetrieval from IMDB with
* <code>pilot_imdbfill</code> > BASIC_ACCESS
*/
public function sound() {
if ($this->pilot_imdbfill > BASIC_ACCESS) $this->sound = $this->imdb->sound();
return $this->sound;
}
#-------------------------------------------------------[ MPAA / PG / FSK ]---
/** Get the MPAA data (also known as PG or FSK)
* @method mpaa
* @return array mpaa (array[country]=rating)
* @see MoviePilot page / (TitlePage)
* @brief No data available at MoviePilot. AutoRetrieval from IMDB with
* <code>pilot_imdbfill</code> > NO_ACCESS
*/
public function mpaa() {
if ($this->pilot_imdbfill) $this->mpaas = $this->imdb->mpaa();
return $this->mpaas;
}
/** Get the MPAA data (also known as PG or FSK) - including historical data
* @method mpaa_hist
* @return array mpaa (array[country][0..n]=rating)
* @see MoviePilot page / (TitlePage)
* @brief No data available at MoviePilot. AutoRetrieval from IMDB with
* <code>pilot_imdbfill</code> set to FULL_ACCESS
*/
public function mpaa_hist() {
if ($this->pilot_imdbfill==FULL_ACCESS) $this->mpaas_hist = $this->imdb->mpaa_hist();
return $this->mpaas_hist;
}
#----------------------------------------------------[ MPAA justification ]---
/** Find out the reason for the MPAA rating
* @method mpaa_reason
* @return string reason why the movie was rated such
* @see MoviePilot page / (TitlePage)
* @brief No data available at MoviePilot. AutoRetrieval from IMDB with
* <code>pilot_imdbfill</code> set to FULL_ACCESS
*/
public function mpaa_reason() {
if ($this->pilot_imdbfill==FULL_ACCESS) $this->mpaa_justification = $this->imdb->mpaa_reason();
return $this->mpaa_justification;
}
#------------------------------------------------------[ Production Notes ]---
/** For not-yet completed movies, we can get the production state
* @method prodNotes
* @returns array production notes [status,statnote,lastupdate[day,month,mon,year],more,note]
* @see MoviePilot page / (TitlePage)
* @brief No data available at MoviePilot. AutoRetrieval from IMDB with
* <code>pilot_imdbfill</code> set to FULL_ACCESS
*/
public function prodNotes() {
if ($this->pilot_imdbfill==FULL_ACCESS) $this->main_prodnotes = $this->imdb->prodNotes();
return $this->main_prodnotes;
}
#----------------------------------------------[ Position in the "Top250" ]---
/** Find the position of a movie in the top 250 ranked movies
* @method top250
* @return int position a number between 1..250 if the movie is listed, 0 otherwise
* @brief No data available at MoviePilot. AutoRetrieval from IMDB with
* <code>pilot_imdbfill</code> set to FULL_ACCESS
*/
public function top250() {
if ($this->pilot_imdbfill==FULL_ACCESS) $this->main_top250 = $this->imdb->top250();
return $this->main_top250;
}
#--------------------------------------------------[ Full Plot (combined) ]---
/** Get the movies plot(s)
* @method plot
* @return array plot (array[0..n] of strings)
* @see MoviePilot page (Titlepage)
* @brief No data available at MoviePilot. If
* <code>pilot_imdbfill</code> is set to FULL_ACCESS, we
* will automatically retrieve this data from the IMDB site configured.
* Otherwise we fake some data using <code>pilot::plotoutline()</code>,
* resulting in a single record (if any) available there.
*/
public function plot() {
if (empty($this->plot_plot)) {
if ($this->pilot_imdbfill==FULL_ACCESS) $this->plot_plot = $this->imdb->plot();
else $this->plot_plot[0] = $this->plotoutline();
}
return $this->plot_plot;
}
#-----------------------------------------------------[ Full Plot (split) ]---
/** Get the movie plot(s) - split-up variant
* @method plot_split
* @return array array[0..n] of array[string plot,array author] - where author consists of string name and string url
* @see MoviePilot page (Titlepage)
* @brief No data available at MoviePilot. AutoRetrieval from IMDB with
* <code>pilot_imdbfill</code> set to FULL_ACCESS
*/
public function plot_split() {
if ($this->pilot_imdbfill==FULL_ACCESS) $this->split_plot = $this->imdb->plot_split();
return $this->split_plot;
}
#========================================================[ /synopsis page ]===
#---------------------------------------------------------[ Full Synopsis ]---
/** Get the movies synopsis
* @method synopsis
* @return string synopsis
* @see MoviePilot page /synopsis
* @brief No data available at MoviePilot. AutoRetrieval from IMDB with
* <code>pilot_imdbfill</code> set to FULL_ACCESS
*/
public function synopsis() {
if ($this->pilot_imdbfill==FULL_ACCESS) $this->synopsis_wiki = $this->imdb->synopsis();
return $this->synopsis_wiki;
}
#========================================================[ /taglines page ]===
#--------------------------------------------------------[ Taglines Array ]---
/** Get all available taglines for the movie
* @method taglines
* @return array taglines (array[0..n] of strings)
* @see MoviePilot page /taglines
* @brief No data available at MoviePilot. AutoRetrieval from IMDB with
* <code>pilot_imdbfill</code> set to FULL_ACCESS
*/
public function taglines() {
if ($this->pilot_imdbfill==FULL_ACCESS) $this->taglines = $this->imdb->taglines();
return $this->taglines;
}
#=====================================================[ /fullcredits page ]===
#---------------------------------------------[ Helper: Get the cast list ]---
/** Obtain all cast data
* @method private castlist
*/
private function castlist() {
if (empty($this->castlist)) {
if (empty($this->page["Credits"])) $this->openpage("Credits");
foreach(array("actor","soundtrack","director","screenplay","production") as $function) $this->castlist[$function] = array(); // fill the important ones
if ( $this->invalidPage("Credits") ) return $this->castlist; // no such page
//$this->page["Credits"]->{'total_entries'} equals count($this->page["Credits"]->{'movies_people'})
if (is_array($this->page["Credits"]->{'movies_people'})) foreach($this->page["Credits"]->{'movies_people'} as $person) {
$function = preg_replace('|.*/(.*?)$|','$1',$person->{'function_restful_url'});
$person->person->character = $person->character;
$this->castlist[$function][] = $person->person;
}
}
}
#------------------------------------------[ Check IMDB ID ]---
/** Create a valid IMDBID
* @method private mid
* @param string input value to check
* @return string imdbid either valid IMDBID (7 digit), or empty string
*/
private function mid($str) {
if ( empty($str) ) return $str;
return str_pad($str,7,'0',STR_PAD_LEFT);
}
#-------------------------------------------------------------[ Directors ]---
/** Get the director(s) of the movie
* @method director
* @return array director (array[0..n] of arrays[imdb,name,role])
* @see MoviePilot page /fullcredits
*/
public function director() {
if (empty($this->credits_director)) $this->castlist();
$this->credits_director = array();
foreach ($this->castlist["director"] as $person) {
$this->credits_director[] = array("imdb"=>$this->mid($person->alternative_identifiers->imdb),"name"=>$person->first_name." ".$person->last_name,"role"=>$person->character);
}
return $this->credits_director;
}
#----------------------------------------------------------------[ Actors ]---
/** Get the actors
* @method cast
* @return array cast (array[0..n] of arrays[imdb,name,role,thumb,photo])
* @see MoviePilot page /fullcredits
*/
public function cast() {
if (empty($this->credits_cast)) $this->castlist();
$this->credits_cast = array();
foreach ($this->castlist["actor"] as $person) {
$this->credits_cast[] = array("imdb"=>$this->mid($person->alternative_identifiers->imdb),"name"=>$person->first_name." ".$person->last_name,"role"=>$person->character);
}
return $this->credits_cast;
}
#---------------------------------------------------------------[ Writers ]---
/** Get the writer(s)
* @method writing
* @return array writers (array[0..n] of arrays[imdb,name,role])
* @see MoviePilot page /fullcredits
*/
public function writing() {
if (empty($this->credits_writing)) $this->castlist();
$this->credits_writing = array();
foreach ($this->castlist["screenplay"] as $person) {
$this->credits_writing[] = array("imdb"=>$this->mid($person->alternative_identifiers->imdb),"name"=>$person->first_name." ".$person->last_name,"role"=>$person->character);
}
return $this->credits_writing;
}
#-------------------------------------------------------------[ Producers ]---
/** Obtain the producer(s)
* @method producer
* @return array producer (array[0..n] of arrays[imdb,name,role])
* @see MoviePilot page /fullcredits
*/
public function producer() {
if (empty($this->credits_producer)) $this->castlist();
$this->credits_producer = array();
foreach ($this->castlist["production"] as $person) {
$this->credits_producer[] = array("imdb"=>$this->mid($person->alternative_identifiers->imdb),"name"=>$person->first_name." ".$person->last_name,"role"=>$person->character);
}
return $this->credits_producer;
}
#-------------------------------------------------------------[ Composers ]---
/** Obtain the composer(s) ("Original Music by...")
* @method composer
* @return array composer (array[0..n] of arrays[imdb,name,role])
* @see MoviePilot page /fullcredits
*/
public function composer() {
if (empty($this->credits_composer)) $this->castlist();
$this->credits_composer = array();
foreach ($this->castlist["soundtrack"] as $person) {
$this->credits_composer[] = array("imdb"=>$this->mid($person->alternative_identifiers->imdb),"name"=>$person->first_name." ".$person->last_name,"role"=>$person->character);
}
return $this->credits_composer;
}
#====================================================[ /crazycredits page ]===
#----------------------------------------------------[ CrazyCredits Array ]---
/** Get the Crazy Credits
* @method crazy_credits
* @return array crazy_credits (array[0..n] of string)
* @see MoviePilot page /crazycredits
* @brief No data available at MoviePilot. AutoRetrieval from IMDB with
* <code>pilot_imdbfill</code> set to FULL_ACCESS
*/
public function crazy_credits() {
if ($this->pilot_imdbfill==FULL_ACCESS) $this->crazy_credits = $this->imdb->crazy_credits();
return $this->crazy_credits;
}
#========================================================[ /episodes page ]===
#--------------------------------------------------------[ Episodes Array ]---
/** Get the series episode(s)
* @method episodes
* @return array episodes (array[0..n] of array[0..m] of array[imdbid,title,airdate,plot])
* @see MoviePilot page /episodes
* @brief No data available at MoviePilot. AutoRetrieval from IMDB with
* <code>pilot_imdbfill</code> set to FULL_ACCESS
*/
public function episodes() {
if ($this->pilot_imdbfill==FULL_ACCESS) $this->season_episodes = $this->imdb->episodes();
return $this->season_episodes;
}
#===========================================================[ /goofs page ]===
#-----------------------------------------------------------[ Goofs Array ]---
/** Get the goofs
* @method goofs
* @return array goofs (array[0..n] of array[type,content]
* @see MoviePilot page /goofs
* @brief No data available at MoviePilot. AutoRetrieval from IMDB with
* <code>pilot_imdbfill</code> set to FULL_ACCESS
*/
public function goofs() {
if ($this->pilot_imdbfill==FULL_ACCESS) $this->goofs = $this->imdb->goofs();
return $this->goofs;
}
#==========================================================[ /quotes page ]===
#----------------------------------------------------------[ Quotes Array ]---
/** Get the quotes for a given movie
* @method quotes
* @return array quotes (array[0..n] of string)
* @see MoviePilot page /quotes
* @brief No data available at MoviePilot. AutoRetrieval from IMDB with
* <code>pilot_imdbfill</code> set to FULL_ACCESS
*/
public function quotes() {
if ($this->pilot_imdbfill==FULL_ACCESS) $this->moviequotes = $this->imdb->quotes();
return $this->moviequotes;
}
#========================================================[ /trailers page ]===
#--------------------------------------------------------[ Trailers Array ]---
/** Get the trailer URLs for a given movie
* @method trailers
* @param optional boolean full Retrieve all available data (TRUE), or stay compatible with previous IMDBPHP versions (FALSE, Default)
* @return mixed trailers either array[0..n] of string ($full=FALSE), or array[0..n] of array[lang,title,url,restful_url ($full=TRUE)
* @see MoviePilot page /trailers
*/
public function trailers($full=FALSE) {
if ( empty($this->trailers) ) {
if (empty($this->page["Trailers"])) $this->openpage("Trailers");
if ( $this->invalidPage("Trailers") ) return $this->trailers;
foreach ($this->page["Trailers"] as $trailer) {
if ($full) {
$this->trailers[] = array("lang"=>$trailer->language,"title"=>$trailer->title,"url"=>$trailer->url,"restful_url"=>$trailer->restful_url);
} else {
$this->trailers[] = $trailer->url;
}
}
}
return $this->trailers;
}
#===========================================================[ /videosites ]===
#------------------------------------------[ Off-site trailers and videos ]---
/** Get the off-site videos and trailer URLs
* @method videosites
* @see IMDB page /videosites
* @brief No data available at MoviePilot. AutoRetrieval from IMDB with
* <code>pilot_imdbfill</code> set to FULL_ACCESS
*/
public function videosites() {
if ($this->pilot_imdbfill==FULL_ACCESS) return $this->imdb->videosites();
}
#==========================================================[ /trivia page ]===
#----------------------------------------------------------[ Trivia Array ]---
/** Get the trivia info
* @method trivia
* @return array trivia (array[0..n] string
* @see MoviePilot page /trivia
* @brief No data available at MoviePilot. AutoRetrieval from IMDB with
* <code>pilot_imdbfill</code> set to FULL_ACCESS
*/
public function trivia() {
if ($this->pilot_imdbfill==FULL_ACCESS) $this->trivia = $this->imdb->trivia();
return $this->trivia;
}
#======================================================[ /soundtrack page ]===
#------------------------------------------------------[ Soundtrack Array ]---
/** Get the soundtrack listing
* @method soundtrack
* @return array soundtracks (array[0..n] of array(soundtrack,array[0..n] of credits)
* @brief Usually, the credits array should hold [0] written by, [1] performed by.
* But IMDB does not always stick to that - so in many cases it holds
* [0] performed by, [1] courtesy of<BR>
* No data available at MoviePilot. AutoRetrieval from IMDB with
* <code>pilot_imdbfill</code> set to FULL_ACCESS
* @see MoviePilot page /soundtrack
*/
public function soundtrack() {
if ($this->pilot_imdbfill==FULL_ACCESS) $this->soundtracks = $this->imdb->soundtrack();
return $this->soundtracks;
}
#=================================================[ /movieconnection page ]===
#-------------------------------------------------[ MovieConnection Array ]---
/** Get connected movie information
* @method movieconnection
* @return array connections (versionOf, editedInto, followedBy, spinOff,
* spinOffFrom, references, referenced, features, featured, spoofs,
* spoofed - each an array of mid, name, year, comment or an empty
* array if no connections of that type)
* @see MoviePilot page /movieconnection
* @brief No data available at MoviePilot. AutoRetrieval from IMDB with
* <code>pilot_imdbfill</code> set to FULL_ACCESS
*/
public function movieconnection() {
if ($this->pilot_imdbfill==FULL_ACCESS) $this->movieconnections = $this->imdb->movieconnection();
elseif (empty($this->movieconnections)) {
# if (empty($this->page["MovieConnections"])) $this->openpage("MovieConnections");
# if ( $this->invalidPage("MovieConnections") ) return array(); // no such page
$this->movieconnections["versionOf"] = array();
$this->movieconnections["editedInto"] = array();
$this->movieconnections["followedBy"] = array();
$this->movieconnections["spinOffFrom"] = array();
$this->movieconnections["spinOff"] = array();
$this->movieconnections["references"] = array();
$this->movieconnections["referenced"] = array();
$this->movieconnections["features"] = array();
$this->movieconnections["featured"] = array();
$this->movieconnections["spoofs"] = array();
$this->movieconnections["spoofed"] = array();
}
return $this->movieconnections;
}
#=================================================[ /externalreviews page ]===
#-------------------------------------------------[ ExternalReviews Array ]---
/** Get list of external reviews (if any)
* @method extReviews
* @return array [0..n] of array [url, desc] (or empty array if no data)
* @see MoviePilot page /externalreviews
* @brief No data available at MoviePilot. AutoRetrieval from IMDB with
* <code>pilot_imdbfill</code> set to FULL_ACCESS
*/
public function extReviews() {
if ($this->pilot_imdbfill==FULL_ACCESS) $this->extreviews = $this->imdb->extReviews();