Exemplo n.º 1
0
 public function testSubtitleFileWillOnlyBeSavedWhenSubtitleWasFound()
 {
     // mock the sub provider
     $mock = \Mockery::mock('\\Mihaeu\\SubCollector\\Provider\\SubProviderInterface');
     $mock->shouldReceive('createMovieHashFromMovieFile')->andReturn(false);
     $subCollector = new SubCollector($mock);
     $fakeMovieWithoutSubtitle = new Movie(vfsStream::url('testDir') . DIRECTORY_SEPARATOR . 'movies' . DIRECTORY_SEPARATOR . 'Die Hard.mkv');
     $this->assertFalse($subCollector->addSubtitleToMovie($fakeMovieWithoutSubtitle));
 }
Exemplo n.º 2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $subCollector = new SubCollector($this->subProvider);
     $movieFinder = new Finder($input->getArgument('path'));
     $movies = $movieFinder->findFilesInFolder();
     /** @var Movie $movie */
     foreach ($movies as $movie) {
         if ($movie->hasNoSubtitle()) {
             $subtitleHasBeenDownloaded = $subCollector->addSubtitleToMovie($movie);
             if ($subtitleHasBeenDownloaded) {
                 $output->writeln('<info>Downloaded subtitle for ' . $movie->getName() . '</info>');
             } else {
                 $output->writeln('<comment>No exact match found for ' . $movie->getName() . '</comment>');
             }
         } else {
             $output->writeln('<comment>' . $movie->getName() . ' already has a subtitle.</comment>');
         }
     }
 }