public function doMkvMerge() { $result = new ezcMvcResult; $result->variables['page_title'] = "MKV Merge command manager :: MKV Manager"; $result->variables['targetDisks'] = mmMkvManagerDiskHelper::diskList(); if ( isset( $_POST['WinCmd'] ) ) $result->variables += mmApp::doConvertWinCMD( $_POST['WinCmd'], $_POST['Target'] ); return $result; }
/** * 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; }
/** * Returns a merge operation's progress, as a rounded percentage * * @return int */ public function progress() { try { $currentTargetSize = mmMkvManagerDiskHelper::bigFileSize( $this->targetFile ); } catch( ezcBaseFileNotFoundException $e ) { return 0; } return round( $currentTargetSize / $this->targetFileSize * 100 ); }
/** * 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; }
public function __get( $property ) { $tvShowPath = ezcConfigurationManager::getInstance()->getSetting( 'tv', 'GeneralSettings', 'SourcePath' ); switch( $property ) { case 'hasSubtitleFile': $basedirAndFile = "{$tvShowPath}/{$this->showName}/{$this->fullname}"; return ( file_exists( "$basedirAndFile.srt" ) || file_exists( "$basedirAndFile.ass" ) ); break; case 'subtitleFile': $basedirAndFile = "{$tvShowPath}/{$this->showName}/{$this->fullname}"; if ( file_exists( "$basedirAndFile.ass" ) ) return "$basedirAndFile.ass"; elseif ( file_exists( "$basedirAndFile.srt" ) ) { return "$basedirAndFile.srt"; } else { throw new Exception("No subtitle found for $this->filename" ); } break; case 'path': return "{$tvShowPath}/{$this->showName}/{$this->filename}"; break; case 'downloadedFile': $db = ezcDbInstance::get( 'sickbeard' ); // show ID $q = $db->createSelectQuery(); $q->select( 'tvdb_id' ) ->from( 'tv_shows' ) ->where( $q->expr->eq( 'show_name', $q->bindValue( $this->showName ) ) ); /** * @var PDOStatement */ $stmt = $q->prepare(); $stmt->execute(); $showId = $stmt->fetchColumn(); // downloaded file name $q = $db->createSelectQuery(); $e = $q->expr; $q->select( 'resource' ) ->from( 'history' ) ->where( $e->lAnd( $e->eq( 'action', $q->bindValue( 404 ) ), $e->eq( 'showid', $q->bindValue( $showId) ), $e->eq( 'season', $q->bindValue( $this->seasonNumber) ), $e->eq( 'episode', $q->bindValue( $this->episodeNumber ) ) ) ); $stmt = $q->prepare(); $stmt->execute(); return new TVEpisodeDownloadedFile( basename( $downloadedFile = $stmt->fetchColumn() ) ); case 'fileSize': return mmMkvManagerDiskHelper::bigFileSize( $this->path ); default: throw new ezcBasePropertyNotFoundException( $property ); } }