| Abhishek Agrawa...'s profileAbhishek's PowerShell Bl...BlogLists | Help |
|
January 09 out-flickrNow that the holiday season is over, many folks would have a gazzillion photos to arrange, organize, upload and share. I am a flickr user and I use it to share photos with friends and family. To make my life easy I wrote a PowerShell script to upload photos to my flickr account.
This is how the usage looks like
PS> cd c:\pictures\New_Year
PS> ls *.jpg | out-flickr
You will now be redirected to www.flickr.com to complete authentication. Hit Ent
er when authentication is complete:: uploading C:\Pictures\New_Year\abhishek.jpg... upload successful, photoid: 352538696 uploading C:\Pictures\New_Year\tanks.jpg... upload successful, photoid: 352538762 uploading C:\Pictures\New_Year\rock1.JPG... upload successful, photoid: 352538784 PS> The script is built on top of the FlickrNet api library which provides an easy way to access the flickr web service from .Net. To use the script the dll needs to be downloaded and loaded into your powershell session. This MSDN Article is a good reference on how to use the library.
To use the script you will need to register for a Flickr API key. A shared secret will also be created at regsitration time (register as a desktop application). The script listing is shown at the end of this article. Enter your flickr key and flickr secret to get the script working.
This is how the script works: The first step is to authenticate the powershell session with the Flickr service. The script will redirect the user to the flickr web-page in your browser, ask them to login and grant permission to the powershell script to access their photos. Once authentication completes, the user returns to the powershell session and hits enter to continue. The script will cache the Authentication token in the powershell session, so the user will not need to authenticate every time.
The core of the script is to call UploadPicture api and pass it the filename to upload. All photos are marked private by default. Rest of the script is just plumbing to make the piping of fileinfo objects into the script work. Once the photos have been uploaded the user is redirected to flickr again to allow them to edit properties on newly uploaded pics.
#out-flickr.ps1
#Note the script assumes the FlickrNet assembly has been loaded into the powershell session
#Error-handling is weak and there might be bugs :-)
Comments (116)
Trackbacks (10)The trackback URL for this entry is: http://abhishek225.spaces.live.com/blog/cns!13469C7B7CE6E911!285.trak Weblogs that reference this entry
|
|
|