mvysny / photocloud-frame-slideshow

Android Digital Photo Frame
https://www.android-photo-frame.eu
14 stars 1 forks source link

Feature Request - iCloud Photo (public shared folder) support #139

Closed TheOriginalMrWolf closed 3 years ago

TheOriginalMrWolf commented 3 years ago

Just bought your app + daydream option for my Android TV. Good app, working well so far, thanks!

I have a simple feature request - can you please consider implementing support for iCloud Photos (public shared folder). Whilst there isn’t really much support for this in the Android world, there is a workaround – when you share a folder of photos in iCloud you can also create a public website (with an obscure URL generated when the shared folder is made public). Should be pretty simple for you to scrape this (I’ve done same very successfully with a JavaScript app I wrote for my MagicMirror project).

Thanks!

mvysny commented 3 years ago

Thank you for your support :)

Well, I don't use Apple at all, so this might be hard to test. Yet if the resource at the URL is publicly available (no logins/tokens required) and sane to parse, it could be perhaps easy to implement.

Could you create a testing gallery for me and share the link, so that I can check the files for myself?

TheOriginalMrWolf commented 3 years ago

Perfect, thanks!

Super simple - images are just at an obscure URL, and all in just one big page (I've tested with 700+ images). No login/token required at all.

To parse, just grab all image src urls within div (inside div inside div inside div...) with class="view image-view canvas-image-view". There will be multiple of these for each 'section' - where a 'section' collects a number of images (each within a div with the above class) in a mosaic layout.

Have a look at: https://www.icloud.com/sharedalbum/#B0R5qXGF1GeKg4d. I duplicated the images several times to give you a feeling for the layout (so you'll probably find duplicate filenames, but that's fine...).

One caveat - the page is built up by the javascript. I'm assuming it's possible to let that run so that you can then grab the subsequent URLs????

Hope that helps!!!

mvysny commented 3 years ago

Thank you. Unfortunately it's not possible to run the javascript without having an actual browser running, and scrolling slowly through the page to obtain all URLs. Also see https://discussions.apple.com/thread/8197135

However, there's a way to rewrite the javascript algorithm to Java and hope that Apple won't change the algorithm:

mvysny commented 3 years ago
echo '{"streamCtag":null}' | curl -sH "Content-Type: application/json" -X POST -d "@-" https://p27-sharedstreams.icloud.com/B0R5qXGF1GeKg4d/sharedstreams/webstream

this actually downloads a json with a list of photos, so this looks hopeful. However, ideally a Java library able to access this protocol would be really handy.

TheOriginalMrWolf commented 3 years ago

Unfortunately it's not possible to run the javascript without having an actual browser running, and scrolling slowly through the page to obtain all URLs.

Ah, that's a bummer! I had hoped you could do something like load the page & run the javascript but not load the image files within a hidden webview and then scrape that for the required URLs. Sort of like a headless chrome implementation https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md....

echo '{"streamCtag":null}' | curl -sH "Content-Type: application/json" -X POST -d "@-" https://p27-sharedstreams.icloud.com/B0R5qXGF1GeKg4d/sharedstreams/webstream

this actually downloads a json with a list of photos, so this looks hopeful.

Absolutely brilliant figuring that out! Presumably from this you can then create a list of 'large' (not thumbnail) images & request each as required.

However, ideally a Java library able to access this protocol would be really handy.

Agreed! Even more ideally, Apple would publish a supported API.... so I guess the bigger question for you though is how much effort do you want to put into implementing a feature based on an 'unofficial' API which could get broken at any time???

Personally, I'd love to be able to show iCloud photos, and think many others would as well. Maybe implement as an extra paid feature???

Thanks!!!

mvysny commented 3 years ago

Yeah, sounds good. Let me try to prototype the curl approach first, sounds much simpler than having to launch an invisible browser and slowly scrolling through things :-)

mvysny commented 3 years ago

Then, calling:

echo '{"photoGuids": ["1F6DA863-398D-4BA6-9980-350C982F6276"]}' | curl -sH "Content-Type: application/json" -X POST -d "@-" https://p27-sharedstreams.icloud.com/B0R5qXGF1GeKg4d/sharedstreams/webasseturls

returns more JSON... and from that JSON we can learn the image URL! Wohoo!

mvysny commented 3 years ago

I'll create a simple kotlin library which downloads the photos, then I'll integrate it into PhotoCloud. Quite a lot of work /phew :-)

mvysny commented 3 years ago

https://gitlab.com/mvysny/icloud-photo-public-share

mvysny commented 3 years ago

Implemented in PhotoCloud 1.13.18