Editing OMwiki:Tech/OMwiki-import.php

Warning: The database has been locked for maintenance, so you will not be able to save your edits right now. You may wish to cut-n-paste the text into a text file and save it for later.

The administrator who locked it offered this explanation:
Editing disabled as spam controls are no longer effective...
Please see: http://meta.wikimedia.org/wiki/OpenMeetings.org
Message updated 29-March-2013 by GChriss

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Current revision Your text
Line 19: Line 19:
require_once ( '../../../maintenance/commandLine.inc' );
require_once ( '../../../maintenance/commandLine.inc' );
-
define( 'MV_DOWNLOAD_DIR', '/home/openmeet/www/archives/' );
+
define( 'MV_DOWNLOAD_DIR', '/home/openmeet/www/w/extensions/MetavidWiki/maintenance/test' );
-
define( 'MV_ARCHIVE_ORG_DL', 'http://ia301540.us.archive.org/3/items/ovc_internetarchive_19june2009/' );
+
define( 'MV_ARCHIVE_ORG_DL', 'http://www.archive.org/download/' );
define( 'ARCHIVE_ORG_SKIP_LIST', '' );
define( 'ARCHIVE_ORG_SKIP_LIST', '' );
Line 33: Line 33:
if ( count( $args ) == 0 || isset ( $options['help'] ) ) {
if ( count( $args ) == 0 || isset ( $options['help'] ) ) {
print "
print "
-
Downloads files from archive.org to configured directory: {$mvDownloadDir}
+
Downloads files from archive.org to configured directory:{$mvDownloadDir}
options keyword:  
options keyword:  
all   //to get all
all   //to get all
-
[stream_name] //to grab a specific stream
+
[stream_name] //to grab a specifc stream
";
";
Line 48: Line 48:
$sql = "SELECT * FROM `mv_streams` LIMIT 0, 5000";
$sql = "SELECT * FROM `mv_streams` LIMIT 0, 5000";
} else {
} else {
-
$sql = "SELECT * FROM `mv_streams` WHERE `name` LIKE '$stream_name'";
+
$sql = "SELECT * FROM `mv_streams` WHERE `name` ={$stream_name}";
}
}
$dbr = wfGetDB( DB_READ );
$dbr = wfGetDB( DB_READ );
Line 55: Line 55:
$skip_list = unserialize( file_get_contents( ARCHIVE_ORG_SKIP_LIST ) );
$skip_list = unserialize( file_get_contents( ARCHIVE_ORG_SKIP_LIST ) );
while ( $stream = $dbr->fetchObject( $result ) ) {
while ( $stream = $dbr->fetchObject( $result ) ) {
-
$local_fl = MV_DOWNLOAD_DIR . strtolower($stream->name) . '.ogv';
+
$local_fl = MV_DOWNLOAD_DIR . $stream->name . '.ogv';
-
// $remote_fl = MV_ARCHIVE_ORG_DL . strtolower($stream->name) . '/format=Ogg+Theora';
+
$remote_fl = MV_ARCHIVE_ORG_DL . $stream->name . '/format=Ogg+Theora';
-
                 $remote_fl = MV_ARCHIVE_ORG_DL . strtolower($stream->name) . '.ogv';
+
                 $remote_meta = MV_ARCHIVE_ORG_DL . $stream->name . '/format=Metadata;
 +
$remote_animatedthumb = MV_ARCHIVE_ORG_DL . $stream->name . '/format=Animated Gif';
 +
$remote_torrent = MV_ARCHIVE_ORG_DL . $stream->name . '/format=Structural Metadata';
-
                $remote_meta = MV_ARCHIVE_ORG_DL . strtolower($stream->name) . '/format=Metadata';
 
-
$remote_animatedthumb = MV_ARCHIVE_ORG_DL . strtolower($stream->name) . '/format=Animated Gif';
 
-
$remote_torrent = MV_ARCHIVE_ORG_DL . strtolower($stream->name) . '/format=Structural Metadata';
 
-
 
-
/* if ( is_file( $local_fl ) . META_DATA_EXT && is_file( $local_fl ) ) {
+
if ( is_file( $local_fl ) . META_DATA_EXT && is_file( $local_fl ) ) {
// check db table for updated mv_flash_low_quality ref
// check db table for updated mv_flash_low_quality ref
$sql = " SELECT * FROM `mv_stream_files` WHERE `stream_id`='" . $stream->id . "' " .
$sql = " SELECT * FROM `mv_stream_files` WHERE `stream_id`='" . $stream->id . "' " .
Line 99: Line 97:
$dbw->query( $sql );
$dbw->query( $sql );
-
} */
+
}
-
+
}
-
// lets just skip local files for now and try to remove incomplete manually
+
// lets just skip local files for now and try to remove incomplete mannually
if ( isset( $skip_list[$stream->name] ) ) {
if ( isset( $skip_list[$stream->name] ) ) {
print "skipping:" . $stream->name . "\n";
print "skipping:" . $stream->name . "\n";
Line 108: Line 106:
}
}
-
+
// senate_proceeding_08-01-07/senate_proceeding_08-01-07.flv
 +
// check local file size matches remote:
 +
if ( is_file( $local_fl ) ) {
 +
print "file $local_fl present (skipping size check)\n";
 +
/*if( filesize($local_fl)!=remotefsize($remote_fl)){
 +
echo ' local:'. hr_bytes(filesize($local_fl)).
 +
' != remote:' . hr_bytes(remotefsize($remote_fl))."\n";
 +
echo '(skipping): ' . "\n";
 +
//curldownload($remote_fl, $local_fl);
 +
}else{
 +
echo ' sizes match: ' . hr_bytes(filesize($local_fl)) .'='.
 +
hr_bytes(remotefsize($remote_fl))."\n";
 +
}*/
 +
} else {
 +
// check if flash file exists:
 +
// $sql ="SELECT * FROM `mv_stream_files` WHERE `stream_id`=" .$stream->id
 +
// ao_file_flash_flv
 +
 
 +
if ( remotefsize( $remote_fl ) < 100000 ) {
 +
print "remote file: $remote_fl < 100k  (skipping) \n";
 +
$skip_list[$stream->name] = true;
 +
continue;
 +
}
echo "DL it: $remote_fl \n";
echo "DL it: $remote_fl \n";
if ( curldownload( $remote_fl, $local_fl ) ) {
if ( curldownload( $remote_fl, $local_fl ) ) {
-
echo 'succesfully grabed: ' . $remote_fl . "\n";
+
echo 'succesfully grabed ' . $remote_fl . "\n";
} ;
} ;
-
+
}
if ( !is_file( $local_fl ) . META_DATA_EXT ) {
if ( !is_file( $local_fl ) . META_DATA_EXT ) {
-
echo "generating RSS entry (FIXME)...\n";
+
echo "gennerating flv metadata\n";
$flv = new MyFLV();
$flv = new MyFLV();
-
/*try {
+
try {
$flv->open( $local_fl );
$flv->open( $local_fl );
} catch ( Exception $e ) {
} catch ( Exception $e ) {
Line 123: Line 143:
}
}
$flv->getMetaData();
$flv->getMetaData();
-
echo "done with .meta (" . filesize( $local_fl . META_DATA_EXT ) . ") \n"; */
+
echo "done with .meta (" . filesize( $local_fl . META_DATA_EXT ) . ") \n";
}
}
// add to skip list
// add to skip list
Line 135: Line 155:
function curldownload( $remote_file, $local_file ) {
function curldownload( $remote_file, $local_file ) {
$pid = simple_run_background( "curl -L -C - -o $local_file $remote_file" );
$pid = simple_run_background( "curl -L -C - -o $local_file $remote_file" );
-
print "Started CURL download with pid: $pid \n";
+
print "started download with pid: $pid \n";
$remote_size = remotefsize( $remote_file );
$remote_size = remotefsize( $remote_file );
$prev_byte = 0;
$prev_byte = 0;
-
while ( true ) {
+
while ( is_process_running( $pid ) ) {
$speed = hr_bytes( ( filesize( $local_file ) - $prev_byte ) / 10 );
$speed = hr_bytes( ( filesize( $local_file ) - $prev_byte ) / 10 );
echo "downloaded (" . hr_bytes( filesize( $local_file ) ) . ' of ' . hr_bytes( $remote_size ) . ") " . $speed . "/s \n";
echo "downloaded (" . hr_bytes( filesize( $local_file ) ) . ' of ' . hr_bytes( $remote_size ) . ") " . $speed . "/s \n";
$prev_byte = filesize( $local_file );
$prev_byte = filesize( $local_file );
-
                if ( $prev_byte == $remote_size ){break;}
 
clearstatcache();
clearstatcache();
-
sleep( 120 );
+
sleep( 10 );
}
}
return true;
return true;
Line 217: Line 236:
}
}
function simple_run_background( $command ) {
function simple_run_background( $command ) {
-
$PID = exec( "nohup $command > /dev/null & echo $!" );
+
$PID = shell_exec( "nohup $command > /dev/null & echo $!" );
return $PID;
return $PID;
}
}
// Verifies if a process is running in linux
// Verifies if a process is running in linux
-
/* function is_process_running( $PID ) {
+
function is_process_running( $PID ) {
$ProcessState = '';
$ProcessState = '';
exec( "ps $PID", $ProcessState );
exec( "ps $PID", $ProcessState );
return( count( $ProcessState ) >= 2 );
return( count( $ProcessState ) >= 2 );
-
} */
+
}
function hr_bytes( $size ) {
function hr_bytes( $size ) {
$size = (int)$size;
$size = (int)$size;
Line 237: Line 256:
}
}
?>
?>
-
 
-
 
</pre>
</pre>

Please note that all contributions to OMwiki are considered to be released under the Attribution 3.0 U.S (see OMwiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!


Cancel | Editing help (opens in new window)

All videos and text are published under the CC-BY 3.0 U. S. or CC-BY-SA 3.0. copyright licenses.  Details.