diff options
author | André Fabian Silva Delgado <emulatorman@parabola.nu> | 2016-07-15 15:33:36 -0300 |
---|---|---|
committer | André Fabian Silva Delgado <emulatorman@parabola.nu> | 2016-07-15 15:33:36 -0300 |
commit | a5f917bbc55e295896b8084f6657eb8b6abaf8a8 (patch) | |
tree | 83dca14378e45b11fe6bbf1d17e64505dff43cbd /extensions/TimedMediaHandler/maintenance/moveTranscoded.php | |
parent | a1d705e541e0d10baa6bb03935ffd38d9478d0e6 (diff) |
Add TimedMediaHandler extension that allows display audio and video files in wiki pages, using the same syntax as for image files
Diffstat (limited to 'extensions/TimedMediaHandler/maintenance/moveTranscoded.php')
-rw-r--r-- | extensions/TimedMediaHandler/maintenance/moveTranscoded.php | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/extensions/TimedMediaHandler/maintenance/moveTranscoded.php b/extensions/TimedMediaHandler/maintenance/moveTranscoded.php new file mode 100644 index 00000000..1ff6717c --- /dev/null +++ b/extensions/TimedMediaHandler/maintenance/moveTranscoded.php @@ -0,0 +1,56 @@ +<?php +/** + * move transcoded files from thumb to transcoded container + * + */ +$IP = getenv( 'MW_INSTALL_PATH' ); +if ( $IP === false ) { + $IP = dirname( __FILE__ ) . '/../../..'; +} +require_once( "$IP/maintenance/Maintenance.php" ); + +class MoveTranscoded extends Maintenance { + + public function __construct() { + parent::__construct(); + $this->mDescription = "move transcoded files from thumb to transcoded container."; + } + public function execute() { + global $wgEnabledTranscodeSet; + + $this->output( "Move transcoded files:\n" ); + $dbr = wfGetDB( DB_SLAVE ); + $res = $dbr->select( 'transcode', '*', array(), __METHOD__ ); + foreach ( $res as $row ) { + $title = Title::newFromText( $row->transcode_image_name, NS_FILE ); + $file = wfLocalFile( $title ); + if ( !$file ) { + continue; + } + $oldPath = $file->getThumbPath( $file->getName() . '.' . $row->transcode_key ); + + $newPath = WebVideoTranscode::getDerivativeFilePath( $file, $row->transcode_key ); + if ($oldPath != $newPath) { + if( $file->repo->fileExists( $oldPath ) ){ + if( $file->repo->fileExists( $newPath ) ){ + $res = $file->repo->quickPurge( $oldPath ); + if( !$res ){ + wfDebug( "Could not delete file $oldPath\n" ); + } else { + $this->output( "deleted $oldPath, exists in transcoded container\n" ); + } + } else { + $this->output( " $oldPath => $newPath\n" ); + $file->repo->quickImport( $oldPath, $newPath ); + $file->repo->quickPurge( $oldPath ); + } + } + } + + } + $this->output( "Finished!\n" ); + } +} + +$maintClass = 'MoveTranscoded'; // Tells it to run the class +require_once( RUN_MAINTENANCE_IF_MAIN ); |