62 lines
1.7 KiB
PowerShell
62 lines
1.7 KiB
PowerShell
$APIToken = 'iXZU8DNKth2qWaDjDck9'
|
|
$APIUrl = 'https://app3.archisnapper.com/api/public/v1/'
|
|
|
|
$url_APIToken = '?auth_token=' + $APIToken
|
|
|
|
$header = @{
|
|
auth_token = $APIToken
|
|
} | ConvertTo-Json
|
|
|
|
$OutputPathBase = "C:\Users\eeckert\Downloads\ArchiSnapper"
|
|
|
|
# get list of projects
|
|
# https://docs.archisnapper.com/reference/retrieving-your-projects
|
|
$page = 1 # init counter
|
|
|
|
do {
|
|
$URI = $APIUrl + 'sites.json' + $url_APIToken + '&page=' + $page
|
|
$response = Invoke-WebRequest -Uri $URI -Method Get
|
|
$ProjectList = $response.Content | convertfrom-json
|
|
|
|
foreach ($project in $ProjectList) {
|
|
|
|
$project_Name = $Project.name
|
|
$project_number = $project.unique_id
|
|
$OutputPathBase_Project = $OutputPathBase + '\' + $project_number + '-' + $project_Name
|
|
Write-Debug -Message ("Processing: $project_Name") -Debug
|
|
|
|
|
|
$project.visits | foreach -Parallel {
|
|
$pathExist = Test-Path $USING:OutputPathBase_Project -ErrorAction SilentlyContinue
|
|
if (!($pathExist)) {
|
|
New-Item -Path $USING:OutputPathBase_Project -ItemType Directory
|
|
}
|
|
if ($_) {
|
|
Write-Debug -Message ("Checking " + $_.unique_id) -Debug
|
|
$testURI = $_.pdf_link + '&auth_token=' + $USING:APIToken
|
|
$Outfile = $USING:OutputPathBase_Project + '\' + $_.Date.ToString().Substring(0,10) + '_' + $_.unique_id + ".pdf"
|
|
if (!(Test-Path $Outfile)) {
|
|
Write-Debug ("Saving file: " + $Outfile) -Debug
|
|
Invoke-WebRequest -Uri $testURI -OutFile $Outfile
|
|
|
|
}
|
|
}
|
|
} -ThrottleLimit 5
|
|
}
|
|
$page++
|
|
}
|
|
|
|
until (
|
|
$null -eq $response.Content
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|