User:Keller999/projects/gamepageupdate: Difference between revisions

From Dolphin Emulator Wiki
Jump to navigation Jump to search
No edit summary
(New game page processing script, NEED YOUR INPUT!)
Line 8: Line 8:


===Scripts===
===Scripts===
Takes a Wikipedia Infobox and first paragraph and turns it into an acceptable format for our wikiPaste in the info from Wikipedia, then enter -1 to show that you're done. Still requires a little bit of manual eye-balling for other system's information, but greatly speeds the whole processAlso removes platforms that aren't in Dolphin, removes all references, citations, and wiki brackets.
Hooray for programming mini-project!  I put together a script that takes the Infobox and summary from Wikipedia, then the existing Dolphin Wiki article, and creates a standards-compliant merge of the two.  For an example of what this script does, please see [[Call of Duty: Black Ops/sandbox]].  Revision 23655 is before, Revision 23677 is afterI did NOT do any additional touchup between these revs, as I wanted to show exactly what the script was doing.
 
I have updated the page to match what I believe to be current standard.  I intend to start running this script for many pages starting tomorrow evening, so PLEASE review the newest revision of [[Call of Duty: Black Ops/sandbox]] to ensure that I'm not missing anything! I would hate to do a bunch of mass changes and then have to go repair them all.
 
Also, expect this script to have a bug or two until I can get it working and find out the issues with it.
 
Let me know your thoughts!
 
--[[User:Keller999|Keller999]] 13:15, 18 August 2011 (CEST)
 
====dolphinpageupdate.pl====
Runs great on my Linux box, uses no special modulesI 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.
<pre>
<pre>
#!/usr/bin/perl
#!/usr/bin/perl


my $line;
my (@wikipedia, @originalPage);
my @devices;
my (@problemSection, @configurationSection, @versionCompatSection, @testingSection, @videoSection, @categorySection);
my @finalResult;
 
my ($savedImageLine, $savedSizeLine);


my $imageLine;
#######
#INPUT#
#######
system('clear');


if (($#ARGV + 1) eq 1) {
print "*********************************\n";
         $imageLine = $ARGV[0];
print "* Dolphin Wiki Page Update v1.0 *\n";
$imageLine =~ s/\ {2,}/\ /g;
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";
 
# Wikipedia input
while ($line ne "-1") {
         $line = <STDIN>;
        chomp($line);
 
        if (($line ne "-1") and ($line ne "")) {
                push (@wikipedia,$line);
        }
}
}
$line = "";


system('clear');
system('clear');


print "*********************************\n";
print "* Dolphin Wiki Page Update v1.0 *\n";
print "*********************************\n\n";
print "Now, copy and paste the existing Dolphin wiki article to import existing information.  No input is fine.  Enter \'-1\' to indicate the end.\n\n";
# Dolphin page input
while ($line ne "-1") {
while ($line ne "-1") {
         $line = <STDIN>;
         $line = <STDIN>;
Line 29: Line 66:


         if (($line ne "-1") and ($line ne "")) {
         if (($line ne "-1") and ($line ne "")) {
                 push (@devices,$line);
                 push (@originalArticle,$line);
         }
         }
}
}
#############################
#EXISTING ARTICLE PROCESSING#
#############################
# (@problemSection, @configurationSection, @versionCompatSection, @testingSection, @videoSection, @categorySection);
$currentSection = "none";
foreach (@originalArticle) {
$newLine = $_;
$checkLine = $_;
if ($newLine =~ /^\ *\={1,4}\ *Problems\ *\=*$/i) { $currentSection = "problems"; }
elsif ($newLine =~ /^\ *\={1,4}\ *Configuration\ *\=*$/i) { $currentSection = "configuration"; }
elsif ($newLine =~ /^\ *\={1,4}\ *Version Compatibility\ *\=*$/i) { $currentSection = "versionCompat"; }
elsif ($newLine =~ /^\ *\={1,4}\ *Testing\ *\=*$/i) { $currentSection = "testing"; }
elsif ($newLine =~ /^\ *\={1,4}\ *.*Videos\ *\=*$/i) { $currentSection = "videos"; }
elsif ($newLine =~ /^\ *\[\[Category\:.*\]\]$/i) { $currentSection = "categories"; }
elsif ($newLine =~ /^\ *\{\{Navigation\ .*\}\}$/i) { $currentSection = "categories"; }
if ($currentSection eq "none") {
# Information is outside of the defined sections, and is purged.  Infobox/summary will be re-generated from Wikipedia
# The ONLY two exceptions are the image (which we prefer over the Wikipedia image name) and the size
if ($newLine =~ /^\|\ *image\ *=\ *.+/gi) {
$savedImageLine = $newLine; # saved for later
} elsif ($newLine =~ /^\|\ *size\ *=\ *.+/gi) {
$savedSizeLine = $newLine; # saved for later
}
} elsif ($currentSection eq "problems") {
if ($newLine =~ /^\ *\={1,4}\ *Problems\ *\=*$/i) {  # Matches the section heading, ignore
# ignore
} elsif ($newLine =~ /^\ *\={1,4}\ *(.*?)\ *\=*\ *$/gm) {  # This is a sub-heading.  Reformat it
push (@problemSection, "\=\=\= $1 \=\=\=");
} else {  # This is something else in the problem section, like user input.  Keep it
push (@problemSection, $newLine);
}
} elsif ($currentSection eq "configuration") {
if ($newLine =~ /\|\ *.*\=\ *\S+.*$/gi) {  # This is a config entry that has been filled out
push (@configurationSection, $newLine);
} # Anything besides filled-out config params are not needed, the rest will be regenerated
} elsif ($currentSection eq "versionCompat") {
if ($newLine =~ /^\{\{VersionCompatibilityVersion\|.+\|.+\}\}$/gi) {  # Version compat report that's been filled out
push (@versionCompatSection, $newLine);
} # Anything besides filled-out compat reports are not needed, the rest will be regenerated
} elsif ($currentSection eq "testing") {
if ($newLine =~ /^\{\{.+?\|revision\=(.*?)\|os\=(.*?)\|cpu\=(.*?)\|gpu\=(.*?)\|result\=(.*?)\|tester\=(.*?)\}\}/i) {
# Matches test reports with all variables set (tester is optional) and dissects for reassembly (muahahaha!)
$testResult = "\{\{testing\/entry\|revision\=$1\|OS\=$2\|CPU\=$3\|GPU\=$4\|result\=$5\|tester\=$6\}\}";
push (@testingSection, $testResult);
}
} elsif ($currentSection eq "videos") {
if ($newLine =~ /^\ *\={1,4}\ *.*Videos\ *\=*$/i) {  # Matches the section heading, ignore
# ignore
} else {  # Keep everything else
push (@videoSection, $newLine);
}
} elsif ($currentSection eq "categories") {  # We keep all existing categories, and add some new auto-generated ones!
if ($newLine =~ /^\[\[Category\:\ *(.*)\ *\]\]/i) {  # This is a category entry
push (@categorySection, "\[\[Category:" . $1 . "\]\]");
} elsif ($newLine =~ /^\{\{Navigation\ *(.*)\ *\}\}/i) {  # This is a navigation entry
push (@categorySection, "\{\{Navigation " . $1 . "\}\}");
}
}
}
######################
#WIKIPEDIA PROCESSING#
######################


$foundInfobox = 0;
$foundInfobox = 0;
my $categories;
$foundImage = 0;
 
my @autoCategory;
 
push (@autoCategory, '<!-- Categories below this line were automatically generated -->');


system('clear');
system('clear');


foreach (@devices) {
foreach (@wikipedia) {
$newLine = $_;
$newLine = $_;


Line 44: Line 154:
$platformAltered = 0;
$platformAltered = 0;
$skip = 0;
$skip = 0;
$skipUnWiki = 0;


if ($newLine =~ /^\{\{\ *Infobox.*/gi) {
if ($newLine =~ /^\{\{\ *Infobox.*/gi) {
Line 52: Line 163:
#Platforms
#Platforms
if ($newLine =~ /\|\ *platforms/gi) {
if ($newLine =~ /\|\ *platforms/gi) {
#Wii
#Wii
if ($newLine =~ /.*Wii.*/i) {
if ($newLine =~ /.*Wii.*/i) {
$platforms .= '[[Wii]] ';
$platforms .= '[[Wii]] ';
$categories .= "[[Category:Wii games]]\n";
push (@autoCategory, "[[Category:Wii games]]");
$platformAltered = 1;
$platformAltered = 1;
}
}
Line 63: Line 173:
                 if ($newLine =~ /GameCube/i) {
                 if ($newLine =~ /GameCube/i) {
$platforms .= '[[GameCube]] ';
$platforms .= '[[GameCube]] ';
$categories .= "[[Category:GameCube games]]\n";
push (@autoCategory, "[[Category:GameCube games]]");
$platformAltered = 1;
$platformAltered = 1;
      }
      }
Line 70: Line 180:
                 if ($newLine =~ /WiiWare/i) {
                 if ($newLine =~ /WiiWare/i) {
               $platforms .= '[[WiiWare]] ';
               $platforms .= '[[WiiWare]] ';
$categories .= "[[Category:WiiWare games]]\n";
push (@autoCategory, "[[Category:WiiWare games]]");
$platformAltered = 1;
$platformAltered = 1;
       }
       }
Line 77: Line 187:
                 if ($newLine =~ /TriForce/i) {
                 if ($newLine =~ /TriForce/i) {
               $platforms .= '[[Triforce]] ';
               $platforms .= '[[Triforce]] ';
$categories .= "[[Category:Triforce games]]\n";
push (@autoCategory, "[[Category:Triforce games]]");
$platformAltered = 1;
$platformAltered = 1;
         }
         }
push (@finalResult,$platforms);
$skip = 1;
$skipUnWiki = 1;
}
}


#Purge un-used parameters
#Purge un-used parameters
if ($newLine =~ /^\|/) {
if ($newLine =~ /^\|/) {
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|image|mode|modes)\ *=\ * .+/gi) {
#If there was already an image listed in the original page, keep it
if ($newLine =~ /^\|\ *image\ *=\ *.+/gi) {
$foundImage = 1;
$skipUnWiki = 1;
$newLine = $savedImageLine;
}
 
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|image|mode|modes)\ *=\ *.+/gi) {
$skip = 0;
$skip = 0;
} else {
} else {
$skip = 1;
$skip = 1;
}
}
}
#Replace image name, if necessary
if (($newLine =~ /^\|\ *image/) and ($imageLine ne "")) {
$skip = 1;
print "$imageLine\n";
}
}


#Un-wiki-fy everything
#Un-wiki-fy everything
         if (($newLine =~ /^\|\ *image/ eq "") and ($platformAltered 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/\{\{cite.*?\}\}//gi; # remove references
$newLine =~ s/\{\{cite.*?\}\}//gi; # remove references
Line 110: Line 225:
$genreLine = $newLine;
$genreLine = $newLine;
$genreLine =~ s/^\|\ *genre\ *\=\ *//i;
$genreLine =~ s/^\|\ *genre\ *\=\ *//i;
@genres = split (/\,/,$genreLine);
@genres = split (/\,|\<br.*?\>/,$genreLine);
foreach (@genres) {
foreach (@genres) {
$line = $_;
$line = $_;
$line =~ s/^\ *//;
$line =~ s/^\ *//;
$line =~ s/\ +$//;
$line =~ s/\ +$//;
$categories .= "\[\[Category:" . $line . " games\]\]\n";
push (@autoCategory, "\[\[Category:" . $line . " games\]\]");
}
}
}
}
#Set mode categories
#Set mode categories
if ($newLine =~ /^\|\ *mode/ ne "") {
$modeLine = $newLine;
$modeLine =~ s/^\|\ *modes{0,1}\ *\=\ *//i;
@modes = split (/\,|\<br.*?\>/,$modeLine);
foreach (@modes) {
$line = $_;
$line =~ s/^\ *//;
$line =~ s/\ +$//;
push (@autoCategory, "\[\[Category:" . $line . " games\]\]");
}
}


if ($foundInfobox eq 1) {
#New-line if this is the end of the Infobox
if (($platformAltered eq 0) and ($skip eq 0)) {
if ($newLine =~ /^\}\}$/) {
print $newLine . "\n";
if ($savedSizeLine ne "") { push (@finalResult, $savedSizeLine); }  # Saved size
} elsif ($platformAltered eq 1) {
if (($foundImage eq 0) and ($savedImageLine ne "")) { push (@finalResult, $savedImageLine); } # Saved image line, if wikipedia doesn't have one
print $platforms . "\n";
 
}
push (@finalResult, $newLine);
push (@finalResult, " ");
$skip = 1;
}
 
if (($foundInfobox eq 1) and ($skip eq 0)) {
push (@finalResult,$newLine);
}
}
}
}


print "\n\n\n";
######################
#COMPILE FINAL RESULT#
######################


print $categories;
# At this point, the Infobox and the summary are in place.  Now, time to add our checked and re-formatted content sections.


print "\n\n\n";
# Need to combine our categories and make sure there are no duplicates
</pre>
foreach (@autoCategory) {
$fullCat = $_;
my $shortCat;
$dupe = 0;


Script that takes existing [[Template:test entry]] entries and converts them to [[Template:testing/entry]] entries.
if (($fullCat =~ /^\[\[Category\:\ *(.*)\ *\]\]/i) or ($fullCat =~ /^\{\{Navigation\ *(.*)\ *\}\}/i)) {
<pre>
$shortCat = $1;
#!/usr/bin/perl
}


my $line;
foreach (@categorySection) {
my @input;
$compareCatLong = $_;
my @result;
my $compareCatShort;


system('clear');
if (($compareCatLong =~ /^\[\[Category\:\ *(.*)\ *\]\]/i) or ($compareCatLong =~ /^\{\{Navigation\ *(.*)\ *\}\}/i)) {
$compareCatShort = $1;
}


while ($line ne "-1") {
if ($compareCatShort eq $shortCat) {
        $line = <STDIN>;
$dupe = 1;
        chomp($line);
}
}


        if (($line ne "-1") and ($line ne "")) {
if ($dupe eq 0) {
                push (@input,$line);
push (@categorySection, $_);
        }
}
}
}


push (@result, "\=\= Testing \=\=");
# Problem Section
push (@result, "\{\{testing\/start\}\}");
push (@finalResult, "\n\=\= Problems \=\=");
push (@result, "\<!--Use this template for test entries\: \{\{testing\/entry\|revision=\|OS=\|CPU=\|GPU=\|result=\|tester=\}\}-->");
push (@finalResult, @problemSection);
 
push (@finalResult, "\n\=\= Configuration \=\=");
push (@finalResult, '<!--A full list of options is available at Template:Config/doc-->');
push (@finalResult, "\{\{Config");
push (@finalResult, @configurationSection);
push (@finalResult, "\}\}");
 
push (@finalResult, "\n\=\= Version Compatibility \=\=");
push (@finalResult, "\{\{VersionCompatibility\}\}");
push (@finalResult, '<!--Use this template for compatibility entries: {{VersionCompatibilityVersion|3891|****}}-->');
push (@finalResult, @versionCompatSection);
push (@finalResult, "\{\{VersionCompatibilityClose\}\}");


system('clear');
push (@finalResult, "\n\=\= Testing \=\=");
push (@finalResult, "\{\{testing\/start\}\}");
push (@finalResult, '<!--Use this template for test entries: {{Test Entry|revision=|OS=|CPU=|GPU=|result=|tester=}}-->');
push (@finalResult, @testingSection);
push (@finalResult, "\{\{testing\/end\}\}");
 
push (@finalResult, "\n\=\= Gameplay Videos \=\=");
push (@finalResult, @videoSection);


foreach (@input) {
push (@finalResult, "\n");
$newLine = $_;
push (@finalResult, @categorySection);


$newLine =~ s/^\{\{test entry/\{\{testing\/entry/gi;


if ($newLine =~ /^\{\{testing\/entry/gi) {
##############
push (@result,  $newLine);
#FINAL OUTPUT#
}
##############


}
system ('clear');


push (@result, "\{\{testing\/end\}\}");
print "****************\n";
print "* FINAL OUTPUT *\n";
print "****************\n";


foreach (@result) {
foreach (@finalResult) {
print $_ . "\n";
print $_ . "\n";
}
}
</pre>
</pre>
I might need to combine all of this into one mega script that you can drop an existing page into and have it spit out a properly-formatted one...

Revision as of 11:15, 18 August 2011

I am working on doing several things for all existing game pages:

  • If it's not already in place, copy/paste a cleaned-up Infobox from Wikipedia into the game page
  • Update templates to use the most recent versions, rather than redirected versions
  • Ensure that all sections that need user updates have a template to copy-paste, or a link to further documentation
  • Update pages to conform to the standard game page -- Problems, Configuration, Version Compatibility, Testing, Gameplay Videos
  • Remove existing non-used config variables if they are present in the page

Scripts

Hooray for programming mini-project! I put together a script that takes the Infobox and summary from Wikipedia, then the existing Dolphin Wiki article, and creates a standards-compliant merge of the two. For an example of what this script does, please see Call of Duty: Black Ops/sandbox. Revision 23655 is before, Revision 23677 is after. I did NOT do any additional touchup between these revs, as I wanted to show exactly what the script was doing.

I have updated the page to match what I believe to be current standard. I intend to start running this script for many pages starting tomorrow evening, so PLEASE review the newest revision of Call of Duty: Black Ops/sandbox to ensure that I'm not missing anything! I would hate to do a bunch of mass changes and then have to go repair them all.

Also, expect this script to have a bug or two until I can get it working and find out the issues with it.

Let me know your thoughts!

--Keller999 13:15, 18 August 2011 (CEST)

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.

#!/usr/bin/perl

my (@wikipedia, @originalPage);
my (@problemSection, @configurationSection, @versionCompatSection, @testingSection, @videoSection, @categorySection);
my @finalResult;

my ($savedImageLine, $savedSizeLine);

#######
#INPUT#
#######
system('clear');

print "*********************************\n";
print "* Dolphin Wiki Page Update v1.0 *\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";

# Wikipedia input
while ($line ne "-1") {
        $line = <STDIN>;
        chomp($line);

        if (($line ne "-1") and ($line ne "")) {
                push (@wikipedia,$line);
        }
}

$line = "";

system('clear');

print "*********************************\n";
print "* Dolphin Wiki Page Update v1.0 *\n";
print "*********************************\n\n";

print "Now, copy and paste the existing Dolphin wiki article to import existing information.  No input is fine.  Enter \'-1\' to indicate the end.\n\n";

# Dolphin page input
while ($line ne "-1") {
        $line = <STDIN>;
        chomp($line);

        if (($line ne "-1") and ($line ne "")) {
                push (@originalArticle,$line);
        }
}

#############################
#EXISTING ARTICLE PROCESSING#
#############################

# (@problemSection, @configurationSection, @versionCompatSection, @testingSection, @videoSection, @categorySection);
$currentSection = "none";

foreach (@originalArticle) {
	$newLine = $_;
	$checkLine = $_;

	if ($newLine =~ /^\ *\={1,4}\ *Problems\ *\=*$/i) { $currentSection = "problems"; }
	elsif ($newLine =~ /^\ *\={1,4}\ *Configuration\ *\=*$/i) { $currentSection = "configuration"; }
	elsif ($newLine =~ /^\ *\={1,4}\ *Version Compatibility\ *\=*$/i) { $currentSection = "versionCompat"; }
	elsif ($newLine =~ /^\ *\={1,4}\ *Testing\ *\=*$/i) { $currentSection = "testing"; }
	elsif ($newLine =~ /^\ *\={1,4}\ *.*Videos\ *\=*$/i) { $currentSection = "videos"; }
	elsif ($newLine =~ /^\ *\[\[Category\:.*\]\]$/i) { $currentSection = "categories"; }
	elsif ($newLine =~ /^\ *\{\{Navigation\ .*\}\}$/i) { $currentSection = "categories"; }

	if ($currentSection eq "none") {
		# Information is outside of the defined sections, and is purged.  Infobox/summary will be re-generated from Wikipedia
		# The ONLY two exceptions are the image (which we prefer over the Wikipedia image name) and the size
		if ($newLine =~ /^\|\ *image\ *=\ *.+/gi) {
			$savedImageLine = $newLine; # saved for later
		} elsif ($newLine =~ /^\|\ *size\ *=\ *.+/gi) {
			$savedSizeLine = $newLine; # saved for later
		}
	} elsif ($currentSection eq "problems") {
		if ($newLine =~ /^\ *\={1,4}\ *Problems\ *\=*$/i) {   # Matches the section heading, ignore
			# ignore
		} elsif ($newLine =~ /^\ *\={1,4}\ *(.*?)\ *\=*\ *$/gm) {   # This is a sub-heading.  Reformat it
			push (@problemSection, "\=\=\= $1 \=\=\=");
		} else {   # This is something else in the problem section, like user input.  Keep it
			push (@problemSection, $newLine);
		}
	} elsif ($currentSection eq "configuration") {
		if ($newLine =~ /\|\ *.*\=\ *\S+.*$/gi) {   # This is a config entry that has been filled out
			push (@configurationSection, $newLine);
		} # Anything besides filled-out config params are not needed, the rest will be regenerated
	} elsif ($currentSection eq "versionCompat") {
		if ($newLine =~ /^\{\{VersionCompatibilityVersion\|.+\|.+\}\}$/gi) {   # Version compat report that's been filled out
			push (@versionCompatSection, $newLine);
		} # Anything besides filled-out compat reports are not needed, the rest will be regenerated
	} elsif ($currentSection eq "testing") {
		if ($newLine =~ /^\{\{.+?\|revision\=(.*?)\|os\=(.*?)\|cpu\=(.*?)\|gpu\=(.*?)\|result\=(.*?)\|tester\=(.*?)\}\}/i) {
			# Matches test reports with all variables set (tester is optional) and dissects for reassembly (muahahaha!)
			$testResult = "\{\{testing\/entry\|revision\=$1\|OS\=$2\|CPU\=$3\|GPU\=$4\|result\=$5\|tester\=$6\}\}";
			push (@testingSection, $testResult);
		}
	} elsif ($currentSection eq "videos") {
		if ($newLine =~ /^\ *\={1,4}\ *.*Videos\ *\=*$/i) {   # Matches the section heading, ignore
			# ignore
		} else {   # Keep everything else
			push (@videoSection, $newLine);
		}
	} elsif ($currentSection eq "categories") {   # We keep all existing categories, and add some new auto-generated ones!
		if ($newLine =~ /^\[\[Category\:\ *(.*)\ *\]\]/i) {   # This is a category entry
			push (@categorySection, "\[\[Category:" . $1 . "\]\]");
		} elsif ($newLine =~ /^\{\{Navigation\ *(.*)\ *\}\}/i) {   # This is a navigation entry
			push (@categorySection, "\{\{Navigation " . $1 . "\}\}");
		}
	}	
}


######################
#WIKIPEDIA PROCESSING#
######################

$foundInfobox = 0;
$foundImage = 0;

my @autoCategory;

push (@autoCategory, '<!-- Categories below this line were automatically generated -->');

system('clear');

foreach (@wikipedia) {
	$newLine = $_;

	$platforms  = "\|platforms \= ";
	$platformAltered = 0;
	$skip = 0;
	$skipUnWiki = 0;

	if ($newLine =~ /^\{\{\ *Infobox.*/gi) {
		$newLine =~ s/^\{\{\ *Infobox.*/\{\{Infobox\ VG/gi;
		$foundInfobox = 1;
	}

	#Platforms
	if ($newLine =~ /\|\ *platforms/gi) {
		#Wii
		if ($newLine =~ /.*Wii.*/i) {
			$platforms .= '[[Wii]] ';
			push (@autoCategory, "[[Category:Wii games]]");
			$platformAltered = 1;
		}			

		#GameCube
                if ($newLine =~ /GameCube/i) {
			$platforms .= '[[GameCube]] ';
			push (@autoCategory, "[[Category:GameCube games]]");
			$platformAltered = 1;
	       	 }	

		#WiiWare
                if ($newLine =~ /WiiWare/i) {
       	        	$platforms .= '[[WiiWare]] ';
			push (@autoCategory, "[[Category:WiiWare games]]");
			$platformAltered = 1;
       	 	}

		#TriForce
                if ($newLine =~ /TriForce/i) {
               		$platforms .= '[[Triforce]] ';
			push (@autoCategory, "[[Category:Triforce games]]");
			$platformAltered = 1;
        	}

		push (@finalResult,$platforms);
		$skip = 1;
		$skipUnWiki = 1;
	}

	#Purge un-used parameters
	if ($newLine =~ /^\|/) {
	
		#If there was already an image listed in the original page, keep it
		if ($newLine =~ /^\|\ *image\ *=\ *.+/gi) {
			$foundImage = 1;
			$skipUnWiki = 1;
			$newLine = $savedImageLine;		
		}

		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|image|mode|modes)\ *=\ *.+/gi) {
			$skip = 0;
		} else {
			$skip = 1;
		}
	}

	#Un-wiki-fy everything
        if ($skipUnWiki eq 0) {
		$newLine =~ s/\<ref.+?\/.{0,3}\>//gi; # remove citations 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|name]]
        }

	#Set genre categories
	if ($newLine =~ /^\|\ *genre/ ne "") {
		$genreLine = $newLine;
		$genreLine =~ s/^\|\ *genre\ *\=\ *//i;
		@genres = split (/\,|\<br.*?\>/,$genreLine);
		foreach (@genres) {
			$line = $_;
			$line =~ s/^\ *//;
			$line =~ s/\ +$//;
			push (@autoCategory, "\[\[Category:" . $line . " games\]\]");
		}
	}
	
	#Set mode categories
	if ($newLine =~ /^\|\ *mode/ ne "") {
		$modeLine = $newLine;
		$modeLine =~ s/^\|\ *modes{0,1}\ *\=\ *//i;
		@modes = split (/\,|\<br.*?\>/,$modeLine);
		foreach (@modes) {
			$line = $_;
			$line =~ s/^\ *//;
			$line =~ s/\ +$//;
			push (@autoCategory, "\[\[Category:" . $line . " games\]\]");
		}
	}		

	#New-line if this is the end of the Infobox
	if ($newLine =~ /^\}\}$/) {
		if ($savedSizeLine ne "") { push (@finalResult, $savedSizeLine); }  # Saved size
		if (($foundImage eq 0) and ($savedImageLine ne "")) { push (@finalResult, $savedImageLine); } # Saved image line, if wikipedia doesn't have one

		push (@finalResult, $newLine);
		push (@finalResult, " ");
		$skip = 1;
	}

	if (($foundInfobox eq 1) and ($skip eq 0)) {
		push (@finalResult,$newLine);
	}
}

######################
#COMPILE FINAL RESULT#
######################

# At this point, the Infobox and the summary are in place.  Now, time to add our checked and re-formatted content sections.

# Need to combine our categories and make sure there are no duplicates
foreach (@autoCategory) {
	$fullCat = $_;
	my $shortCat;
	$dupe = 0;

	if (($fullCat =~ /^\[\[Category\:\ *(.*)\ *\]\]/i) or ($fullCat =~ /^\{\{Navigation\ *(.*)\ *\}\}/i)) {
		$shortCat = $1;
	}

	foreach (@categorySection) {
		$compareCatLong = $_;
		my $compareCatShort;

		if (($compareCatLong =~ /^\[\[Category\:\ *(.*)\ *\]\]/i) or ($compareCatLong =~ /^\{\{Navigation\ *(.*)\ *\}\}/i)) {
			$compareCatShort = $1;
		}

		if ($compareCatShort eq $shortCat) {
			$dupe = 1;
		}		
	}

	if ($dupe eq 0) {
		push (@categorySection, $_);
	}	
}

# Problem Section
push (@finalResult, "\n\=\= Problems \=\=");
push (@finalResult, @problemSection);

push (@finalResult, "\n\=\= Configuration \=\=");
push (@finalResult, '<!--A full list of options is available at Template:Config/doc-->');
push (@finalResult, "\{\{Config");
push (@finalResult, @configurationSection);
push (@finalResult, "\}\}");

push (@finalResult, "\n\=\= Version Compatibility \=\=");
push (@finalResult, "\{\{VersionCompatibility\}\}");
push (@finalResult, '<!--Use this template for compatibility entries: {{VersionCompatibilityVersion|3891|****}}-->');
push (@finalResult, @versionCompatSection);
push (@finalResult, "\{\{VersionCompatibilityClose\}\}");

push (@finalResult, "\n\=\= Testing \=\=");
push (@finalResult, "\{\{testing\/start\}\}");
push (@finalResult, '<!--Use this template for test entries: {{Test Entry|revision=|OS=|CPU=|GPU=|result=|tester=}}-->');
push (@finalResult, @testingSection);
push (@finalResult, "\{\{testing\/end\}\}");

push (@finalResult, "\n\=\= Gameplay Videos \=\=");
push (@finalResult, @videoSection);

push (@finalResult, "\n");
push (@finalResult, @categorySection);


##############
#FINAL OUTPUT#
##############

system ('clear');

print "****************\n";
print "* FINAL OUTPUT *\n";
print "****************\n";

foreach (@finalResult) {
	print $_ . "\n";
}