aboutsummaryrefslogtreecommitdiffstats
path: root/scanner/PhotoAlbum.py
diff options
context:
space:
mode:
Diffstat (limited to 'scanner/PhotoAlbum.py')
-rw-r--r--scanner/PhotoAlbum.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/scanner/PhotoAlbum.py b/scanner/PhotoAlbum.py
index 18cd425..50216c9 100644
--- a/scanner/PhotoAlbum.py
+++ b/scanner/PhotoAlbum.py
@@ -52,6 +52,17 @@ class Album(object):
if not self._albums_sorted:
self._albums.sort()
self._albums_sorted = True
+ @property
+ def empty(self):
+ if len(self._photos) != 0:
+ return False
+ if len(self._albums) == 0:
+ return True
+ for album in self._albums:
+ if not album.empty:
+ return False
+ return True
+
def cache(self, base_dir):
self._sort()
fp = open(os.path.join(base_dir, self.cache_path), 'w')
@@ -75,10 +86,15 @@ class Album(object):
return album
def to_dict(self, cripple=True):
self._sort()
+ subalbums = []
if cripple:
- subalbums = [ { "path": trim_base_custom(sub.path, self._path), "date": sub.date } for sub in self._albums ]
+ for sub in self._albums:
+ if not sub.empty:
+ subalbums.append({ "path": trim_base_custom(sub.path, self._path), "date": sub.date })
else:
- subalbums = self._albums
+ for sub in self._albums:
+ if not sub.empty:
+ subalbums.append(sub)
return { "path": self.path, "date": self.date, "albums": subalbums, "photos": self._photos }
def photo_from_path(self, path):
for photo in self._photos: