Skip to content

Instantly share code, notes, and snippets.

@jonaswouters
Created September 22, 2020 09:01
Show Gist options
  • Save jonaswouters/66742b13ba64e8ffac99257bdd17e2d1 to your computer and use it in GitHub Desktop.
Save jonaswouters/66742b13ba64e8ffac99257bdd17e2d1 to your computer and use it in GitHub Desktop.
Check the Belgian nvidia store for 3080 stock
function FormatXML ([xml]$xml)
{
$StringWriter = New-Object System.IO.StringWriter;
$XmlWriter = New-Object System.Xml.XmlTextWriter $StringWriter;
$XmlWriter.Formatting = "indented";
$xml.WriteTo($XmlWriter);
$XmlWriter.Flush();
$StringWriter.Flush();
Write-Output $StringWriter.ToString();
}
Add-Type -AssemblyName System.speech
$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer
# https://api.digitalriver.com/v1/shoppers/me/products?apiKey=9485fa7b159e42edb08a83bde0d83dia&locale=fr_fr&pageNumber=6
$urlstore = "https://www.nvidia.com/fr-be/geforce/graphics-cards/30-series/rtx-3080/"
while ($true) {
try { [xml]$xmldata = (New-Object System.Net.Webclient).DownloadString("https://api.digitalriver.com/v1/shoppers/me/products/5438795700/inventory-status?apiKey=9485fa7b159e42edb08a83bde0d83dia&locale=fr_fr") } catch { Write-Host -NoNewLine -Back Black -Fore Red '.';Start-Sleep -s 25;continue }
If ($xmldata.inventoryStatus.status)
{ Write-Host -NoNewLine '.' }
If ($xmldata.inventoryStatus.status -ne 'PRODUCT_INVENTORY_OUT_OF_STOCK' -or $debug -eq $true) {
Start-Process $urlstore
$speak.Speak("Nvidia RTX 3080 is now in stock!")
Write-Host -Back Black -Fore Yellow "Inventory Status: In Stock!!"
} else {
Write-Progress -Activity "Waiting for inventory..." -Status "Status: $($xmldata.inventoryStatus.status)" -PercentComplete 0
}
Start-Sleep -s 60
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment