User:Zaz/FeedDumHostTests3/script: Difference between revisions

From LoadingReadyWiki
Jump to navigationJump to search
Zaz (talk | contribs)
No edit summary
Zaz (talk | contribs)
No edit summary
 
Line 1: Line 1:
<pre>
<pre>
# This script can be run using powershell v3.0, I believe
$wc = New-Object System.Net.WebClient
$wc = New-Object System.Net.WebClient
$wc.DownloadFile("http://wiki.loadingreadyrun.com/index.php?title=Feed_Dump&action=edit","tmp.txt");
$wc.DownloadFile("http://wiki.loadingreadyrun.com/index.php?title=Feed_Dump&action=edit","tmp.txt");
Line 10: 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 Name -Value $name `
  | Add-Member -PassThru -MemberType NoteProperty -Name CoHosts -Value $cohosts `
  | 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 AllHosts -Value ($h+$cohosts) `
  | Add-Member -PassThru -MemberType NoteProperty -Name Host -Value $h
  | Add-Member -PassThru -MemberType NoteProperty -Name Host -Value $h
 
}
}


Line 37: Line 38:
   $colcount = 0
   $colcount = 0
   $hostlist | %{
   $hostlist | %{
 
    if( $colcount -lt $rowcount ){
if( $colcount -lt $rowcount )
      $outstr += "|style=""text-align:center;font-size:large""| »`r`n"
{
    }
$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 {
$outstr += "`r`n|bgcolor=""lightgray""| [[$rowhost]]`r`n"
      $colhost = $_
}
      $outstr += "|| "
else
      $haswritten = $false;
{
      $line ="";
$colhost = $_
      $datatable | %{
$outstr += "|| "
        $episode = $_
$haswritten = $false;
        if( $episode.allhosts.contains( $rowhost ) -and $episode.allhosts.contains( $colhost ) ){
$line ="";
          $trimname = $episode.name.trim("[]")
$datatable | %{
          $line += "[[$($trimname)|$($episode.number)]], "
$episode = $_
          $haswritten = $true
if( $episode.allhosts.contains( $rowhost ) -and $episode.allhosts.contains( $colhost ) )
        }
{
      }
$trimname = $episode.name.trim("[]")
      if($haswritten){
$line += "[[$($trimname)|$($episode.number)]], "
        $outstr += ($line.trim(", "))
$haswritten = $true
        $outstr += "`r`n"
}
      }
}
    }
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