Ejemplo n.º 1
0
 public function testCustomFileExtensionsWillBeDetected()
 {
     // for testing purposes subtitles will be treated as custom movies (content makes no difference)
     // if subtitles are going to be detected, so will movies
     $this->movieFinder = new \Mihaeu\SubCollector\Movie\Finder(vfsStream::url('testDir'), array('srt'));
     $movies = $this->movieFinder->findFilesInFolder();
     $this->assertEquals(2, count($movies));
 }
Ejemplo n.º 2
0
 public function testIgnoresFilesItCannotRead()
 {
     // create a temp movie file, which cannot be read
     $tmpFolder = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'phpunit_mihaeu';
     if (!is_dir($tmpFolder)) {
         mkdir($tmpFolder);
     }
     $unreadableFile = $tmpFolder . DIRECTORY_SEPARATOR . 'test.avi';
     touch($unreadableFile);
     chmod($unreadableFile, 00);
     // unreadable file
     $movieFinder = new \Mihaeu\SubCollector\Movie\Finder($tmpFolder);
     $this->assertEquals(0, count($movieFinder->findFilesInFolder()));
 }
Ejemplo n.º 3
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>');
         }
     }
 }