endkb / SoundsDownloadScript

Download programs from BBC Sounds and publish them to a podcast feed
2 stars 0 forks source link

Use ConvertFrom-Json to parse the program metadata instead of ConvertFrom-StringData #2

Closed endkb closed 6 months ago

endkb commented 6 months ago

SoundsDownloadScript.ps1 uses regex and ConvertFrom-StringData to parse the program metadata from the BBC Sounds page. This isn't always reliable when there are certain characters, especially quotes and commas.

The metadata is already in JSON format.

Recommend using regex to pull the whole JSON string, and then ConvertFrom-Json to parse the needed data.

endkb commented 6 months ago
$Getjson = "(?<=<script> window.__PRELOADED_STATE__ = )(.*?)(?=; </script>)"
$jsonResult = [regex]::match($SoundsShowPage, $Getjson)
$jsonData = $jsonResult | ConvertFrom-Json
endkb commented 6 months ago

Implemented. Needs to be tested.

endkb commented 6 months ago

Happy with the testing. Merged test-json-metadata to main.