Download picasa web albums photos automatically. This application requires mpod mother board. See also http://mbed.org/users/geodenx/notebook/mpod/
Dependencies: BlinkLed HTTPClient EthernetInterface FatFileSystemCpp MSCFileSystem mbed-rtos mbed
Download picasa web albums photos automatically.
This application requires mpod mother board.
Picasaウェブアルバムから、自動的に写真をダウンロードして、ディジタルフォトフレームに表示します。
動作させるには mpod マザーボード が必要です。
プログラムの中で、ご自分のアルバムのRSSファイルへのURLを指定してからご利用下さい。
Revision 3:ffbb2b22099a, committed 2012-08-24
- Comitter:
- togayan
- Date:
- Fri Aug 24 16:16:54 2012 +0000
- Parent:
- 2:531722036c0a
- Child:
- 4:f2d619e67d44
- Commit message:
- Even if the DCIM folder does not exist, the photos are downloaded.
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Aug 24 13:07:06 2012 +0000
+++ b/main.cpp Fri Aug 24 16:16:54 2012 +0000
@@ -26,6 +26,7 @@
/***** Please specify "albumRssUrl" *****/
const char* albumRssUrl = "http://picasaweb.google.com/data/feed/base/user/*****/albumid/*****?alt=rss&kind=photo&authkey=*****&hl=ja";
+
const char* albumRssPath = "/usb/album.xml";
const char* tempPath = "/usb/temp.xml";
const char* summaryPath = "/usb/summary.xml";
@@ -36,6 +37,16 @@
printf("mpod Picasa Photo frame\n");
printf("================================\n\n");
+ // Check albumRssUrl
+ if(NULL != strstr(albumRssUrl, "*****"))
+ {
+ error("[ERROR] Please specify the RSS of YOUR album to \"albumRssUrl\" in the firmware.\n");
+ }
+ if(NULL != strstr(albumRssUrl, "https"))
+ {
+ error("[ERROR] Please specify the URL of the RSS in \"HTTP\" format.\n");
+ }
+
// FSUSB30 switches to HSD1 (mbed)
printf("USB host was switched to HSD1(mbed).\n\n");
fsusb30s = 0; // HSD1
@@ -94,13 +105,35 @@
strcpy(lastBuildDateCurrent, lastBuildDateCurrentElement->GetText());
printf("\nlastBuildDate (current) : %s\n", lastBuildDateCurrent);
- if( strcmp(lastBuildDateOriginal, lastBuildDateCurrent) != 0 )
+
+ // Determine the necessity of downloading new Photos.
+ bool flgDownloadPhoto = false;
+ if ( strcmp(lastBuildDateOriginal, lastBuildDateCurrent) == 0 )
+ {
+ printf("lastBuildDate (original) == lastBuildDate (current)\n");
+ if(DirHandle* dir = opendir("/usb/DCIM")) // check an existance of DCIM folder
+ {
+ printf("However, no DCIM folder in USB memory\n");
+ flgDownloadPhoto = true;
+ }
+ else
+ {
+ //Should be checked whether files exist.
+ flgDownloadPhoto = false;
+ }
+ }
+ else
{
printf("lastBuildDate (original) != lastBuildDate (current)\n");
+ flgDownloadPhoto = true;
+ }
+
+ // Download new Photos
+ if(flgDownloadPhoto)
+ {
if(removePhotos() < 0)
{
- fsusb30s = 1; // HSD2
- error("No \"DCIM\" folder in MSD.\n");
+ mkdir("/usb/DCIM", 0777);
}
char photoUrl[256] = {0};
@@ -126,10 +159,6 @@
++photoNo;
}
}
- else
- {
- printf("lastBuildDate (original) == lastBuildDate (current)\n");
- }
// Wait for the completion of writing to USB Mass Storage Device.
wait(1);
@@ -149,7 +178,7 @@
{
led2.startBlink();
ethYellow.startBlink();
- printf("\nGetting %s\n", url);
+ printf("\nGetting %s -> %s\n", url, path);
timer.stop();
timer.reset();
Satoshi Togawa