diff --git a/README.md b/README.md index 7940c167..a1a77068 100644 --- a/README.md +++ b/README.md @@ -141,7 +141,7 @@ Returns path to last opened Photo Library as string. #### ```list_photo_libraries()``` -Returns list of Photos libraries found in the user's Pictures folder. +Returns list of Photos libraries found on the system ### PhotosDB diff --git a/osxphotos/__init__.py b/osxphotos/__init__.py index e80dc06a..acfce319 100644 --- a/osxphotos/__init__.py +++ b/osxphotos/__init__.py @@ -1,8 +1,8 @@ -import glob import json import logging import os.path import platform +import subprocess import sqlite3 import sys import tempfile @@ -191,8 +191,16 @@ def get_last_library_path(): def list_photo_libraries(): - """ returns list of Photos libraries found in the user's Pictures folder """ - lib_list = glob.glob(f"{str(Path.home())}/Pictures/*.photoslibrary") + """ returns list of Photos libraries found on the system """ + # lib_list = glob.glob(f"{str(Path.home())}/Pictures/*.photoslibrary") + # return lib_list + + lib_list = [] + output = subprocess.check_output( + ["/usr/bin/mdfind", "-onlyin", "/", "-name", ".photoslibrary"] + ).splitlines() + for lib in output: + lib_list.append(lib.decode("utf-8")) return lib_list