PoshCode Archive  Artifact [b1e26dcf2e]

Artifact b1e26dcf2e2bbbc4d4159faa1bbea4881d3e38d4169604998cc0793862b4755d:

  • File Download-from-Picasa.ps1 — part of check-in [7b44139642] at 2018-06-10 13:47:11 on branch trunk — Download all images from privately shared Google Picasa web album in full resolution Version 1.1 (user: Parul Jain paruljain size: 2035)

# encoding: ascii
# api: powershell
# title: Download from Picasa
# description: Download all images from privately shared Google Picasa web album in full resolution Version 1.1
# version: 1.1
# type: script
# author: Parul Jain paruljain
# license: CC0
# x-poshcode-id: 4869
# x-archived: 2016-07-20T10:55:49
# x-published: 2016-02-03T14:03:00
#
#
<#
.SYNOPSIS
    Download all images from privately shared Google Picasa web album in full resolution
.DESCRIPTION
    When someone shares a link to a privately shared album on Picasa, it is painful to download each picture if you do not have
    the desktop version of Picasa installed. This script will take the link to the album, ususally shared on email, and will
    download the full resolution version of all pictures automatically
.NOTES
    Author: Parul Jain paruljain@hotmai.com
    Version: 1.1 Feb 3, 2014
    Requires: PowerShell v3 or better
.PARAMETER albumUrl
    Mandatory. String URL of the privately shared Google Picasa web album, usually distributed on email
.EXAMPLE
    picasa.ps1 https://picasaweb.google.com/1234567890/someAlbum?authkey=xy12DFghj9Ipw
#>

param([Parameter(Mandatory=$True)][string]$albumUrl)

$page = Invoke-WebRequest $albumUrl
if ($page.RawContent -match 'https://picasaweb.google.com/data/feed/base/user/(\d+)/albumid/(\d+)') {
    $userId = $matches[1]
    $albumId = $matches[2]
}
else { throw 'User ID and Album ID cannot be found on the picasa page' }

if ($page.RawContent -match 'authkey=([^&]+)') { $authKey = $matches[1] }
else { throw 'Authentication key cannot be found the picasa page'}

$photos = Invoke-RestMethod -Uri "https://picasaweb.google.com/data/feed/api/user/$userId/albumid/${albumId}?authkey=$authKey"
foreach ($photo in $photos) {
    $photoDetail = Invoke-RestMethod -Uri ($photo.id[0] + "?authkey=$authKey&imgmax=d")
    $filename = ($photoDetail.entry.content.src).Split('/')[-1]
    Invoke-RestMethod -Uri $photoDetail.entry.content.src -OutFile (".\$filename")
}