User:Zaz/FeedDumHostTests2/script: Difference between revisions

From LoadingReadyWiki
Jump to navigationJump to search
Zaz (talk | contribs)
No edit summary
Zaz (talk | contribs)
No edit summary
Line 21: Line 21:
$outstr = "<small>`r`n{| class=""wikitable"" border=""1""`r`n|+ Feed dump Appearances by Actor`r`n!`r`n"
$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 | %{
$hostlist | %{
$width = 75
  $width = 75
if($_ -eq "Graham Stark" -or $_ -eq "Kathleen De Vere" )
  if($XLCol.contains($_)){$width=250}
{
  if($LCol.contains($_)){$width=125}
$width=250
  $outstr += "!scope=""col"" style=""min-width:$($width)px;"" width=""$($width)""| [[$($_)]]`r`n"
}
$outstr += "!scope=""col"" style=""min-width:$($width)px;"" width=""$($width)""| [[$($_)]]`r`n"
}
}


Line 41: Line 40:
$outstr += "|bgcolor=""gray""|`r`n"
$outstr += "|bgcolor=""gray""|`r`n"
}
}
else
elseif( $colcount -gt $rowcount )
{
{
$colhost = $_
$colhost = $_
$outstr += "||`r`n"
$outstr += "||`r`n"
$haswritten = $false;
$line ="";
$line ="";
$datatable | %{
$datatable | %{
Line 52: Line 52:
$trimname = $episode.name.trim("[]")
$trimname = $episode.name.trim("[]")
$line += "[[$($trimname)|$($episode.number)]], "
$line += "[[$($trimname)|$($episode.number)]], "
$haswritten = $true
}
}
}
}
$outstr += ($line.trim(", "))
if($haswritten)
$outstr += "`r`n"
{
$outstr += ($line.trim(", "))
$outstr += "`r`n"
}
}
}
     $colcount++
     $colcount++

Revision as of 13:54, 12 May 2015

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)""| [[$($_)]]`r`n"
}

$rowcount = 0
$hostlist | %{
  $rowhost = $_
  $outstr += "|-`r`n! [[$rowhost]]`r`n"
  $colcount = 0
  $hostlist | %{
    if( $colcount -eq $rowcount )
	{
		$outstr += "|bgcolor=""gray""|`r`n"
	}
	elseif( $colcount -gt $rowcount )
	{
		$colhost = $_
		$outstr += "||`r`n"
		$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