osxphotos


Nameosxphotos JSON
Version 0.68.1 PyPI version JSON
download
home_pagehttps://github.com/RhetTbull/
SummaryExport photos from Apple's macOS Photos app and query the Photos library database to access metadata about images.
upload_time2024-06-12 00:20:49
maintainerNone
docs_urlNone
authorRhet Turnbull
requires_python<3.13,>=3.9
licenseLicense :: OSI Approved :: MIT License
keywords
VCS
bugtrack_url
requirements bitmath bpylist2 cgmetadata Click mac-alias makelive Mako more-itertools objexplore osxmetadata packaging pathvalidate photoscript pip ptpython pyobjc-core pyobjc-core pyobjc-framework-AppleScriptKit pyobjc-framework-AppleScriptKit pyobjc-framework-AppleScriptObjC pyobjc-framework-AppleScriptObjC pyobjc-framework-AVFoundation pyobjc-framework-AVFoundation pyobjc-framework-Cocoa pyobjc-framework-Cocoa pyobjc-framework-CoreServices pyobjc-framework-CoreServices pyobjc-framework-Metal pyobjc-framework-Metal pyobjc-framework-Photos pyobjc-framework-Photos pyobjc-framework-Quartz pyobjc-framework-Quartz pyobjc-framework-Vision pyobjc-framework-Vision pytimeparse2 PyYAML requests rich_theme_manager rich shortuuid strpdatetime tenacity textx toml wrapt wurlitzer xdg-base-dirs xdg
Travis-CI No Travis.
coveralls test coverage No coveralls.
            .. role:: raw-html-m2r(raw)
   :format: html


osxphotos
=========

What is osxphotos?
------------------

OSXPhotos provides both the ability to interact with and query Apple's Photos.app library on macOS directly from your python code 
as well as a very flexible command line interface (CLI) app for exporting photos. 
You can query the Photos library database -- for example, file name, file path, and metadata such as keywords/tags, persons/faces, albums, etc. 
You can also easily export both the original and edited photos. 

Supported operating systems
---------------------------

Only works on macOS (aka Mac OS X). Tested on macOS Sierra (10.12.6) through macOS Monterey (12.3).

This package will read Photos databases for any supported version on any supported macOS version.  
E.g. you can read a database created with Photos 5.0 on MacOS 10.15 on a machine running macOS 10.12 and vice versa.

Requires python >= ``3.9``. 

Installation
------------

If you just want to use the command line application, I recommend you to install using pipx. See other advanced options below. 

Installation using pipx
^^^^^^^^^^^^^^^^^^^^^^^

If you aren't familiar with installing python applications, I recommend you install ``osxphotos`` with `pipx <https://github.com/pipxproject/pipx>`_. If you use ``pipx``\ , you will not need to create a virtual environment as ``pipx`` takes care of this. The easiest way to do this on a Mac is to use `homebrew <https://brew.sh/>`_\ :


* Open ``Terminal`` (search for ``Terminal`` in Spotlight or look in ``Applications/Utilities``\ )
* Install ``homebrew`` according to instructions at `https://brew.sh/ <https://brew.sh/>`_
* Type the following into Terminal: ``brew install pipx``
* Then type this: ``pipx install osxphotos``
* Now you should be able to run ``osxphotos`` by typing: ``osxphotos``

Installation using pip
^^^^^^^^^^^^^^^^^^^^^^

You can also install directly from `pypi <https://pypi.org/project/osxphotos/>`_\ :

.. code-block::

   python3 -m pip install osxphotos

Command Line Usage
------------------

This package will install a command line utility called ``osxphotos`` that allows you to query the Photos database and export photos.  
Alternatively, you can also run the command line utility like this: ``python3 -m osxphotos``

.. code-block::
   
   Usage: osxphotos [OPTIONS] COMMAND [ARGS]...
   
     OSXPhotos: the multi-tool for your Photos library.
   
     To get help on a specific command, use "osxphotos COMMAND --help" or
     "osxphotos help COMMAND"; for example, "osxphotos help export".
   
     To search help for a specific topic within a command, run "osxphotos help
     COMMAND TOPIC"; for example, "osxphotos help export keyword" to get help
     related to keywords when using the export command.
   
     To see the full documentation in your browser, run "osxphotos docs".
   
     Some advanced commands are hidden by default. To see all commands, run
     "OSXPHOTOS_SHOW_HIDDEN=1 osxphotos help". Some commands also have hidden
     options. These can be seen by running "OSXPHOTOS_SHOW_HIDDEN=1 osxphotos
     help COMMAND".
   
   Options:
     -v, --version  Show the version and exit.
     -h, --help     Show this message and exit.
   
   Commands:
     about          Print information about osxphotos including license.
     add-locations  Add missing location data to photos in Photos.app using...
     albums         Print out albums found in the Photos library.
     batch-edit     Batch edit photo metadata such as title, description,...
     compare        Compare two Photos libraries to find differences
     docs           Open osxphotos documentation in your browser.
     dump           Print list of all photos & associated info from the...
     exiftool       Run exiftool on previously exported files to update...
     export         Export photos from the Photos database.
     exportdb       Utilities for working with the osxphotos export database
     help           Print help; for help on commands: help <command>.
     import         Import photos and videos into Photos.
     info           Print out descriptive info of the Photos library database.
     inspect        Interactively inspect photos selected in Photos.
     install        Install Python packages into the same environment as...
     keywords       Print out keywords found in the Photos library.
     labels         Print out image classification labels found in the...
     list           Print list of Photos libraries found on the system.
     orphans        Find orphaned photos in a Photos library
     persons        Print out persons (faces) found in the Photos library.
     places         Print out places found in the Photos library.
     push-exif      Write photo metadata to original files in the Photos...
     query          Query the Photos database using 1 or more search...
     repl           Run interactive osxphotos REPL shell (useful for...
     run            Run a python file using same environment as osxphotos.
     show           Show photo, album, or folder in Photos from UUID_OR_NAME
     sync           Sync metadata and albums between Photos libraries.
     template       Interactively render templates for selected photo.
     theme          Manage osxphotos color themes.
     timewarp       Adjust date/time/timezone of photos in Apple Photos.
     tutorial       Display osxphotos tutorial.
     uninstall      Uninstall Python packages from the osxphotos environment
     uuid           Print out unique IDs (UUID) of photos selected in Photos
     version        Check for new version of osxphotos.
   
   To get help on a specific command, use ``osxphotos help <command_name>``
   
Command line examples
^^^^^^^^^^^^^^^^^^^^^

export all photos to ~/Desktop/export group in folders by date created
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

``osxphotos export --export-by-date ~/Pictures/Photos\ Library.photoslibrary ~/Desktop/export``

**Note**\ : Photos library/database path can also be specified using ``--db`` option:

``osxphotos export --export-by-date --db ~/Pictures/Photos\ Library.photoslibrary ~/Desktop/export``

find all photos with keyword "Kids" and output results to json file named results.json:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

``osxphotos query --keyword Kids --json ~/Pictures/Photos\ Library.photoslibrary >results.json``

export photos to file structure based on 4-digit year and full name of month of photo's creation date:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

``osxphotos export ~/Desktop/export --directory "{created.year}/{created.month}"``

(by default, it will attempt to use the system library)

export photos to file structure based on 4-digit year of photo's creation date and add keywords for media type and labels (labels are only awailable on Photos 5 and higher):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

``osxphotos export ~/Desktop/export --directory "{created.year}" --keyword-template "{label}" --keyword-template "{media_type}"`` 

export default library using 'country name/year' as output directory (but use "NoCountry/year" if country not specified), add persons, album names, and year as keywords, write exif metadata to files when exporting, update only changed files, print verbose ouput
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

``osxphotos export ~/Desktop/export --directory "{place.name.country,NoCountry}/{created.year}"  --person-keyword --album-keyword --keyword-template "{created.year}" --exiftool --update --verbose``

find all videos larger than 200MB and add them to Photos album "Big Videos" creating the album if necessary
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

``osxphotos query --only-movies --min-size 200MB --add-to-album "Big Videos"``

Example uses of the package
---------------------------

.. code-block:: python

   """ Simple usage of the package """
   import osxphotos

   def main():
       photosdb = osxphotos.PhotosDB()
       print(photosdb.keywords)
       print(photosdb.persons)
       print(photosdb.album_names)

       print(photosdb.keywords_as_dict)
       print(photosdb.persons_as_dict)
       print(photosdb.albums_as_dict)

       # find all photos with Keyword = Foo and containing John Smith
       photos = photosdb.photos(keywords=["Foo"],persons=["John Smith"])

       # find all photos that include Alice Smith but do not contain the keyword Bar
       photos = [p for p in photosdb.photos(persons=["Alice Smith"]) 
                   if p not in photosdb.photos(keywords=["Bar"]) ]
       for p in photos:
           print(
               p.uuid,
               p.filename,
               p.original_filename,
               p.date,
               p.description,
               p.title,
               p.keywords,
               p.albums,
               p.persons,
               p.path,
           )

   if __name__ == "__main__":
       main()

.. code-block:: python

   """ Export all photos to specified directory using album names as folders
       If file has been edited, also export the edited version, 
       otherwise, export the original version 
       This will result in duplicate photos if photo is in more than album """

   import os.path
   import pathlib
   import sys

   import click
   from pathvalidate import is_valid_filepath, sanitize_filepath

   import osxphotos


   @click.command()
   @click.argument("export_path", type=click.Path(exists=True))
   @click.option(
       "--default-album",
       help="Default folder for photos with no album. Defaults to 'unfiled'",
       default="unfiled",
   )
   @click.option(
       "--library-path",
       help="Path to Photos library, default to last used library",
       default=None,
   )
   def export(export_path, default_album, library_path):
       export_path = os.path.expanduser(export_path)
       library_path = os.path.expanduser(library_path) if library_path else None

       if library_path is not None:
           photosdb = osxphotos.PhotosDB(library_path)
       else:
           photosdb = osxphotos.PhotosDB()

       photos = photosdb.photos()

       for p in photos:
           if not p.ismissing:
               albums = p.albums
               if not albums:
                   albums = [default_album]
               for album in albums:
                   click.echo(f"exporting {p.filename} in album {album}")

                   # make sure no invalid characters in destination path (could be in album name)
                   album_name = sanitize_filepath(album, platform="auto")

                   # create destination folder, if necessary, based on album name
                   dest_dir = os.path.join(export_path, album_name)

                   # verify path is a valid path
                   if not is_valid_filepath(dest_dir, platform="auto"):
                       sys.exit(f"Invalid filepath {dest_dir}")

                   # create destination dir if needed
                   if not os.path.isdir(dest_dir):
                       os.makedirs(dest_dir)

                   # export the photo
                   if p.hasadjustments:
                       # export edited version
                       exported = p.export(dest_dir, edited=True)
                       edited_name = pathlib.Path(p.path_edited).name
                       click.echo(f"Exported {edited_name} to {exported}")
                   # export unedited version
                   exported = p.export(dest_dir)
                   click.echo(f"Exported {p.filename} to {exported}")
           else:
               click.echo(f"Skipping missing photo: {p.filename}")


   if __name__ == "__main__":
       export()  # pylint: disable=no-value-for-parameter

Package Interface
-----------------

Reference full documentation on `GitHub <https://github.com/RhetTbull/osxphotos/blob/master/README.md>`_

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/RhetTbull/",
    "name": "osxphotos",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.13,>=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Rhet Turnbull",
    "author_email": "rturnbull+git@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/5c/2d/b38ed02cebde409c1116517c7607de3a3d1c6d604f33273eb3c58c43b00f/osxphotos-0.68.1.tar.gz",
    "platform": null,
    "description": ".. role:: raw-html-m2r(raw)\n   :format: html\n\n\nosxphotos\n=========\n\nWhat is osxphotos?\n------------------\n\nOSXPhotos provides both the ability to interact with and query Apple's Photos.app library on macOS directly from your python code \nas well as a very flexible command line interface (CLI) app for exporting photos. \nYou can query the Photos library database -- for example, file name, file path, and metadata such as keywords/tags, persons/faces, albums, etc. \nYou can also easily export both the original and edited photos. \n\nSupported operating systems\n---------------------------\n\nOnly works on macOS (aka Mac OS X). Tested on macOS Sierra (10.12.6) through macOS Monterey (12.3).\n\nThis package will read Photos databases for any supported version on any supported macOS version.  \nE.g. you can read a database created with Photos 5.0 on MacOS 10.15 on a machine running macOS 10.12 and vice versa.\n\nRequires python >= ``3.9``. \n\nInstallation\n------------\n\nIf you just want to use the command line application, I recommend you to install using pipx. See other advanced options below. \n\nInstallation using pipx\n^^^^^^^^^^^^^^^^^^^^^^^\n\nIf you aren't familiar with installing python applications, I recommend you install ``osxphotos`` with `pipx <https://github.com/pipxproject/pipx>`_. If you use ``pipx``\\ , you will not need to create a virtual environment as ``pipx`` takes care of this. The easiest way to do this on a Mac is to use `homebrew <https://brew.sh/>`_\\ :\n\n\n* Open ``Terminal`` (search for ``Terminal`` in Spotlight or look in ``Applications/Utilities``\\ )\n* Install ``homebrew`` according to instructions at `https://brew.sh/ <https://brew.sh/>`_\n* Type the following into Terminal: ``brew install pipx``\n* Then type this: ``pipx install osxphotos``\n* Now you should be able to run ``osxphotos`` by typing: ``osxphotos``\n\nInstallation using pip\n^^^^^^^^^^^^^^^^^^^^^^\n\nYou can also install directly from `pypi <https://pypi.org/project/osxphotos/>`_\\ :\n\n.. code-block::\n\n   python3 -m pip install osxphotos\n\nCommand Line Usage\n------------------\n\nThis package will install a command line utility called ``osxphotos`` that allows you to query the Photos database and export photos.  \nAlternatively, you can also run the command line utility like this: ``python3 -m osxphotos``\n\n.. code-block::\n   \n   Usage: osxphotos [OPTIONS] COMMAND [ARGS]...\n   \n     OSXPhotos: the multi-tool for your Photos library.\n   \n     To get help on a specific command, use \"osxphotos COMMAND --help\" or\n     \"osxphotos help COMMAND\"; for example, \"osxphotos help export\".\n   \n     To search help for a specific topic within a command, run \"osxphotos help\n     COMMAND TOPIC\"; for example, \"osxphotos help export keyword\" to get help\n     related to keywords when using the export command.\n   \n     To see the full documentation in your browser, run \"osxphotos docs\".\n   \n     Some advanced commands are hidden by default. To see all commands, run\n     \"OSXPHOTOS_SHOW_HIDDEN=1 osxphotos help\". Some commands also have hidden\n     options. These can be seen by running \"OSXPHOTOS_SHOW_HIDDEN=1 osxphotos\n     help COMMAND\".\n   \n   Options:\n     -v, --version  Show the version and exit.\n     -h, --help     Show this message and exit.\n   \n   Commands:\n     about          Print information about osxphotos including license.\n     add-locations  Add missing location data to photos in Photos.app using...\n     albums         Print out albums found in the Photos library.\n     batch-edit     Batch edit photo metadata such as title, description,...\n     compare        Compare two Photos libraries to find differences\n     docs           Open osxphotos documentation in your browser.\n     dump           Print list of all photos & associated info from the...\n     exiftool       Run exiftool on previously exported files to update...\n     export         Export photos from the Photos database.\n     exportdb       Utilities for working with the osxphotos export database\n     help           Print help; for help on commands: help <command>.\n     import         Import photos and videos into Photos.\n     info           Print out descriptive info of the Photos library database.\n     inspect        Interactively inspect photos selected in Photos.\n     install        Install Python packages into the same environment as...\n     keywords       Print out keywords found in the Photos library.\n     labels         Print out image classification labels found in the...\n     list           Print list of Photos libraries found on the system.\n     orphans        Find orphaned photos in a Photos library\n     persons        Print out persons (faces) found in the Photos library.\n     places         Print out places found in the Photos library.\n     push-exif      Write photo metadata to original files in the Photos...\n     query          Query the Photos database using 1 or more search...\n     repl           Run interactive osxphotos REPL shell (useful for...\n     run            Run a python file using same environment as osxphotos.\n     show           Show photo, album, or folder in Photos from UUID_OR_NAME\n     sync           Sync metadata and albums between Photos libraries.\n     template       Interactively render templates for selected photo.\n     theme          Manage osxphotos color themes.\n     timewarp       Adjust date/time/timezone of photos in Apple Photos.\n     tutorial       Display osxphotos tutorial.\n     uninstall      Uninstall Python packages from the osxphotos environment\n     uuid           Print out unique IDs (UUID) of photos selected in Photos\n     version        Check for new version of osxphotos.\n   \n   To get help on a specific command, use ``osxphotos help <command_name>``\n   \nCommand line examples\n^^^^^^^^^^^^^^^^^^^^^\n\nexport all photos to ~/Desktop/export group in folders by date created\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n``osxphotos export --export-by-date ~/Pictures/Photos\\ Library.photoslibrary ~/Desktop/export``\n\n**Note**\\ : Photos library/database path can also be specified using ``--db`` option:\n\n``osxphotos export --export-by-date --db ~/Pictures/Photos\\ Library.photoslibrary ~/Desktop/export``\n\nfind all photos with keyword \"Kids\" and output results to json file named results.json:\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n``osxphotos query --keyword Kids --json ~/Pictures/Photos\\ Library.photoslibrary >results.json``\n\nexport photos to file structure based on 4-digit year and full name of month of photo's creation date:\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n``osxphotos export ~/Desktop/export --directory \"{created.year}/{created.month}\"``\n\n(by default, it will attempt to use the system library)\n\nexport photos to file structure based on 4-digit year of photo's creation date and add keywords for media type and labels (labels are only awailable on Photos 5 and higher):\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n``osxphotos export ~/Desktop/export --directory \"{created.year}\" --keyword-template \"{label}\" --keyword-template \"{media_type}\"`` \n\nexport default library using 'country name/year' as output directory (but use \"NoCountry/year\" if country not specified), add persons, album names, and year as keywords, write exif metadata to files when exporting, update only changed files, print verbose ouput\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n``osxphotos export ~/Desktop/export --directory \"{place.name.country,NoCountry}/{created.year}\"  --person-keyword --album-keyword --keyword-template \"{created.year}\" --exiftool --update --verbose``\n\nfind all videos larger than 200MB and add them to Photos album \"Big Videos\" creating the album if necessary\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n``osxphotos query --only-movies --min-size 200MB --add-to-album \"Big Videos\"``\n\nExample uses of the package\n---------------------------\n\n.. code-block:: python\n\n   \"\"\" Simple usage of the package \"\"\"\n   import osxphotos\n\n   def main():\n       photosdb = osxphotos.PhotosDB()\n       print(photosdb.keywords)\n       print(photosdb.persons)\n       print(photosdb.album_names)\n\n       print(photosdb.keywords_as_dict)\n       print(photosdb.persons_as_dict)\n       print(photosdb.albums_as_dict)\n\n       # find all photos with Keyword = Foo and containing John Smith\n       photos = photosdb.photos(keywords=[\"Foo\"],persons=[\"John Smith\"])\n\n       # find all photos that include Alice Smith but do not contain the keyword Bar\n       photos = [p for p in photosdb.photos(persons=[\"Alice Smith\"]) \n                   if p not in photosdb.photos(keywords=[\"Bar\"]) ]\n       for p in photos:\n           print(\n               p.uuid,\n               p.filename,\n               p.original_filename,\n               p.date,\n               p.description,\n               p.title,\n               p.keywords,\n               p.albums,\n               p.persons,\n               p.path,\n           )\n\n   if __name__ == \"__main__\":\n       main()\n\n.. code-block:: python\n\n   \"\"\" Export all photos to specified directory using album names as folders\n       If file has been edited, also export the edited version, \n       otherwise, export the original version \n       This will result in duplicate photos if photo is in more than album \"\"\"\n\n   import os.path\n   import pathlib\n   import sys\n\n   import click\n   from pathvalidate import is_valid_filepath, sanitize_filepath\n\n   import osxphotos\n\n\n   @click.command()\n   @click.argument(\"export_path\", type=click.Path(exists=True))\n   @click.option(\n       \"--default-album\",\n       help=\"Default folder for photos with no album. Defaults to 'unfiled'\",\n       default=\"unfiled\",\n   )\n   @click.option(\n       \"--library-path\",\n       help=\"Path to Photos library, default to last used library\",\n       default=None,\n   )\n   def export(export_path, default_album, library_path):\n       export_path = os.path.expanduser(export_path)\n       library_path = os.path.expanduser(library_path) if library_path else None\n\n       if library_path is not None:\n           photosdb = osxphotos.PhotosDB(library_path)\n       else:\n           photosdb = osxphotos.PhotosDB()\n\n       photos = photosdb.photos()\n\n       for p in photos:\n           if not p.ismissing:\n               albums = p.albums\n               if not albums:\n                   albums = [default_album]\n               for album in albums:\n                   click.echo(f\"exporting {p.filename} in album {album}\")\n\n                   # make sure no invalid characters in destination path (could be in album name)\n                   album_name = sanitize_filepath(album, platform=\"auto\")\n\n                   # create destination folder, if necessary, based on album name\n                   dest_dir = os.path.join(export_path, album_name)\n\n                   # verify path is a valid path\n                   if not is_valid_filepath(dest_dir, platform=\"auto\"):\n                       sys.exit(f\"Invalid filepath {dest_dir}\")\n\n                   # create destination dir if needed\n                   if not os.path.isdir(dest_dir):\n                       os.makedirs(dest_dir)\n\n                   # export the photo\n                   if p.hasadjustments:\n                       # export edited version\n                       exported = p.export(dest_dir, edited=True)\n                       edited_name = pathlib.Path(p.path_edited).name\n                       click.echo(f\"Exported {edited_name} to {exported}\")\n                   # export unedited version\n                   exported = p.export(dest_dir)\n                   click.echo(f\"Exported {p.filename} to {exported}\")\n           else:\n               click.echo(f\"Skipping missing photo: {p.filename}\")\n\n\n   if __name__ == \"__main__\":\n       export()  # pylint: disable=no-value-for-parameter\n\nPackage Interface\n-----------------\n\nReference full documentation on `GitHub <https://github.com/RhetTbull/osxphotos/blob/master/README.md>`_\n",
    "bugtrack_url": null,
    "license": "License :: OSI Approved :: MIT License",
    "summary": "Export photos from Apple's macOS Photos app and query the Photos library database to access metadata about images.",
    "version": "0.68.1",
    "project_urls": {
        "Download": "https://github.com/RhetTbull/osxphotos",
        "GitHub": "https://github.com/RhetTbull/osxphotos",
        "Homepage": "https://github.com/RhetTbull/"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8fe35950401d08a3a5621e4f150667478e8b0bbef208028c2a49849865215beb",
                "md5": "0b31b2d1083d45de41e7d69a06fc6b8d",
                "sha256": "443dcedfa32b25f8125edf9917b53d2c24351335f3aabf2e15f318267d41b30a"
            },
            "downloads": -1,
            "filename": "osxphotos-0.68.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0b31b2d1083d45de41e7d69a06fc6b8d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.13,>=3.9",
            "size": 1870010,
            "upload_time": "2024-06-12T00:20:38",
            "upload_time_iso_8601": "2024-06-12T00:20:38.664939Z",
            "url": "https://files.pythonhosted.org/packages/8f/e3/5950401d08a3a5621e4f150667478e8b0bbef208028c2a49849865215beb/osxphotos-0.68.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5c2db38ed02cebde409c1116517c7607de3a3d1c6d604f33273eb3c58c43b00f",
                "md5": "d5dc8f11673da39394f29f664246f595",
                "sha256": "e9729be53f752908037980cfa948a17e8f6afcd928496f71f446f6ead907313b"
            },
            "downloads": -1,
            "filename": "osxphotos-0.68.1.tar.gz",
            "has_sig": false,
            "md5_digest": "d5dc8f11673da39394f29f664246f595",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.13,>=3.9",
            "size": 2152370,
            "upload_time": "2024-06-12T00:20:49",
            "upload_time_iso_8601": "2024-06-12T00:20:49.691864Z",
            "url": "https://files.pythonhosted.org/packages/5c/2d/b38ed02cebde409c1116517c7607de3a3d1c6d604f33273eb3c58c43b00f/osxphotos-0.68.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-12 00:20:49",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "RhetTbull",
    "github_project": "osxphotos",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "bitmath",
            "specs": [
                [
                    ">=",
                    "1.3.3.1"
                ],
                [
                    "<",
                    "1.4.0.0"
                ]
            ]
        },
        {
            "name": "bpylist2",
            "specs": [
                [
                    "<",
                    "5.0.0"
                ],
                [
                    ">=",
                    "4.1.1"
                ]
            ]
        },
        {
            "name": "cgmetadata",
            "specs": [
                [
                    ">=",
                    "0.1.6"
                ]
            ]
        },
        {
            "name": "Click",
            "specs": [
                [
                    "<",
                    "9.0"
                ],
                [
                    ">=",
                    "8.1.3"
                ]
            ]
        },
        {
            "name": "mac-alias",
            "specs": [
                [
                    "<",
                    "3.0.0"
                ],
                [
                    ">=",
                    "2.2.2"
                ]
            ]
        },
        {
            "name": "makelive",
            "specs": [
                [
                    ">=",
                    "0.5.0"
                ]
            ]
        },
        {
            "name": "Mako",
            "specs": [
                [
                    ">=",
                    "1.2.2"
                ],
                [
                    "<",
                    "1.3.0"
                ]
            ]
        },
        {
            "name": "more-itertools",
            "specs": [
                [
                    ">=",
                    "8.8.0"
                ],
                [
                    "<",
                    "9.0.0"
                ]
            ]
        },
        {
            "name": "objexplore",
            "specs": [
                [
                    "<",
                    "2.0.0"
                ],
                [
                    ">=",
                    "1.6.3"
                ]
            ]
        },
        {
            "name": "osxmetadata",
            "specs": [
                [
                    ">=",
                    "1.3.2"
                ],
                [
                    "<",
                    "2.0.0"
                ]
            ]
        },
        {
            "name": "packaging",
            "specs": [
                [
                    ">=",
                    "21.3"
                ]
            ]
        },
        {
            "name": "pathvalidate",
            "specs": [
                [
                    "<",
                    "4.0.0"
                ],
                [
                    ">=",
                    "2.4.1"
                ]
            ]
        },
        {
            "name": "photoscript",
            "specs": [
                [
                    ">=",
                    "0.3.0"
                ],
                [
                    "<",
                    "0.4.0"
                ]
            ]
        },
        {
            "name": "pip",
            "specs": []
        },
        {
            "name": "ptpython",
            "specs": [
                [
                    "<",
                    "4.0.0"
                ],
                [
                    ">=",
                    "3.0.20"
                ]
            ]
        },
        {
            "name": "pyobjc-core",
            "specs": [
                [
                    ">=",
                    "9.0"
                ],
                [
                    "<",
                    "10.0"
                ]
            ]
        },
        {
            "name": "pyobjc-core",
            "specs": [
                [
                    "<",
                    "11.0"
                ],
                [
                    ">=",
                    "9.0"
                ]
            ]
        },
        {
            "name": "pyobjc-framework-AppleScriptKit",
            "specs": [
                [
                    ">=",
                    "9.0"
                ],
                [
                    "<",
                    "10.0"
                ]
            ]
        },
        {
            "name": "pyobjc-framework-AppleScriptKit",
            "specs": [
                [
                    "<",
                    "11.0"
                ],
                [
                    ">=",
                    "9.0"
                ]
            ]
        },
        {
            "name": "pyobjc-framework-AppleScriptObjC",
            "specs": [
                [
                    ">=",
                    "9.0"
                ],
                [
                    "<",
                    "10.0"
                ]
            ]
        },
        {
            "name": "pyobjc-framework-AppleScriptObjC",
            "specs": [
                [
                    "<",
                    "11.0"
                ],
                [
                    ">=",
                    "9.0"
                ]
            ]
        },
        {
            "name": "pyobjc-framework-AVFoundation",
            "specs": [
                [
                    ">=",
                    "9.0"
                ],
                [
                    "<",
                    "10.0"
                ]
            ]
        },
        {
            "name": "pyobjc-framework-AVFoundation",
            "specs": [
                [
                    "<",
                    "11.0"
                ],
                [
                    ">=",
                    "9.0"
                ]
            ]
        },
        {
            "name": "pyobjc-framework-Cocoa",
            "specs": [
                [
                    ">=",
                    "9.0"
                ],
                [
                    "<",
                    "10.0"
                ]
            ]
        },
        {
            "name": "pyobjc-framework-Cocoa",
            "specs": [
                [
                    "<",
                    "11.0"
                ],
                [
                    ">=",
                    "9.0"
                ]
            ]
        },
        {
            "name": "pyobjc-framework-CoreServices",
            "specs": [
                [
                    ">=",
                    "9.0"
                ],
                [
                    "<",
                    "10.0"
                ]
            ]
        },
        {
            "name": "pyobjc-framework-CoreServices",
            "specs": [
                [
                    "<",
                    "11.0"
                ],
                [
                    ">=",
                    "9.0"
                ]
            ]
        },
        {
            "name": "pyobjc-framework-Metal",
            "specs": [
                [
                    ">=",
                    "9.0"
                ],
                [
                    "<",
                    "10.0"
                ]
            ]
        },
        {
            "name": "pyobjc-framework-Metal",
            "specs": [
                [
                    "<",
                    "11.0"
                ],
                [
                    ">=",
                    "9.0"
                ]
            ]
        },
        {
            "name": "pyobjc-framework-Photos",
            "specs": [
                [
                    ">=",
                    "9.0"
                ],
                [
                    "<",
                    "10.0"
                ]
            ]
        },
        {
            "name": "pyobjc-framework-Photos",
            "specs": [
                [
                    "<",
                    "11.0"
                ],
                [
                    ">=",
                    "9.0"
                ]
            ]
        },
        {
            "name": "pyobjc-framework-Quartz",
            "specs": [
                [
                    ">=",
                    "9.0"
                ],
                [
                    "<",
                    "10.0"
                ]
            ]
        },
        {
            "name": "pyobjc-framework-Quartz",
            "specs": [
                [
                    "<",
                    "11.0"
                ],
                [
                    ">=",
                    "9.0"
                ]
            ]
        },
        {
            "name": "pyobjc-framework-Vision",
            "specs": [
                [
                    ">=",
                    "9.0"
                ],
                [
                    "<",
                    "10.0"
                ]
            ]
        },
        {
            "name": "pyobjc-framework-Vision",
            "specs": [
                [
                    "<",
                    "11.0"
                ],
                [
                    ">=",
                    "9.0"
                ]
            ]
        },
        {
            "name": "pytimeparse2",
            "specs": [
                [
                    ">=",
                    "1.4.0"
                ],
                [
                    "<",
                    "2.0.0"
                ]
            ]
        },
        {
            "name": "PyYAML",
            "specs": [
                [
                    "<",
                    "7.0.0"
                ],
                [
                    ">=",
                    "6.0.0"
                ]
            ]
        },
        {
            "name": "requests",
            "specs": [
                [
                    "<",
                    "3.0.0"
                ],
                [
                    ">=",
                    "2.27.1"
                ]
            ]
        },
        {
            "name": "rich_theme_manager",
            "specs": [
                [
                    ">=",
                    "0.11.0"
                ]
            ]
        },
        {
            "name": "rich",
            "specs": [
                [
                    "<",
                    "14.0.0"
                ],
                [
                    ">=",
                    "13.5.2"
                ]
            ]
        },
        {
            "name": "shortuuid",
            "specs": [
                [
                    "<",
                    "2.0.0"
                ],
                [
                    ">=",
                    "1.0.9"
                ]
            ]
        },
        {
            "name": "strpdatetime",
            "specs": [
                [
                    ">=",
                    "0.3.0"
                ]
            ]
        },
        {
            "name": "tenacity",
            "specs": [
                [
                    ">=",
                    "8.0.1"
                ],
                [
                    "<",
                    "9.0.0"
                ]
            ]
        },
        {
            "name": "textx",
            "specs": [
                [
                    "<",
                    "5.0.0"
                ],
                [
                    ">=",
                    "4.0.1"
                ]
            ]
        },
        {
            "name": "toml",
            "specs": [
                [
                    ">=",
                    "0.10.2"
                ],
                [
                    "<",
                    "0.11.0"
                ]
            ]
        },
        {
            "name": "wrapt",
            "specs": [
                [
                    "<",
                    "2.0.0"
                ],
                [
                    ">=",
                    "1.14.1"
                ]
            ]
        },
        {
            "name": "wurlitzer",
            "specs": [
                [
                    "<",
                    "4.0.0"
                ],
                [
                    ">=",
                    "3.0.2"
                ]
            ]
        },
        {
            "name": "xdg-base-dirs",
            "specs": [
                [
                    ">=",
                    "6.0.0"
                ]
            ]
        },
        {
            "name": "xdg",
            "specs": [
                [
                    "==",
                    "5.1.1"
                ]
            ]
        }
    ],
    "lcname": "osxphotos"
}
        
Elapsed time: 0.24833s