PoshCode Archive  Artifact [cdcb5aa946]

Artifact cdcb5aa9463e6eaf634221af1026d61d891ffa5fb92c549c753271916334f238:

  • File Download-from-Picasa.ps1 — part of check-in [9d30d109f6] at 2018-06-10 13:46:52 on branch trunk — Download all images from privately shared Google Picasa web album in full resolution (user: Parul Jain paruljain size: 2022)

# encoding: ascii
# api: powershell
# title: Download from Picasa
# description: Download all images from privately shared Google Picasa web album in full resolution
# version: 1.0
# type: script
# author: Parul Jain paruljain
# license: CC0
# x-poshcode-id: 4855
# x-archived: 2016-08-19T05:15:28
# x-published: 2016-01-30T15:54: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.0 Jan 30, 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=(\w+)') { $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")
}