Changeset 2388
- Timestamp:
- 01/07/08 00:20:39 (11 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
Trunk/Scripts/Mirroring_scripts/WebGUIForumUpdate.pm
r2386 r2388 32 32 #################################################################### 33 33 my $LoginURL ='http://www.scout.org'; 34 my $UploadURL ='http://www.scout.org/home/downloads/audio/model-repository/audio-speech-files';35 my $RepositoryURL ='http://www.repository.voxforge1.org/downloads/SpeechCorpus/Trunk/Audio/Original';36 34 my $command; 37 35 #################################################################### … … 40 38 sub Main { 41 39 my ($parms,%ProcessedUserSubmissions) = @_; 42 my $debug = $$parms{"debug"}; 40 my $debug = $$parms{"debug"}; 41 42 my $counter; 43 43 44 Login($parms); 44 45 foreach my $AudioDirName (keys %ProcessedUserSubmissions) { 46 $counter++; 47 print "$counter. $AudioDirName ==============================================\n"; 45 48 my $path_original = $ProcessedUserSubmissions{$AudioDirName}; 46 49 print STDERR "Update Forum with AudioDirName:$path_original/$AudioDirName\n" if $debug; 47 my ($content,$title)= getContentsofZipFile($parms,$path_original, $AudioDirName); 48 Upload($parms,$content,$title); 50 my ($content,$title,$language,$AudioRecordingSoftware)= getContentsofZipFile($parms,$path_original, $AudioDirName); 51 if ($AudioRecordingSoftware =~ /VoxForge Speech Submission Application/) { 52 Upload($parms,$content,$title,$language); 53 } 54 49 55 } 50 56 $command = ("rm my_cookies.txt"); print "$command\n" if $debug;system($command) == 0 or die "system $command failed: $?"; … … 54 60 ### Subroutines 55 61 #################################################################### 62 sub getUploadURL { 63 my ($parms,$language) = @_; 64 my $debug = $$parms{"debug"}; 65 my $UploadURL; 66 67 if ($$language =~ /EN/) { 68 $UploadURL ='http://www.scout.org/home/downloads/audio/model-repository/audio-speech-files'; 69 } elsif ($$language =~ /NL/) { 70 $UploadURL ='http://www.scout.org/home/downloads/speech/dutch'; 71 } else { 72 $UploadURL ='http://www.scout.org/home/downloads/audio/model-repository/audio-speech-files'; 73 } 74 return $UploadURL; 75 } 76 56 77 sub getContentsofZipFile() { 57 78 my ($parms,$path_original, $AudioDirName) = @_; 58 79 my $debug = $$parms{"debug"}; 59 80 60 my ($content, @readme, @prompts, @license );81 my ($content, @readme, @prompts, @license,$AudioRecordingSoftware,$language,$RepositoryURL); 61 82 my $title=$AudioDirName; 62 83 print STDERR "Extracting :$path_original/$AudioDirName\n" if $debug; … … 64 85 if ( $ae->extract( to => "$AudioDirName-temp" ) ) { 65 86 open(README, "<$AudioDirName-temp/readme.txt") or confess ("can't find readme.txt"); 66 @readme = <README>; 87 @readme = <README>; 88 foreach my $line (@readme) { 89 if ($line =~ /Language: /) { 90 $language = $line; 91 $language =~ s/Language: //; 92 } elsif ($line =~ /Audio Recording Software: /) { 93 $AudioRecordingSoftware = $line; 94 $AudioRecordingSoftware =~ s/Audio Recording Software: //; 95 } 96 } 97 $RepositoryURL = getRepositoryURL($parms,$language); 67 98 open(PROMPTS, "<$AudioDirName-temp/prompts.txt") or confess ("can't find prompts.txt"); 68 99 @prompts = <PROMPTS>; … … 79 110 $content .= join(" ", @license); 80 111 $content =~ s/\n/<br>\n/g; 81 $content =~ s/WARRANTY;/WARRANTY,/; # WebGUI does not like CAPITAL S followed by semi-colons...?112 $content =~ s/WARRANTY;/WARRANTY,/; # WebGUI does not like CAPITAL LETTERS followed by a semi-colon ...? 82 113 $content =~ s|<http://www.gnu.org/licenses/>|http://www.gnu.org/licenses/|; # more WebGUI arcana 83 114 $content .= "<br><img src=\"http://www.repository.voxforge1.org/spicons/compressed.gif\">"; 84 $content .= "<a href=\"$RepositoryURL/48kHz_16bit/$title.tgz\">$title.tgz</a><br>"; 85 # $content = join(" ", 86 # @readme, 87 # "<h2>Prompts:</h2>", @prompts, 88 # "<h2>License:</h2>", @license, 89 # "<br> <img src=\"http://www.repository.voxforge1.org/spicons/compressed.gif\" alt=\"[ ]\" border=\"0\">", 90 # "<a href=\"http://www.repository.voxforge1.org/downloads/SpeechCorpus/Trunk/Audio/Original/48kHz_16bit/$title.tgz\">$title.tgz</a><br>" 91 # ); 92 93 print $content; 94 return (\$content,\$title); 115 $content .= "<a href=\"$RepositoryURL/$title.tgz\">$title.tgz</a><br>"; 116 return (\$content,\$title,\$language,$AudioRecordingSoftware); 117 } 118 119 sub getRepositoryURL { 120 my ($parms,$language) = @_; 121 my $debug = $$parms{"debug"}; 122 123 my $RepositoryURL; 124 125 if ($language =~ /EN/) { 126 $RepositoryURL ='http://www.repository.voxforge1.org/downloads/SpeechCorpus/Trunk/Audio/Original/48kHz_16bit'; 127 } elsif ($language =~ /NL/) { 128 $RepositoryURL = "WARNING: Dutch submissions not set up yet in Repository yet!\n"; 129 print "WARNING: Dutch submissions not set up yet in Repository yet!\n"; 130 } else { 131 $RepositoryURL ='http://www.repository.voxforge1.org/downloads/SpeechCorpus/Trunk/Audio/Original/48kHz_16bit'; 132 } 133 return $RepositoryURL; 95 134 } 96 135 … … 129 168 # print "\n\nresult:\n$result\n"; 130 169 } 131 print "==============================================\n";132 170 } 133 171 … … 143 181 144 182 sub Upload { 145 my ($parms,$content,$title ) = @_;183 my ($parms,$content,$title,$language) = @_; 146 184 my $debug = $$parms{"debug"}; 147 185 148 186 my ($result, $err); 149 187 my $post = "func=editSave;assetId=new;class=WebGUI::Asset::Post::Thread;proceed=showConfirmation;title=$$title;content=$$content;contentType=text,subscribe=1;submit=save"; 188 my $UploadURL = getUploadURL($parms,$language); 150 189 151 190 my $curl = new WWW::Curl::Easy; … … 175 214 print "info: $curl->getinfo(CURLINFO_HTTP_CODE\n"; 176 215 } 216 177 217 } 178 218