Exemplo n.º 1
0
 /**
  * Downloads and saves multiple images locally.
  * 
  * @param  string $url 
  * @param  string $id
  * @param  string/null $path
  * @param  string/int $num
  * @return void
  */
 public function saveMultiple(array $urls, $id = null, $path)
 {
     if (empty($urls)) {
         return;
     }
     $images = $this->scraper->multiCurl($urls);
     foreach ($images as $k => $v) {
         //we're saving cast images
         if (strpos($k, 'nm') || !$id) {
             try {
                 Imagine::raw($v)->save(public_path($path) . $k . '.jpg', 100);
             } catch (\Exception $e) {
             }
         } else {
             try {
                 $image = Imagine::raw($v);
                 $image->save(public_path($path) . $id . $k . '.jpg', 60);
                 $image->resize(400, null, function ($constraint) {
                     $constraint->aspectRatio();
                 })->save(public_path($path) . $id . $k . '.thumb' . '.jpg', 90);
             } catch (\Exception $e) {
             }
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Scrapes the reviews of provided title from metacritic.
  * 
  * @param  string $title
  * @return self
  */
 public function get(Title $title)
 {
     // $titleName = $title->original_title ? $title->original_title : $title->title;
     $titleName = $title->title;
     $url = $this->url($titleName, $title->type);
     $this->html = $this->scraper->curl($url);
     $this->title = $title;
     return $this;
 }
Exemplo n.º 3
0
 /**
  * Scrapes given actors page.
  *
  * @param string $id
  * @return self
  */
 private function scrape($id)
 {
     $url = 'http://www.imdb.com/name/' . "{$id}/";
     $html = $this->scraper->curl($url);
     $this->crawler = new crawler($html);
     $this->imdbid = $id;
     return $this;
 }
Exemplo n.º 4
0
 /**
  * Scrapes given actors page.
  *
  * @param string $id
  * @return self
  */
 private function scrape($id)
 {
     $url = 'http://www.imdb.com/name/' . "{$id}/";
     $html = $this->scraper->curl($url);
     $html = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $html);
     $this->crawler = new crawler($html);
     $this->imdbid = $id;
     return $this;
 }
Exemplo n.º 5
0
 /**
  * Fetches now playing movies from imdb.
  * 
  * @return array
  */
 public function getNowPlaying()
 {
     $url = 'http://www.imdb.com/movies-in-theaters/';
     $html = $this->scraper->curl($url);
     $crawler = new Crawler($html);
     //grab all the movie divs
     $titles = $crawler->filter('.list.detail')->eq(1)->filter('.list_item');
     return $this->compileNowPLaying($titles);
 }