User:Zaz/FeedDumHostTests3/script: Difference between revisions
From LoadingReadyWiki
Jump to navigationJump to search
Created page with "<pre>curl "http://wiki.loadingreadyrun.com/index.php?title=Feed_Dump&action=edit" -o tmp.txt $datatable = (gc tmp.txt -encoding UTF8) | ?{ $_.startswith("| ")} | ?{ !$_.starts..." |
No edit summary |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
<pre> | <pre> | ||
# This script can be run using powershell v3.0, I believe | |||
$wc = New-Object System.Net.WebClient | |||
$wc.DownloadFile("http://wiki.loadingreadyrun.com/index.php?title=Feed_Dump&action=edit","tmp.txt"); | |||
$datatable = (gc tmp.txt -encoding UTF8) | ?{ $_.startswith("| ")} | ?{ !$_.startswith("| style") } | %{ | $datatable = (gc tmp.txt -encoding UTF8) | ?{ $_.startswith("| ")} | ?{ !$_.startswith("| style") } | %{ | ||
$spl = $_ -split "\|\|" | $spl = $_ -split "\|\|" | ||
| Line 7: | Line 12: | ||
$cohosts = $spl[3].trim() -split "\[\[" | select -skip 1 | %{ $_ -split "\]\]|\|" | select -first 1 } | $cohosts = $spl[3].trim() -split "\[\[" | select -skip 1 | %{ $_ -split "\]\]|\|" | select -first 1 } | ||
New-Object psobject | Add-Member -PassThru -MemberType NoteProperty -Name Number -Value $number ` | 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 | |||
} | } | ||
| Line 34: | Line 38: | ||
$colcount = 0 | $colcount = 0 | ||
$hostlist | %{ | $hostlist | %{ | ||
if( $colcount -lt $rowcount ){ | |||
$outstr += "|style=""text-align:center;font-size:large""| »`r`n" | |||
} | |||
elseif( $colcount -eq $rowcount ){ | |||
$outstr += "`r`n|bgcolor=""lightgray""| [[$rowhost]]`r`n" | |||
elseif( $colcount -eq $rowcount ) | } | ||
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++ | $colcount++ | ||
} | } | ||
$rowcount++; | $rowcount++; | ||
} | } | ||
Latest revision as of 08:47, 16 May 2015
# This script can be run using powershell v3.0, I believe
$wc = New-Object System.Net.WebClient
$wc.DownloadFile("http://wiki.loadingreadyrun.com/index.php?title=Feed_Dump&action=edit","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)""| [[$($_)]]`r`n"
}
$rowcount = 0
$hostlist | %{
$rowhost = $_
$outstr += "`r`n|-`r`n! [[$rowhost]]`r`n"
$colcount = 0
$hostlist | %{
if( $colcount -lt $rowcount ){
$outstr += "|style=""text-align:center;font-size:large""| »`r`n"
}
elseif( $colcount -eq $rowcount ){
$outstr += "`r`n|bgcolor=""lightgray""| [[$rowhost]]`r`n"
}
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