Browse Source

Merge pull request #834 from rob1998/v2-develop

CouchPotato Calendar Metadata
causefx 8 years ago
parent
commit
3ca03d40a3
1 changed files with 36 additions and 0 deletions
  1. 36 0
      api/functions/homepage-connect-functions.php

+ 36 - 0
api/functions/homepage-connect-functions.php

@@ -985,12 +985,48 @@ function getCouchCalendar($array,$number){
             if (new DateTime() < new DateTime($physicalRelease)) { $notReleased = "true"; }else{ $notReleased = "false"; }
             $downloaded = ($child['status'] == "active") ? "0" : "1";
             if($downloaded == "0" && $notReleased == "true"){ $downloaded = "text-info"; }elseif($downloaded == "1"){ $downloaded = "text-success"; }else{ $downloaded = "text-danger"; }
+
+            if(!empty($child['info']['images']['backdrop_original'])) {
+                $banner = $child['info']['images']['backdrop_original'][0];
+            } else if (!empty($child['info']['images']['backdrop'])) {
+                $banner = $child['info']['images']['backdrop_original'][0];
+            } else {
+                $banner = "/plugins/images/cache/no-np.png";
+            }
+            if($banner !== "/plugins/images/cache/no-np.png"){
+                $cacheDirectory = dirname(__DIR__,2).DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR;
+                $imageURL = $banner;
+                $cacheFile = $cacheDirectory.$movieID.'.jpg';
+                $banner = 'plugins/images/cache/'.$movieID.'.jpg';
+                if(!file_exists($cacheFile)){
+                    cacheImage($imageURL,$movieID);
+                    unset($imageURL);
+                    unset($cacheFile);
+                }
+            }
+            $hasFile = ( !empty($child['releases']) && !empty($child['releases'][0]['files']['movie']) );
+            $details = array(
+                    "topTitle" => $movieName,
+                    "bottomTitle" => $child['info']['tagline'],
+                    "status" => $child['status'],
+                    "overview" => $child['info']['plot'],
+                    "runtime" => $child['info']['runtime'],
+                    "image" => $banner,
+                    "ratings" => $child['info']['rating']['imdb'][0],
+                    "videoQuality" => $hasFile ? $child['releases'][0]['quality'] : "unknown",
+                    "audioChannels" => "",
+                    "audioCodec" => "",
+                    "videoCodec" => "",
+                    "genres" => $child['info']['genres'],
+                );
+
             array_push($gotCalendar, array(
                 "id" => "CouchPotato-".$number."-".$i,
                 "title" => $movieName,
                 "start" => $physicalRelease,
                 "className" => "bg-calendar calendar-item movieID--".$movieID,
                 "imagetype" => "film ".$downloaded,
+                "details" => $details
             ));
         }
     }