jarrettbarnett
12/5/2013 - 8:21 PM

For exporting photos from Disney Photo Pass website

For exporting photos from Disney Photo Pass website

#!/bin/bash
# 
# takes a url like this:
# http://www.disneyphotopass.com/api/photostore/getSharedImageList.ashx?ShareToken=[[token]]
# and saves all the pictures to ./disneypics
# 
# url can be found by going to http://www.disneyphotopass.com/photoshare.aspx and sharing photos by email. 
# the link will be in the email

[[ -n "$1" ]] || { echo "Please add the share url as a parameter"; exit 0; }

cnt=1
regex='http://www.disneyphotopass.com/api/photostore/getSharedImageList.ashx\?ShareToken=([a-zA-Z0-9]+-){4}[a-zA-Z0-9]'
if [[ $1 =~ $regex ]]
then
	token=`printf "%s" "$1"|cut -d= -f2`
	url_xml="`wget -qO- $1`" 
	
	id_regex='id='
	for word in $url_xml
	do
		
		if [[ $word =~ $id_regex ]]
		then 
			id=`printf "%s" "$word"|cut -d\" -f2`
			img_url="http://www.disneyphotopass.com/api/photostore/previewEdits.pix?quality=100&ImageId=${id}";

			if [ ! -d ./disneypics ] 
			then
    				mkdir disneypics
			fi	
    			
			wget $img_url -O ./disneypics/disney_${cnt}.jpg
    			cnt=$(( $cnt + 1 ))

		fi
	done


else
	echo "invalid link"
fi