Ejemplo n.º 1
0
 /**
  * Calculates the best fit for a command
  *
  * @param string $command Windows command line
  * @return array ezcMvcResult content, others... :)
  */
 public static function doBestFit($command)
 {
     $command = MKVMergeCommandImportWindowsGUI::convert($command, false);
     $return = array('size' => $command->TargetSize);
     if ($command->conversionType === 'tvshow') {
         $return += mmMkvManagerDiskHelper::BestTVEpisodeFit($command->title, $command->TargetSize);
     }
     return $return;
 }
Ejemplo n.º 2
0
    /**
     * Generates an MKVMerge command for the video file $videoFile
     * @param string $videoFile
     */
    public function doGenerateCommand()
    {
        $result = new ezcMvcResult();

        $videoFile = $this->VideoFile;

        $episodeFile = new TVEpisodeFile( $videoFile );
        $result->variables['status'] = 'ok';
        $commandGenerator = new MKVMergeCommandGenerator();

        // add audio + video in english, and disable existing subtitles
        foreach( $commandGenerator->addInputFile( new MKVMergeMediaInputFile( $episodeFile->path ) )
            as $track )
        {
            if ( $track instanceof MKVmergeCommandSubtitleTrack )
            {
                $track->enabled = false;
            }
            else
            {
                $track->language = 'eng';
                $track->default_track = true;
            }
        }
        // add subtitle file
        if ( $episodeFile->hasSubtitleFile )
        {
            foreach( $commandGenerator->addInputFile( new MKVMergeSubtitleInputFile( $episodeFile->subtitleFile, 'fre' ) )
                as $track )
            {
                $track->language = 'fre';
                $track->default_track = true;
            }
        }

        // determine best disk
        $bestFit = mmMkvManagerDiskHelper::BestTVEpisodeFit( $episodeFile->fullname, $episodeFile->fileSize );
        if ( isset( $bestFit['RecommendedDiskHasFreeSpace'] ) && $bestFit['RecommendedDiskHasFreeSpace'] === 'true' )
            $disk = $bestFit['RecommendedDisk'];
        else
            $disk = 'VIMES';

        $commandGenerator->setOutputFile( "/media/storage/{$disk}/TV Shows/{$episodeFile->showName}/{$episodeFile->filename}" );

        $commandObject = $commandGenerator->get();
        $commandObject->appendSymLink = true;

        $result->variables['command'] = $commandObject->asString();

        return $result;
    }