1,411
edits
Progress Continues
We've already had 21646 updates since Dolphin 5.0. Keep up with Dolphin's continuing progress through the Dolphin Blog: February, March, and April 2024 Dolphin Progress Report. |
The Dolphin Emulator Wiki needs your help! Dolphin can play thousands of games, and changes are happening all the time. Help us keep up! Join in and help us make this the best resource for Dolphin. |
(Revised test regexps+code to: trim whitespace around params; appropriately handle optional parameters (please double check, I didn't test my recodes and it's been a while since I've written perl)) |
m (Script update -- version 1.01 (see Version History)) |
||
Line 17: | Line 17: | ||
--[[User:Keller999|Keller999]] 13:15, 18 August 2011 (CEST) | --[[User:Keller999|Keller999]] 13:15, 18 August 2011 (CEST) | ||
====dolphinpageupdate.pl==== | ====dolphinpageupdate.pl==== | ||
Runs great on my Linux box, uses no special modules. I know for a fact that system('clear') does NOT work in Windows, but you could probably replace it with system('cls') and get the same effect. | Runs great on my Linux box, uses no special modules. I know for a fact that system('clear') does NOT work in Windows, but you could probably replace it with system('cls') and get the same effect. | ||
====Version History==== | |||
'''''1.0''''' | |||
* Initial release | |||
'''''1.01''''' | |||
* Image is now always parsed, and will set the size based on platforms detected. Defaults to Wii (300px) | |||
* If no Wikipedia Infobox is supplied, re-use the one from the Dolphin wiki page | |||
* If no Infobox is supplied at all, generate a generic one | |||
* Better supports not providing information (for example, if you don't supply a Wikipedia entry, the description from the Dolphin page will be reused) | |||
* Added shortcut to just generate a generic template | |||
<pre> | <pre> | ||
#!/usr/bin/perl | #!/usr/bin/perl | ||
my (@wikipedia, @originalPage); | my (@wikipedia, @originalPage); | ||
my (@problemSection, @configurationSection, @versionCompatSection, @testingSection, @videoSection, @categorySection); | my (@infoboxSection, @descriptionSection, @problemSection, @configurationSection, @versionCompatSection, @testingSection, @videoSection, @categorySection); | ||
my @finalResult; | my @finalResult; | ||
$imageSize = 300; | $imageSize = 300; # Assuming Wii by default | ||
my ($ | my ($image, $savedSizeLine); | ||
####### | ####### | ||
Line 37: | Line 50: | ||
print "*********************************\n"; | print "*********************************\n"; | ||
print "* Dolphin Wiki Page Update v1. | print "* Dolphin Wiki Page Update v1.01 *\n"; | ||
print "*********************************\n\n"; | print "*********************************\n\n"; | ||
print "First, copy and paste the game's Wikipedia article from the top to wherever you'd like to end the new description. Enter \'-1\' to indicate the end.\n\n"; | print "First, copy and paste the game's Wikipedia article from the top to wherever you'd like to end the new description. Zero input is fine. Enter \'-1\' to indicate the end, or -2 to just get a blank template.\n\n"; | ||
# Wikipedia input | # Wikipedia input | ||
while ($line ne "-1") { | while (($line ne "-1") and ($line ne "-2")) { | ||
$line = <STDIN>; | $line = <STDIN>; | ||
chomp($line); | chomp($line); | ||
if (($line ne "-1") and ($line ne "")) { | if (($line ne "-1") and ($line ne "") and ($line ne "-2")) { | ||
push (@wikipedia,$line); | push (@wikipedia,$line); | ||
} | } | ||
} | } | ||
$line = ""; | if ($line eq "-2") { | ||
$line = "-1"; | |||
} else { | |||
$line = ""; | |||
} | |||
system('clear'); | system('clear'); | ||
Line 60: | Line 77: | ||
print "*********************************\n\n"; | print "*********************************\n\n"; | ||
print "Now, copy and paste the existing Dolphin wiki article to import existing information. | print "Now, copy and paste the existing Dolphin wiki article to import existing information. Zero input is fine. Enter \'-1\' to indicate the end.\n\n"; | ||
# Dolphin page input | # Dolphin page input | ||
Line 76: | Line 93: | ||
############################# | ############################# | ||
# (@problemSection, @configurationSection, @versionCompatSection, @testingSection, @videoSection, @categorySection); | # (@infoboxSection, @descriptionSection, @problemSection, @configurationSection, @versionCompatSection, @testingSection, @videoSection, @categorySection); | ||
$currentSection = "none"; | $currentSection = "none"; | ||
$foundDolphinInfobox = 0; | |||
foreach (@originalArticle) { | foreach (@originalArticle) { | ||
Line 83: | Line 101: | ||
$checkLine = $_; | $checkLine = $_; | ||
if ($newLine =~ /^\ *\={1,4}\ *Problems\ *\=*$/i) { $currentSection = "problems"; } | if ($newLine =~ /^\{\{\ *Infobox.*/i) { $currentSection = "infobox"; $foundDolphinInfobox = 1; } | ||
elsif ($newLine =~ /^\ *\={1,4}\ *Problems\ *\=*$/i) { $currentSection = "problems"; } | |||
elsif ($newLine =~ /^\ *\={1,4}\ *Configuration\ *\=*$/i) { $currentSection = "configuration"; } | elsif ($newLine =~ /^\ *\={1,4}\ *Configuration\ *\=*$/i) { $currentSection = "configuration"; } | ||
elsif ($newLine =~ /^\ *\={1,4}\ *Version Compatibility\ *\=*$/i) { $currentSection = "versionCompat"; } | elsif ($newLine =~ /^\ *\={1,4}\ *Version Compatibility\ *\=*$/i) { $currentSection = "versionCompat"; } | ||
Line 91: | Line 110: | ||
elsif ($newLine =~ /^\ *\{\{Navigation\ .*\}\}$/i) { $currentSection = "categories"; } | elsif ($newLine =~ /^\ *\{\{Navigation\ .*\}\}$/i) { $currentSection = "categories"; } | ||
if ($currentSection eq " | if ($currentSection eq "infobox") { | ||
# | if ($newLine =~ /^\{\{\ *Infobox.*/i) { # This is the start of the Infobox, ignore | ||
# | # ignore | ||
} elsif ($newLine =~ /^\}\}$/) { # This is the end of the Infobox, change section and ignore | |||
$currentSection = "description"; | |||
} else { # We want to keep anything else in the infobox. This is in case the user didn't give us a wikipedia article to generate a new one from | |||
push (@infoboxSection, $newLine); | |||
# Now we save the image filename and size to be added onto wikipedia's infobox, if its provided | |||
if ($newLine =~ /^\|\ *image\ *=\ *.+/gi) { | |||
$image = $newLine; | |||
# just keep the filename, and format | |||
$image =~ s/\|image\ *\=\ *\[\[(?:File|Image)\ *\:\ *(.*?)(?:\||\]).*/$1/i; # | |||
} elsif ($newLine =~ /^\|\ *size\ *=\ *.+/gi) { | |||
$savedSizeLine = $newLine; # saved for later | |||
} | |||
} | } | ||
} elsif ($currentSection eq "description") { | |||
# We're pretty much going to assume that if it's in this section, we want to keep it all as-is | |||
push (@descriptionSection, $newLine); | |||
} elsif ($currentSection eq "problems") { | } elsif ($currentSection eq "problems") { | ||
if ($newLine =~ /^\ *\={1,4}\ *Problems\ *\=*$/i) { # Matches the section heading, ignore | if ($newLine =~ /^\ *\={1,4}\ *Problems\ *\=*$/i) { # Matches the section heading, ignore | ||
Line 144: | Line 175: | ||
###################### | ###################### | ||
$ | $foundWikipediaInfobox = 0; | ||
$insideInfobox = 0; | $insideInfobox = 0; | ||
my @autoCategory; | my @autoCategory; | ||
system('clear'); | system('clear'); | ||
Line 164: | Line 192: | ||
if ($newLine =~ /^\{\{\ *Infobox.*/i) { | if ($newLine =~ /^\{\{\ *Infobox.*/i) { | ||
push (@finalResult, '{{Infobox VG'); | push (@finalResult, '{{Infobox VG'); | ||
$ | $foundWikipediaInfobox = 1; | ||
$insideInfobox = 1; | $insideInfobox = 1; | ||
$skip = 1; | $skip = 1; | ||
Line 177: | Line 205: | ||
push (@autoCategory, "[[Category:Wii games]]"); | push (@autoCategory, "[[Category:Wii games]]"); | ||
$platformAltered = 1; | $platformAltered = 1; | ||
$imageSize = 300; | |||
} | } | ||
Line 184: | Line 213: | ||
push (@autoCategory, "[[Category:GameCube games]]"); | push (@autoCategory, "[[Category:GameCube games]]"); | ||
$platformAltered = 1; | $platformAltered = 1; | ||
$imageSize = 300; | |||
} | } | ||
Line 191: | Line 221: | ||
push (@autoCategory, "[[Category:WiiWare games]]"); | push (@autoCategory, "[[Category:WiiWare games]]"); | ||
$platformAltered = 1; | $platformAltered = 1; | ||
$imageSize = 175; | |||
} | } | ||
Line 198: | Line 229: | ||
push (@autoCategory, "[[Category:Triforce games]]"); | push (@autoCategory, "[[Category:Triforce games]]"); | ||
$platformAltered = 1; | $platformAltered = 1; | ||
$imageSize = 300; | |||
} | } | ||
Line 207: | Line 239: | ||
#Purge un-used parameters | #Purge un-used parameters | ||
if ($insideInfobox) { | if ($insideInfobox) { | ||
#Replace whatever title Wikipedia is using with our own | |||
# | if ($newLine =~ /^\|\ *title\ *=\ *.+/gi) { | ||
if | $newLine = '|title = {{SUBPAGENAME}}'; | ||
$ | |||
} | } | ||
if ($newLine =~ /^\|\ *(title|developer|publisher|distributor|director|producer|designer|programmer|artist|composer|license|series|engine|resolution|released|genre|mode|ratings|input|size|fps|dspcode|dtkadpcm|channeltype | if ($newLine =~ /^\|\ *(title|developer|publisher|distributor|director|producer|designer|programmer|artist|composer|license|series|engine|resolution|released|genre|mode|ratings|input|size|fps|dspcode|dtkadpcm|channeltype|mode|modes)\ *=\ *.+/gi) { | ||
$skip = 0; | $skip = 0; | ||
} else { | } else { | ||
Line 225: | Line 254: | ||
if ($skipUnWiki eq 0) { | if ($skipUnWiki eq 0) { | ||
$newLine =~ s/\<ref.+?\/.{0,3}\>//gi; # remove citations references | $newLine =~ s/\<ref.+?\/.{0,3}\>//gi; # remove citations references | ||
$newLine =~ s/\{\{vgy\|([0-9]{4})\}\}/$1/gi; # we don't do Template:vgy, removing | |||
$newLine =~ s/\{\{cite.*?\}\}//gi; # remove references | $newLine =~ s/\{\{cite.*?\}\}//gi; # remove references | ||
$newLine =~ s/\[\[(([.]|[^\|])+?)\]\]/$1/g; # un-wiki-fy wiki links in the format [[link]] | $newLine =~ s/\[\[(([.]|[^\|])+?)\]\]/$1/g; # un-wiki-fy wiki links in the format [[link]] | ||
Line 236: | Line 266: | ||
@genres = split (/\,|\<br.*?\>/,$genreLine); | @genres = split (/\,|\<br.*?\>/,$genreLine); | ||
foreach (@genres) { | foreach (@genres) { | ||
if (@autoCategory eq 0) { | |||
push (@autoCategory, '<!-- Categories below this line were automatically generated -->'); | |||
} | |||
$line = $_; | $line = $_; | ||
$line =~ s/^\ *//; | $line =~ s/^\ *//; | ||
Line 249: | Line 282: | ||
@modes = split (/\,|\<br.*?\>/,$modeLine); | @modes = split (/\,|\<br.*?\>/,$modeLine); | ||
foreach (@modes) { | foreach (@modes) { | ||
if (@autoCategory eq 0) { | |||
push (@autoCategory, '<!-- Categories below this line were automatically generated -->'); | |||
} | |||
$line = $_; | $line = $_; | ||
$line =~ s/^\ *//; | $line =~ s/^\ *//; | ||
Line 259: | Line 295: | ||
if ($newLine =~ /^\}\}$/) { | if ($newLine =~ /^\}\}$/) { | ||
if ($savedSizeLine ne "") { push (@finalResult, $savedSizeLine); } # Saved size | if ($savedSizeLine ne "") { push (@finalResult, $savedSizeLine); } # Saved size | ||
if | if ($image ne "") { # Saved image line | ||
push (@finalResult, $ | push (@finalResult, '|image = [[File:' . $image . '|' . $imageSize . 'px]]'); | ||
} elsif | } elsif ($image eq "") { | ||
push (@finalResult, '|image = [[File:{{SUBPAGENAME}}.png|' . $imageSize . 'px]]'); | push (@finalResult, '|image = [[File:{{SUBPAGENAME}}.png|' . $imageSize . 'px]]'); | ||
} | } | ||
push (@finalResult, $newLine); | push (@finalResult, $newLine); | ||
Line 272: | Line 307: | ||
} | } | ||
if (($ | if (($foundWikipediaInfobox eq 1) and ($skip eq 0)) { | ||
push (@finalResult,$newLine); | push (@finalResult,$newLine); | ||
} | } | ||
Line 283: | Line 318: | ||
# At this point, the Infobox and the summary are in place. Now, time to add our checked and re-formatted content sections. | # At this point, the Infobox and the summary are in place. Now, time to add our checked and re-formatted content sections. | ||
# CATEOGRY PROCESSING | |||
# Need to combine our categories and make sure there are no duplicates | # Need to combine our categories and make sure there are no duplicates | ||
foreach (@autoCategory) { | foreach (@autoCategory) { | ||
Line 311: | Line 347: | ||
} | } | ||
# | #INFOBOX PROCESSING | ||
if (($foundWikipediaInfobox eq 1) and ($foundDolphinInfobox eq 1)) { | |||
# If a Wikipedia Infobox was received, it was already pushed into @finalResult. | |||
# TODO: Wikipedia parsing should push into its own array, which is then added in this section | |||
} elsif (($foundWikipediaInfobox eq 0) and ($foundDolphinInfobox eq 1)) { # We didn't get a Wikipedia Infobox, so use the one from Dolphin | |||
push (@finalResult, '{{Infobox VG'); | |||
push (@finalResult, @infoboxSection); | |||
push (@finalResult, '}}'); | |||
} elsif (($foundWikipediaInfobox eq 0) and ($foundDolphinInfobox eq 0)) { # We didn't get ANY infoboxes, create a generic one | |||
push (@finalResult, '{{Infobox VG'); | |||
push (@finalResult, '|title = {{SUBPAGENAME}}'); | |||
push (@finalResult, '|image = [[File:{{SUBPAGENAME}}.png|'); | |||
push (@finalResult, '}}'); | |||
} | |||
#DESCRIPTION PROCESSING | |||
if ((@descriptionSection) and ($foundWikipediaInfobox eq 0)) { # Only re-use the original description if there was one and we didn't get Wikipedia data | |||
push (@finalResult, "\n"); | |||
push (@finalResult, @descriptionSection); | |||
} | |||
push (@finalResult, "\n\=\= Problems \=\="); | push (@finalResult, "\n\=\= Problems \=\="); | ||
push (@finalResult, @problemSection); | push (@finalResult, @problemSection); | ||
Line 353: | Line 409: | ||
print $_ . "\n"; | print $_ . "\n"; | ||
} | } | ||
print "\n\n"; | |||
</pre> | </pre> |
edits