User:Zaz/FeedDumHostTests2/script
From LoadingReadyWiki
Jump to navigationJump to search
This powershell script generated User:Zaz/FeedDumHostTests2
curl "http://wiki.loadingreadyrun.com/index.php?title=Feed_Dump&action=edit" -o tmp.txt
$datatable = (gc tmp.txt -encoding UTF8) | ?{ $_.startswith("| ")} | ?{ !$_.startswith("| style") } | %{
$spl = $_ -split "\|\|"
$number = $spl[0].substring(2).trim()
$name = $spl[1].substring(26).trim()
$h = $spl[2].trim()
$cohosts = $spl[3].trim() -split "\[\[" | select -skip 1 | %{ $_ -split "\]\]|\|" | select -first 1 }
New-Object psobject | Add-Member -PassThru -MemberType NoteProperty -Name Number -Value $number `
| Add-Member -PassThru -MemberType NoteProperty -Name Name -Value $name `
| Add-Member -PassThru -MemberType NoteProperty -Name CoHosts -Value $cohosts `
| Add-Member -PassThru -MemberType NoteProperty -Name AllHosts -Value ($h+$cohosts) `
| Add-Member -PassThru -MemberType NoteProperty -Name Host -Value $h
}
$hostlist = $datatable.cohosts | select -unique | sort
$outstr = "<small>`r`n{| class=""wikitable"" border=""1""`r`n|+ Feed dump Appearances by Actor`r`n!`r`n"
$XLCol = @("Graham Stark", "Kathleen De Vere")
$LCol = @("Paul Saunders", "Cameron Lauder")
$hostlist | %{
$width = 75
if($XLCol.contains($_)){$width=250}
if($LCol.contains($_)){$width=125}
$outstr += "!scope=""col"" style=""min-width:$($width)px;"" width=""$($width)""| [[$($_)]]"
}
$rowcount = 0
$hostlist | %{
$rowhost = $_
$outstr += "`r`n|- ! [[$rowhost]] "
$colcount = 0
$hostlist | %{
if( $colcount -lt $rowcount )
{
$outstr += "|| "
}
elseif( $colcount -eq $rowcount )
{
$outstr += "|bgcolor=""gray""| "
}
else
{
$colhost = $_
$outstr += "|| "
$haswritten = $false;
$line ="";
$datatable | %{
$episode = $_
if( $episode.allhosts.contains( $rowhost ) -and $episode.allhosts.contains( $colhost ) )
{
$trimname = $episode.name.trim("[]")
$line += "[[$($trimname)|$($episode.number)]], "
$haswritten = $true
}
}
if($haswritten)
{
$outstr += ($line.trim(", "))
$outstr += "`r`n"
}
}
$colcount++
}
$rowcount++;
}
$outstr += "|}`r`n</small>"
$outstr | sc "output.txt" -encoding UTF8