summaryrefslogtreecommitdiff
path: root/extensions/TimedMediaHandler/maintenance/cleanupTranscodes.php
diff options
context:
space:
mode:
authorAndré Fabian Silva Delgado <emulatorman@parabola.nu>2016-07-15 15:33:36 -0300
committerAndré Fabian Silva Delgado <emulatorman@parabola.nu>2016-07-15 15:33:36 -0300
commita5f917bbc55e295896b8084f6657eb8b6abaf8a8 (patch)
tree83dca14378e45b11fe6bbf1d17e64505dff43cbd /extensions/TimedMediaHandler/maintenance/cleanupTranscodes.php
parenta1d705e541e0d10baa6bb03935ffd38d9478d0e6 (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/cleanupTranscodes.php')
-rw-r--r--extensions/TimedMediaHandler/maintenance/cleanupTranscodes.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/extensions/TimedMediaHandler/maintenance/cleanupTranscodes.php b/extensions/TimedMediaHandler/maintenance/cleanupTranscodes.php
new file mode 100644
index 00000000..01c7b004
--- /dev/null
+++ b/extensions/TimedMediaHandler/maintenance/cleanupTranscodes.php
@@ -0,0 +1,46 @@
+<?php
+/**
+ * cleanup transcodes no longer defined in $wgEnabledTranscodeSet
+ *
+ */
+$IP = getenv( 'MW_INSTALL_PATH' );
+if ( $IP === false ) {
+ $IP = dirname( __FILE__ ) . '/../../..';
+}
+require_once( "$IP/maintenance/Maintenance.php" );
+
+class CleanupTranscodes extends Maintenance {
+
+ public function __construct() {
+ parent::__construct();
+ $this->addOption( "key", "remove all transcodes for given key", false, true );
+ $this->addOption( "all", "remove all transcodes", false, false );
+ $this->mDescription = "cleanup transcodes left over after changing encoding profiles.";
+ }
+ public function execute() {
+ global $wgEnabledTranscodeSet;
+
+ if ( $this->hasOption( "all" ) ) {
+ $where = array();
+ } elseif ( $this->hasOption( "key" ) ) {
+ $where = array( 'transcode_key' => $this->getOption( 'key' ) );
+ } else {
+ $where = 'transcode_key NOT IN ("'. implode('", "', $wgEnabledTranscodeSet ).'")';
+ }
+ $this->output( "Cleanup transcodes:\n" );
+ $dbr = wfGetDB( DB_SLAVE );
+ $res = $dbr->select( 'transcode', '*', $where, __METHOD__ );
+ foreach ( $res as $row ) {
+ $this->output(
+ 'remove: '. $row->transcode_image_name . ' ' . $row->transcode_key . "\n"
+ );
+ $title = Title::newFromText( $row->transcode_image_name, NS_FILE );
+ $file = wfLocalFile( $title );
+ WebVideoTranscode::removeTranscodes( $file, $row->transcode_key );
+ }
+ $this->output( "Finished!\n" );
+ }
+}
+
+$maintClass = 'CleanupTranscodes'; // Tells it to run the class
+require_once( RUN_MAINTENANCE_IF_MAIN );