Пример #1
0
 public function Fire()
 {
     if (!$this->input->name) {
         TaskPump::Pump()->QueueTask(new ErrorTask('Name is required.'));
         return;
     }
     if (!$this->input->episode) {
         TaskPump::Pump()->QueueTask(new ErrorTask('Episode (SxE) is required.'));
         return;
     }
     if (!$this->input->feed_url) {
         TaskPump::Pump()->QueueTask(new ErrorTask('Feed URL is required.'));
         return;
     }
     $episode = Episode::SplitEpisodeNumber($this->input->episode);
     if (!$episode) {
         TaskPump::Pump()->QueueTask(new ErrorTask('Episode format is invalid (SxE).'));
         return;
     }
     $show = new Show();
     $show->name = $this->input->name;
     $show->search_url = $this->input->feed_url;
     $show->last_season = $episode[0];
     $show->last_episode = $episode[1];
     try {
         $show->Insert();
     } catch (\phalanx\data\ModelException $e) {
         TaskPump::Pump()->QueueTask(new ErrorTask('An error occurred while adding the show.'));
         return;
     }
     $str = 'Added ' . $show->name . ' at ' . $show->last_season . 'x' . $show->last_episode;
     TaskPump::Pump()->QueueTask(new MessageTask($str));
 }
Пример #2
0
 public function Fire()
 {
     $show = Show::FetchByName($this->input->_id);
     if (!$show) {
         TaskPump::Pump()->QueueTask(new ErrorTask('Could not find show named "' . $this->input->_id . '"'));
         return;
     }
     try {
         $show->Delete();
     } catch (\phalanx\data\ModelException $e) {
         TaskPump::Pump()->QueueTask(new ErrorTask('An error occurred while deleting the show.'));
         return;
     }
     TaskPump::Pump()->QueueTask(new MessageTask('Deleted ' . $show->name));
 }
Пример #3
0
 public function Fire()
 {
     $show = Show::FetchByName($this->input->_id);
     if (!$show) {
         TaskPump::Pump()->QueueTask(new ErrorTask('Could not find show named "' . $this->input->_id . '"'));
         return;
     }
     $show->last_season++;
     $show->last_episode = 0;
     try {
         $show->Update();
     } catch (\phalanx\data\ModelException $e) {
         TaskPump::Pump()->QueueTask(new ErrorTask('An error occurred while updating the record.'));
         return;
     }
     TaskPump::Pump()->QueueTask(new MessageTask('Updated ' . $show->name . ' to ' . $show->last_season . 'x' . $show->last_episode));
 }
Пример #4
0
 public function Fire()
 {
     $keeper = new BookKeeper();
     $provider = GetProvider();
     $shows = Show::FetchAll();
     foreach ($shows as $show) {
         LogMessage("Beginning search for {$show->name}");
         $results = $provider->SearchForShow($show);
         foreach ($results as $episode) {
             // Skip this episode if it's too old.
             if (!$keeper->ShouldDownloadEpisode($episode)) {
                 LogMessage("Skipping #{$episode->nzbid} '{$episode->title}' because it is too old");
                 continue;
             }
             // We've already downloaded this episode.
             if ($episode->IsAlreadyDownloaded()) {
                 LogMessage("Skipping #{$episode->nzbid} '{$episode->title}' because it has been downloaded previously");
                 continue;
             }
             TaskPump::Pump()->QueueTask(new DownloadEpisodeTask($episode));
         }
     }
 }
Пример #5
0
 public function Fire()
 {
     $shows = Show::FetchAll();
     foreach ($shows as $show) {
         $episode = $show->GetLatestEpisode();
         if (!$episode) {
             continue;
         }
         // This show hasn't been downloaded yet.
         if ($episode->season > $show->last_season || $episode->season == $show->last_season && $episode->episode > $show->last_episode) {
             print "{$show->name} has {$show->last_season}x{$show->last_episode} as latest," . " but most recent download is {$episode->season}x{$episode->episode}. Update" . " [Y/n]? ";
             $fp = fopen('php://stdin', 'r');
             $c = fgetc($fp);
             fclose($fp);
             if (strtolower($c) == 'y') {
                 $show->last_season = $episode->season;
                 $show->last_episode = $episode->episode;
                 $show->Update();
                 TaskPump::Pump()->QueueTask(new MessageTask("Updated {$show->name} to {$show->last_season}x{$show->last_episode}"));
             }
         }
     }
 }