Пример #1
0
 /**
  * Updates options in db.
  * 
  * @param  array  $options
  * @return void
  */
 public function updateOptions(array $options)
 {
     foreach ($options as $k => $v) {
         $insert[$k] = $v;
     }
     $this->dbWriter->updateOptions($insert);
 }
Пример #2
0
 /**
  * Adds given title to given list of user.
  *
  * @param  array $input
  * @return void
  */
 public function add(array $input)
 {
     if ($user = Sentry::getUser()) {
         $data = array('user_id' => $user->id, 'title_id' => $input['title_id'], $input['list_name'] => 1);
     }
     $this->dbWriter->compileInsert('users_titles', $data)->save();
     //fire eloquent saved event so cache is flushed
     Event::fire('eloquent.saved: *', new Title());
 }
Пример #3
0
 /**
  * Handles new season creation from input.
  * 
  * @param  array $input
  * @return Season
  */
 public function create(array $input)
 {
     $temp = str_random(10);
     $input['temp_id'] = $temp;
     $this->dbWriter->CompileInsert('seasons', $input)->save();
     return $this->season->where('temp_id', $temp)->limit(1)->get(array('id'))->first();
 }
Пример #4
0
 /**
  * Associates actors with titles.
  * 
  * @param  string $temp tempId of titles to associate.
  * @return void
  */
 private function associate($temp, $known = 0)
 {
     $insert = array();
     $titles = $this->title->Where('temp_id', '=', $temp)->lists('id');
     foreach ($titles as $k => $v) {
         $insert[] = array('actor_id' => $this->actorId, 'title_id' => $v, 'known_for' => $known);
     }
     $this->dbWriter->compileBatchInsert('actors_titles', $insert)->save();
 }
Пример #5
0
 /**
  * Upload and associate image to title.
  *
  * @param array $input
  * @return  void
  */
 public function uploadImage(array $input)
 {
     $title = $this->model->find($input['title-id']);
     $name = str_random(25);
     $insert = array('local' => asset('assets/images/' . $name . '.jpg'), 'title_id' => $input['title-id']);
     $this->images->saveTitleImage($input, $name);
     $this->dbWriter->compileInsert('images', $insert)->save();
     Event::fire('Titles.Modified', array($input['title-id']));
 }
Пример #6
0
 /**
  * Attaches actor to title from given input.
  * 
  * @param  array $input
  * @return void
  */
 private function attachActor(array $input)
 {
     //if we've got no actor id in input means we're
     //attaching a new actor to title so we need to
     //insert this actor into db first
     if (!isset($input['actor-id'])) {
         $actor = $this->insertActor($input['actor']);
         $input['actor-id'] = $actor->id;
     }
     $this->dbWriter->compileInsert('actors_titles', array('actor_id' => $input['actor-id'], 'title_id' => $input['title-id'], 'char_name' => $input['char']))->save();
 }
Пример #7
0
 /**
  * Associates actors with titles.
  * 
  * @param  string $temp tempId of titles to associate.
  * @return void
  */
 private function associate($temp, $known = 0, $names = array())
 {
     $insert = array();
     $titles = $this->title->Where('temp_id', '=', $temp)->get(array('id', 'tmdb_id'));
     foreach ($titles as $k => $v) {
         if (isset($names[$v['tmdb_id']])) {
             $insert[] = array('actor_id' => $this->modelId, 'title_id' => $v['id'], 'known_for' => $known, 'char_name' => $names[$v['tmdb_id']]);
         } else {
             $insert[] = array('actor_id' => $this->modelId, 'title_id' => $v['id'], 'known_for' => $known);
         }
     }
     $this->dbWriter->compileBatchInsert('actors_titles', $insert)->save();
 }
Пример #8
0
 /**
  * Scrapes titles from imdb advanced search
  * 
  * @param  array $input
  * @return void
  */
 public function imdbAdvanced(array $input)
 {
     ini_set('max_execution_time', 0);
     $url = $this->compileImdbAdvancedUrl($input);
     $amount = $input['howMuch'];
     $currentPage = 1;
     while ($currentPage <= $amount) {
         $html = $this->curl($url);
         //increment current page by 100 as thats how many
         //titles page containts
         $currentPage = $currentPage + 100;
         //change url so it starts at 100 more then previous scrape
         $url = preg_replace('/&start=[0-9]+/', "&start={$currentPage}", $url);
         $data = $this->imdbSearch->compileSearchResults($html);
         if (!$data) {
             return false;
         }
         $this->dbWriter->insertFromImdbSearch($data);
     }
     Event::Fire('Titles.Updated');
     return $currentPage;
 }
Пример #9
0
 /**
  * Handles new episode creation/updating.
  * 
  * @param  array $input
  * @return void
  */
 public function create(array $input)
 {
     $this->dbWriter->CompileInsert('episodes', $input)->save();
     Event::fire('Titles.Modified', array($input['title_id']));
 }
Пример #10
0
 /**
  * Handles new season creation from input.
  * 
  * @param  array $input
  * @return void
  */
 public function create(array $input)
 {
     $this->dbWriter->CompileInsert('seasons', $input)->save();
 }
Пример #11
0
 /**
  * Saves scraped news to the database.
  * 
  * @return void
  */
 private function save()
 {
     $this->dbWriter->compileBatchInsert('news', $this->news)->save();
 }
Пример #12
0
 /**
  * Saves featured movies to db.
  * 
  * @param  string $html
  * @return void
  */
 private function saveFeatured($html)
 {
     foreach ($html as $h) {
         $flags = array('featured' => 1, 'fully_scraped' => 1, 'temp_id' => str_random(15));
         $writer = new Writer(new ImdbData($h), $flags);
         $writer->saveAll();
     }
 }
Пример #13
0
 /**
  * Saves reviews from user input.
  * 
  * @param  array $input
  * @return void
  */
 public function save(array $input)
 {
     $input['source'] = trans('main.brand');
     $this->dbWriter->compileInsert('reviews', $input)->save();
 }
Пример #14
0
 /**
  * Adds given title to given list of user.
  *
  * @param  array $input
  * @return void
  */
 public function add(array $input)
 {
     $data = array('user_id' => $input['user'], 'title_id' => $input['title'], $input['list'] => 1);
     $this->dbWriter->compileInsert('users_titles', $data)->save();
 }