Ejemplo n.º 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     #$result = DB::table('catalog')->select('*')->take(5)->get();
     #print_r($result) ;
     $trailers = [];
     $url = '';
     //MUST USE OUTSIDE SCRIPT BECAUSE OF CORS//
     $result = Selector::getTitles();
     #echo $result[6]['trailer_title'];
     #count($result);
     for ($i = 0; $i < count($result); $i++) {
         $parsedResult = Selector::removeSymbols($result[$i]['trailer_title']);
         if ($parsedResult == 'Hardcore-Henry') {
             $parsedResult = 'hardcore-2015';
         }
         if ($parsedResult === 'The-Jungle-Book') {
             $parsedResult = 'the-jungle-book-2015';
         }
         if ($parsedResult === 'Friend-Request') {
             $parsedResult = 'friend-request-2016';
         }
         if ($parsedResult === 'Teenage-Mutant-Ninja-TurtlesOut-of-the-Shadows') {
             $parsedResult = 'teenage-mutant-ninja-turtles-2';
         }
         if ($parsedResult === 'The-Angry-Birds') {
             $parsedResult = 'angry-birds';
         }
         if ($parsedResult === 'The-Witch') {
             $parsedResult = 'the-witch-2016';
         }
         if ($parsedResult === 'X-Men-Apocoalypse') {
             $parsedResult = 'xmen-apocalypse';
         }
         if ($parsedResult === 'Joy') {
             $parsedResult = 'joy-2015';
         }
         if ($parsedResult === 'The-Boy') {
             $parsedResult = 'the-boy-2016';
         }
         $url = 'http://simpleapi.traileraddict.com/' . $parsedResult . '/trailer';
         $val = getTrailers($url);
         #$val2 = strval($val);
         $trailers[$i]['title'] = $result[$i]['title'];
         $trailers[$i]['trailer'] = $val;
     }
     Selector::insertTrailers($trailers);
     #var_dump(getTrailers('http://simpleapi.traileraddict.com/Hail,-Caesar!/trailer')) ;
     #echo getTrailers('http://simpleapi.traileraddict.com/FSDDSF/trailer')  ;
 }
Ejemplo n.º 2
0
 public static function aggregate_films($title)
 {
     $films = DB::table('catalog')->leftJoin('omdb', 'catalog.title', '=', 'omdb.title_id')->select('catalog.title', 'catalog.venue', 'catalog.cinema', 'catalog.time', 'catalog.day', 'catalog.month', 'catalog.year', 'omdb.img', 'omdb.title_id', 'omdb.runtime', 'omdb.genre', 'omdb.imdb_rating', 'omdb.plot', 'omdb.website', 'omdb.tomato_url')->where('catalog.title', '=', $title)->get();
     $replace = Selector::replace('_', " ", $films[0]->title);
     $trailer = DB::table('trailers')->select('trailers.trailer')->where('trailers.title', '=', $title)->get();
     $z = 0;
     $tempArray = [];
     $aggregateArray[0]['title_id'] = $films[0]->title;
     $aggregateArray[0]['title'] = $replace;
     $aggregateArray[0]['marker'] = 'search';
     $aggregateArray[0]['trailer'] = $trailer[0]->trailer;
     $aggregateArray[0]['img'] = $films[0]->img;
     $aggregateArray[0]['plot'] = $films[0]->plot;
     $aggregateArray[0]['website'] = $films[0]->website;
     $aggregateArray[0]['tomato_url'] = $films[0]->tomato_url;
     $aggregateArray[0]['genre'] = $films[0]->genre;
     $aggregateArray[0]['runtime'] = $films[0]->runtime;
     $aggregateArray[0]['imdb_rating'] = $films[0]->imdb_rating;
     $aggregateArray[0]['runtime'] = $films[0]->runtime;
     for ($i = 0; $i < count($films); $i++) {
         if (array_search($films[$i]->venue, $tempArray) === false) {
             $tempArray[$z] = $films[$i]->venue;
             $aggregateArray[$z]['venue'] = $films[$i]->venue;
             $aggregateArray[$z]['cinema'] = $films[$i]->cinema;
             $z++;
         }
     }
     return $aggregateArray;
 }