icloud-photos-downloader / icloud_photos_downloader

A command-line tool to download photos from iCloud
MIT License
6.47k stars 531 forks source link

Download photos from albums in folders #482

Open EmilyJYN opened 1 year ago

EmilyJYN commented 1 year ago

Summary

Is there a way to download photos from albums in folders?

Context

So I have an album folder called "Course Note", and then there are albums like "Math 209", "ECE 332", etc. However, when I try to download the folder by "--album Course_notes", here is the message: image Apparently, nothing was downloaded.

And then when I tried "--album Course_notes\ECE332", here is the error message: image

Is this feature not available yet? I saw some other people having the same need as I do: https://github.com/icloud-photos-downloader/icloud_photos_downloader/issues/125#issuecomment-801943814

rafaelsales commented 1 year ago

As much as I'd love to have this feature too, I can't see how this would make sense for users in general. The concept of an album in Photos is just a mechanism to group photos logically, not physically. That means that you can add photos to as many albums as you want and these are just references, not copies.

menkej commented 1 year ago

So I have an album folder called "Course Note"

Could you please post what a call with "--list-albums" gives you regarding the mentioned folders? I guess it could be just a matter of spelling and/or using the right slash...

Thanks Jörg

gordonaspin commented 1 year ago

Saving to folders named by album is useful to me. Downloading in linux/windows to one huge All Photos folder is unmanageable. I have over 500 albums 17,000 assets, so I implemented it in my fork with a set of other features:

Check out my fork of icloud_photo_downloader and accompanying pyicloud repo too. Features added to icloud_photo_downloader:

  1. Save album assets to folder as with -d Photos and --folder-structure album, will save to Phosts/
  2. New --date-since YYYY-MM-DD or YYYY-MM-DD-HH:MM:SS to only download assets newer than date-since
  3. New --exclude-smart-folders flag
  4. Make logging more consistent
  5. Python 3.10.8
  6. Log datetime of newest asset in Library (can be used to set --date-since in next run) Changes in my pyicloud fork:
  7. Implement feature in _fetch_folders to retrieve ALL album names and not the first 200
  8. add property item_type in Photos service
  9. Python 3.10.8
Jonnypleasehelp commented 1 year ago

Folder by date good

drawingthesun commented 11 months ago

If we could run something like:

icloudpd -d x -u x —create-json-album-listing <album_name>
# and/or:
icloudpd -d x -u x —create-json-album-listing all_albums

Where —create-json-album-listing x produces a json file listing per album (or all albums) containing all of the file names and locally downloaded paths (or file hash)

This way we have all the info needed to recreate the albums without duplicating the files, it's a more complete backup imo.

gordonaspin commented 11 months ago

If we could run something like:

icloudpd -d x -u x —create-json-album-listing <album_name>
# and/or:
icloudpd -d x -u x —create-json-album-listing all_albums

Where —create-json-album-listing x produces a json file listing per album (or all albums) containing all of the file names and locally downloaded paths (or file hash)

This way we have all the info needed to recreate the albums without duplicating the files, it's a more complete backup imo. If you look at the PhotoAsset table in icloudpd.db you can get that info already, e.g. sqlite3 icloudpd.db "select * from PhotoAsset" id|filename|size|created|asset_date|added_date|dimensionX|dimensionY|item_type|item_type_extension|path|md5|album AejGSLcEgZoHqzEkqFxykNkTGxX4|73a1caf0-3a3b-4646-95fe-724da1f74e84.jpg|229203|2023-06-04 15:15:43.000000+00:00|2023-06-04 15:15:43.000000+00:00|2023-06-04 16:11:30.453000+00:00|1600|1200|image|JPG|WhatsApp/73a1caf0-3a3b-4646-95fe-724da1f74e84.jpg|31923fdb974edade95f592a830d0321d|WhatsApp ....

I'll think about adding a new feature. Something like this: ?

[
    {
        "album_name" : "Some Album Name",
        "filename" : "some file name.heic",
        "relative_path" : "Some Album Name/some_file name.heic",
        "absolute_path" : "/home/username/Pictures/iCloud Photos/Some Album Name/some file name.heic"
    },
    {
        ...
    {
]
gordonaspin commented 11 months ago

I implemented the catalog.json output when using --create-json-listing. You can pull this repo along with my fork of pyicloud as a dependent repo.

structure is as follows, with example here:

{
    catalog_attributes,
    ...
    albums[
        {
            album_attributes,
            ....
            assets[
                asset_attributes,
                ...
            ]
        },
        ....
    ]
}
{
    "icloud_username": "username@gmail.com",
    "directory": "/home/username/Pictures/iCloud Photos",
    "albums": [
        {
            "album_name": "WhatsApp",
            "assets": [
                {
                    "id": "AfRuw5AKo2JEP+1r5ciAWSQJTvQh",
                    "filename": "9133a2a3-25b7-47dd-9205-f9ea607449ff.jpg",
                    "size": 96806,
                    "created": "2023-09-12T17:08:37+00:00",
                    "asset_date": "2023-09-12T17:08:37+00:00",
                    "added_date": "2023-09-13T00:02:07.680000+00:00",
                    "x": 1080,
                    "y": 1920,
                    "item_type": "image",
                    "item_type_extension": "JPG",
                    "path": "WhatsApp/9133a2a3-25b7-47dd-9205-f9ea607449ff.jpg",
                    "md5": "17bf7eb1d69fd460d098c96a163f6f8d",
                    "album": "WhatsApp",
                    "file_size": 96806
                },
                {
                    "id": "AaaSuI//3ZZ6CzoESk5Cw56kZy07",
                    "filename": "b603edd1-bcb9-4f8d-967b-0896d741aaaa.mp4",
                    "size": 8692803,
                    "created": "2023-09-08T12:18:09+00:00",
                    "asset_date": "2023-09-08T12:18:09+00:00",
                    "added_date": "2023-09-08T12:49:42.097000+00:00",
                    "x": 480,
                    "y": 848,
                    "item_type": "movie",
                    "item_type_extension": "MP4",
                    "path": "WhatsApp/b603edd1-bcb9-4f8d-967b-0896d741aaaa.mp4",
                    "md5": "d1984aff65eb83fa171c595ab540d4cf",
                    "album": "WhatsApp",
                    "file_size": 8692803
                },