Public/Get-iPlayerFeatured.ps1
function Get-iPlayerFeatured { param ( [switch]$Raw ) 1..2 | ForEach-Object { $Elements = ConvertTo-HtmlDocument -Uri "https://www.bbc.co.uk/iplayer/group/featured?page=$_" | Select-HtmlNode -CssSelector '#tvip-script-app-store' | Select-Object -ExpandProperty InnerText | ForEach-Object { $_ -replace '^window\.__IPLAYER_REDUX_STATE__ = ', '' -replace ';$', '' } | ConvertFrom-Json -Depth 10 | Select-Object -ExpandProperty entities | Select-Object -ExpandProperty elements switch ($Raw) { $true { $Elements } $false { $Elements | ForEach-Object { [PSCustomObject]@{ PSTypeName = 'UncommonSense.iPlayer.Featured' ID = $_.id Title = $_.title SubTitle = $_.subtitle Category = $_.labels.category Synopsis = $_.synposes.large ?? $_.synopses.medium ?? $_.synopses.small Image = ($_.images.promotional ?? $_.images.standard) -replace '\{recipe\}', '304x171' Link = $_.related_links.url } } } } } } |