X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=local_photos_mirror_renderer.py;fp=local_photos_mirror_renderer.py;h=0b8f7fc0a4b9e8724b8dc257e1df35724c121785;hb=d6990436e08a57ce211b10058dc61fb223cb94ec;hp=32e0c1e3e06a60c53acbb495864933908ee72d07;hpb=37b72e72c59140c4a6f7f541c716e4b0bc254b08;p=kiosk.git diff --git a/local_photos_mirror_renderer.py b/local_photos_mirror_renderer.py index 32e0c1e..0b8f7fc 100644 --- a/local_photos_mirror_renderer.py +++ b/local_photos_mirror_renderer.py @@ -2,6 +2,7 @@ import os import file_writer import renderer import random +import re class local_photos_mirror_renderer(renderer.debuggable_abstaining_renderer): """A renderer that uses a local mirror of Google photos""" @@ -9,28 +10,38 @@ class local_photos_mirror_renderer(renderer.debuggable_abstaining_renderer): album_root_directory = "/usr/local/export/www/gphotos/albums" album_whitelist = frozenset([ - '1208 Newer Alex Photos', - '1013 Scott and Lynn', - '0106 Key West 2019', - '1017 Olympic Sculpture Park', - '0212 Chihuly Glass', - '0730 Trip to East Coast \'16', - '0715 Barn', - '1009 East Coast 2018', - '0819 Skiing with Alex', - '0819 Friends', - '0227 Trip to California, \'16', - '0407 London, 2018', - '0528 Ohme Gardens', - '0809 Bangkok and Phuket, 2003', - '0803 Blue Angels... Seafair', - '0719 Dunn Gardens', - '0514 Krakow 2009', - '0515 Tuscany 2008', - '0508 Yosemite 2010', - '0611 Sonoma', - '1025 NJ 2015', - '0407 Las Vegas, 2017', + '8-Mile Lake Hike', + 'Bangkok and Phuket, 2003', + 'Barn', + 'Blue Angels... Seafair', + 'Chihuly Glass', + 'Dunn Gardens', + 'East Coast 2018', + 'Fall \'17', + 'Friends', + 'Hiking', + 'Key West 2019', + 'Krakow 2009', + 'Kubota Gardens', + 'Las Vegas, 2017', + 'London, 2018', + 'Munich, July 2018', + 'NJ 2015', + 'Newer Alex Photos', + 'Ohme Gardens', + 'Olympic Sculpture Park', + 'Prague and Munich 2019', + 'Random', + 'Scott and Lynn', + 'SFO 2014', + 'Skiing with Alex', + 'Sonoma', + 'Trip to California, \'16', + 'Trip to San Francisco', + 'Trip to East Coast \'16', + 'Tuscany 2008', + 'Yosemite 2010', + 'Zoo', ]) extension_whitelist = frozenset([ @@ -56,12 +67,18 @@ class local_photos_mirror_renderer(renderer.debuggable_abstaining_renderer): else: raise error('Unexpected operation') + def album_is_in_whitelist(self, name): + for wlalbum in self.album_whitelist: + if re.search('\d+ %s' % wlalbum, name) != None: + return True + return False + # Walk the filesystem looking for photos in whitelisted albums and # keep their paths in memory. def index_photos(self): for root, subdirs, files in os.walk(self.album_root_directory): last_dir = root.rsplit('/', 1)[1] - if last_dir in self.album_whitelist: + if self.album_is_in_whitelist(last_dir): for x in files: extension = x.rsplit('.', 1)[1] if extension in self.extension_whitelist: @@ -79,7 +96,7 @@ class local_photos_mirror_renderer(renderer.debuggable_abstaining_renderer): print("No photos!") return False path = random.sample(self.candidate_photos, 1)[0] - f = file_writer.file_writer('photo_23_none.html') + f = file_writer.file_writer('photo_23_3600.html') f.write("""