{ "info": { "author": "Simon Willison", "author_email": "", "bugtrack_url": null, "classifiers": [], "description": "# datasette-bplist\n\n[![PyPI](https://img.shields.io/pypi/v/datasette-bplist.svg)](https://pypi.org/project/datasette-bplist/)\n[![CircleCI](https://circleci.com/gh/simonw/datasette-bplist.svg?style=svg)](https://circleci.com/gh/simonw/datasette-bplist)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/datasette-bplist/blob/master/LICENSE)\n\nDatasette plugin for working with Apple's [binary plist](https://en.wikipedia.org/wiki/Property_list) format.\n\nThis plugin adds two features: a display hook and a SQL function.\n\nThe display hook will detect any database values that are encoded using the binary plist format. It will decode them, convert them into JSON and display them pretty-printed in the Datasette UI.\n\nThe SQL function `bplist_to_json(value)` can be used inside a SQL query to convert a binary plist value into a JSON string. This can then be used with SQLite's `json_extract()` function or with the [datasette-jq](https://github.com/simonw/datasette-jq) plugin to further analyze that data as part of a SQL query.\n\nInstall this plugin in the same environment as Datasette to enable this new functionality:\n\n pip install datasette-bplist\n\n## Trying it out\n\nIf you use a Mac you already have plenty of SQLite databases that contain binary plist data.\n\nOne example is the database that powers the Apple Photos app.\n\nThis database tends to be locked, so you will need to create a copy of the database in order to run queries against it:\n\n cp ~/Pictures/Photos\\ Library.photoslibrary/database/photos.db /tmp/photos.db\n\nThe database also makes use of custom SQLite extensions which prevent it from opening in Datasette.\n\nYou can work around this by exporting the data that you want to experiment with into a new SQLite file.\n\nI recommend trying this plugin against the `RKMaster_dataNote` table, which contains plist-encoded EXIF metadata about the photos you have taken.\n\nYou can export that table into a fresh database like so:\n\n sqlite3 /tmp/photos.db \".dump RKMaster_dataNote\" | sqlite3 /tmp/exif.db\n\nNow run `datasette /tmp/exif.db` and you can start trying out the plugin.\n\n## Using the bplist_to_json() SQL function\n\nOnce you have the `exif.db` demo working, you can try the `bplist_to_json()` SQL function.\n\nHere's a query that shows the camera lenses you have used the most often to take photos:\n\n select\n json_extract(\n bplist_to_json(value),\n \"$.{Exif}.LensModel\"\n ) as lens,\n count(*) as n\n from RKMaster_dataNote\n group by lens\n order by n desc;\n\nIf you have a large number of photos this query can take a long time to execute, so you may need to increase the SQL time limit enforced by Datasette like so:\n\n $ datasette /tmp/exif.db \\\n --config sql_time_limit_ms:10000\n\nHere's another query, showing the time at which you took every photo in your library which is classified as as screenshot:\n\n select\n attachedToId,\n json_extract(\n bplist_to_json(value),\n \"$.{Exif}.DateTimeOriginal\"\n )\n from RKMaster_dataNote\n where\n json_extract(\n bplist_to_json(value),\n \"$.{Exif}.UserComment\"\n ) = \"Screenshot\"\n\nAnd if you install the [datasette-cluster-map](https://github.com/simonw/datasette-cluster-map) plugin, this query will show you a map of your most recent 1000 photos:\n\n select\n *, \n json_extract(\n bplist_to_json(value),\n \"$.{GPS}.Latitude\"\n ) as latitude,\n -json_extract(\n bplist_to_json(value),\n \"$.{GPS}.Longitude\"\n ) as longitude,\n json_extract(\n bplist_to_json(value),\n \"$.{Exif}.DateTimeOriginal\"\n ) as datetime\n from\n RKMaster_dataNote\n where\n latitude is not null\n order by\n attachedToId desc\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/simonw/datasette-bplist", "keywords": "", "license": "Apache License, Version 2.0", "maintainer": "", "maintainer_email": "", "name": "datasette-bplist", "package_url": "https://pypi.org/project/datasette-bplist/", "platform": "", "project_url": "https://pypi.org/project/datasette-bplist/", "project_urls": { "Homepage": "https://github.com/simonw/datasette-bplist" }, "release_url": "https://pypi.org/project/datasette-bplist/0.1/", "requires_dist": [ "datasette", "bpylist", "pytest ; extra == 'test'" ], "requires_python": "", "summary": "Datasette plugin for working with Apple's binary plist format", "version": "0.1" }, "last_serial": 5376623, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "198af42a127b8c2d953489b72fd0d6ec", "sha256": "3befe172d5621287634020e933af9b531567782058a9c1e0f969bbb72488d192" }, "downloads": -1, "filename": "datasette_bplist-0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "198af42a127b8c2d953489b72fd0d6ec", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7599, "upload_time": "2019-06-09T01:17:52", "url": "https://files.pythonhosted.org/packages/47/14/269ee90f057a4672a837a976f4cd96b8622469b2945ddcd62f46dec577db/datasette_bplist-0.1-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "198af42a127b8c2d953489b72fd0d6ec", "sha256": "3befe172d5621287634020e933af9b531567782058a9c1e0f969bbb72488d192" }, "downloads": -1, "filename": "datasette_bplist-0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "198af42a127b8c2d953489b72fd0d6ec", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7599, "upload_time": "2019-06-09T01:17:52", "url": "https://files.pythonhosted.org/packages/47/14/269ee90f057a4672a837a976f4cd96b8622469b2945ddcd62f46dec577db/datasette_bplist-0.1-py3-none-any.whl" } ] }