Changed default to PhotosDB.photos(movies=True), closes #177
This commit is contained in:
parent
185483e1aa
commit
ab36264af0
10
README.md
10
README.md
@ -875,7 +875,7 @@ for row in results:
|
||||
conn.close()
|
||||
```
|
||||
|
||||
#### ` photos(keywords=None, uuid=None, persons=None, albums=None, images=True, movies=False, from_date=None, to_date=None, intrash=False)`
|
||||
#### ` photos(keywords=None, uuid=None, persons=None, albums=None, images=True, movies=True, from_date=None, to_date=None, intrash=False)`
|
||||
|
||||
```python
|
||||
# assumes photosdb is a PhotosDB object (see above)
|
||||
@ -906,7 +906,7 @@ photos = photosdb.photos(
|
||||
- ```persons```: list of one or more persons. Returns only photos containing the person(s). If more than one person provided, returns photos that match any of the persons (e.g. treated as "or")
|
||||
- ```albums```: list of one or more album names. Returns only photos contained in the album(s). If more than one album name is provided, returns photos contained in any of the albums (.e.g. treated as "or")
|
||||
- ```images```: bool; if True, returns photos/images; default is True
|
||||
- ```movies```: bool; if True, returns movies/videos; default is False
|
||||
- ```movies```: bool; if True, returns movies/videos; default is True
|
||||
- ```from_date```: datetime.datetime; if provided, finds photos where creation date >= from_date; default is None
|
||||
- ```to_date```: datetime.datetime; if provided, finds photos where creation date <= to_date; default is None
|
||||
- ```intrash```: if True, finds only photos in the "Recently Deleted" or trash folder, if False does not find any photos in the trash; default is False
|
||||
@ -952,15 +952,11 @@ photos2 = photosdb.photos(keywords=["Kids"])
|
||||
photos3 = [p for p in photos2 if p not in photos1]
|
||||
```
|
||||
|
||||
By default, photos() only returns images, not movies. To also get movies, pass movies=True:
|
||||
```python
|
||||
photos_and_movies = photosdb.photos(movies=True)
|
||||
```
|
||||
|
||||
To get only movies:
|
||||
```python
|
||||
movies = photosdb.photos(images=False, movies=True)
|
||||
```
|
||||
|
||||
**Note** PhotosDB.photos() may return a different number of photos than Photos.app reports in the GUI. This is because photos() returns [hidden](#hidden) photos, [shared](#shared) photos, and for [burst](#burst) photos, all selected burst images even if non-selected burst images have not been deleted. Photos only reports 1 single photo for each set of burst images until you "finalize" the burst by selecting key photos and deleting the others using the "Make a selection" option.
|
||||
|
||||
For example, in my library, Photos says I have 19,386 photos and 474 movies. However, PhotosDB.photos() reports 25,002 photos. The difference is due to 5,609 shared photos and 7 hidden photos. (*Note* Shared photos only valid for Photos 5). Similarly, filtering for just movies returns 625 results. The difference between 625 and 474 reported by Photos is due to 151 shared movies.
|
||||
|
||||
@ -650,7 +650,7 @@ def info(ctx, cli_obj, db, json_, photos_library):
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=db)
|
||||
info = {"database_path": photosdb.db_path, "database_version": photosdb.db_version}
|
||||
photos = photosdb.photos()
|
||||
photos = photosdb.photos(movies=False)
|
||||
not_shared_photos = [p for p in photos if not p.shared]
|
||||
info["photo_count"] = len(not_shared_photos)
|
||||
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
""" version info """
|
||||
|
||||
__version__ = "0.30.0"
|
||||
__version__ = "0.30.1"
|
||||
|
||||
@ -2145,7 +2145,7 @@ class PhotosDB:
|
||||
persons=None,
|
||||
albums=None,
|
||||
images=True,
|
||||
movies=False,
|
||||
movies=True,
|
||||
from_date=None,
|
||||
to_date=None,
|
||||
intrash=False,
|
||||
@ -2162,7 +2162,7 @@ class PhotosDB:
|
||||
persons: list of persons to search for
|
||||
albums: list of album names to search for
|
||||
images: if True, returns image files, if False, does not return images; default is True
|
||||
movies: if True, returns movie files, if False, does not return movies; default is False
|
||||
movies: if True, returns movie files, if False, does not return movies; default is True
|
||||
from_date: return photos with creation date >= from_date (datetime.datetime object, default None)
|
||||
to_date: return photos with creation date <= to_date (datetime.datetime object, default None)
|
||||
intrash: if True, returns only images in "Recently deleted items" folder,
|
||||
|
||||
@ -13,6 +13,9 @@ ALBUM_DICT = {}
|
||||
|
||||
UUID_DICT = {"movie": "CfnR005YQ1uvNdq8UcnFtw", "image": "XuKdBnARTB+fPyyY+uh4fQ"}
|
||||
|
||||
PHOTOS_LEN = 6
|
||||
MOVIES_LEN = 1
|
||||
|
||||
|
||||
def test_init():
|
||||
import osxphotos
|
||||
@ -97,8 +100,8 @@ def test_count_photos():
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
photos = photosdb.photos()
|
||||
assert len(photos) == 6
|
||||
photos = photosdb.photos(movies=False)
|
||||
assert len(photos) == PHOTOS_LEN
|
||||
|
||||
|
||||
def test_count_movies():
|
||||
@ -106,7 +109,7 @@ def test_count_movies():
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
photos = photosdb.photos(movies=True, images=False)
|
||||
assert len(photos) == 1
|
||||
assert len(photos) == MOVIES_LEN
|
||||
|
||||
|
||||
def test_count_movies_2():
|
||||
@ -114,7 +117,7 @@ def test_count_movies_2():
|
||||
|
||||
# if don't ask for movies=True, won't get any
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
photos = photosdb.photos(uuid=[UUID_DICT["movie"]])
|
||||
photos = photosdb.photos(uuid=[UUID_DICT["movie"]], movies=False)
|
||||
assert len(photos) == 0
|
||||
|
||||
|
||||
@ -123,7 +126,7 @@ def test_count_all():
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
photos = photosdb.photos(images=True, movies=True)
|
||||
assert len(photos) == 7
|
||||
assert len(photos) == PHOTOS_LEN + MOVIES_LEN
|
||||
|
||||
|
||||
def test_uti_movie():
|
||||
|
||||
@ -16,6 +16,9 @@ UUID_DICT = {
|
||||
"image": "FF158787-3EA0-4B06-8D93-4E7E362495DE",
|
||||
}
|
||||
|
||||
PHOTOS_LEN = 6
|
||||
MOVIES_LEN = 1
|
||||
|
||||
|
||||
def test_init():
|
||||
import osxphotos
|
||||
@ -102,8 +105,8 @@ def test_count_photos():
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
photos = photosdb.photos()
|
||||
assert len(photos) == 6
|
||||
photos = photosdb.photos(movies=False)
|
||||
assert len(photos) == PHOTOS_LEN
|
||||
|
||||
|
||||
def test_count_movies():
|
||||
@ -111,7 +114,7 @@ def test_count_movies():
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
photos = photosdb.photos(movies=True, images=False)
|
||||
assert len(photos) == 1
|
||||
assert len(photos) == MOVIES_LEN
|
||||
|
||||
|
||||
def test_count_movies_2():
|
||||
@ -119,7 +122,7 @@ def test_count_movies_2():
|
||||
|
||||
# if don't ask for movies=True, won't get any
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
photos = photosdb.photos(uuid=[UUID_DICT["movie"]])
|
||||
photos = photosdb.photos(uuid=[UUID_DICT["movie"]], movies=False)
|
||||
assert len(photos) == 0
|
||||
|
||||
|
||||
@ -128,7 +131,7 @@ def test_count_all():
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
photos = photosdb.photos(images=True, movies=True)
|
||||
assert len(photos) == 7
|
||||
assert len(photos) == PHOTOS_LEN + MOVIES_LEN
|
||||
|
||||
|
||||
def test_uti_movie():
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user