Skip to content

Instantly share code, notes, and snippets.

@MikDal002
Last active July 21, 2018 01:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MikDal002/23b86f18d6a34ab488212171870509a7 to your computer and use it in GitHub Desktop.
Save MikDal002/23b86f18d6a34ab488212171870509a7 to your computer and use it in GitHub Desktop.
It is a simple powershell script used to download whole book from polish on-line library - POLONA
param ([Parameter(Mandatory=$true)][int]$bookUid)
$url = "https://polona.pl/resources/item/$($bookUid)/"
$bookMeta = Invoke-WebRequest $url | ConvertFrom-Json
$bookDirectory = "$($PSScriptRoot)\$($bookUid)"
New-Item -ItemType Directory -Force -Path $bookDirectory
# write metadata to file
$additionalMetadata = "$($bookMeta.creator) `n$($bookMeta.title)"
echo $additionalMetadata > "$($bookDirectory)\$($bookUid).txt"
foreach ($page in $bookMeta.pages)
{
$downloadUri = $page.archive_url
$pageFileName = "$($page.uid).jpeg"
Invoke-WebRequest -Uri $downloadUri -OutFile "$($bookDirectory)\$($pageFileName)"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment