Add matrix 'Today x years ago'
This commit is contained in:
parent
073cb1d320
commit
52f935a084
8 changed files with 1011 additions and 255 deletions
26
synology.py
26
synology.py
|
@ -35,6 +35,29 @@ LIMIT %s;
|
|||
cur.close()
|
||||
|
||||
return pictures
|
||||
|
||||
def fetch_path_for_names_day_and_month(conn, names, month, day, limit=1):
|
||||
sql_query = """
|
||||
SELECT folder.name, unit.filename, user_info.name AS user, EXTRACT(YEAR FROM to_timestamp(unit.takentime)::date) as year
|
||||
FROM unit
|
||||
LEFT OUTER JOIN face ON face.ref_id_unit = unit.id
|
||||
LEFT OUTER JOIN folder ON folder.id = unit.id_folder
|
||||
LEFT OUTER JOIN user_info ON user_info.id = unit.id_user
|
||||
WHERE
|
||||
face.id_person in (SELECT id FROM person WHERE lower(name) SIMILAR TO %s)
|
||||
AND
|
||||
EXTRACT(MONTH FROM to_timestamp(unit.takentime)::date) = %s
|
||||
AND
|
||||
EXTRACT(DAY FROM to_timestamp(unit.takentime)::date) = %s
|
||||
ORDER BY random()
|
||||
LIMIT %s;
|
||||
"""
|
||||
cur = conn.cursor()
|
||||
cur.execute(sql_query, ('%(' + names + ')%', month, day, limit))
|
||||
pictures = cur.fetchall()
|
||||
cur.close()
|
||||
|
||||
return pictures
|
||||
|
||||
def fetch_files(remotehost, pictures):
|
||||
dirpath = tempfile.mkdtemp()
|
||||
|
@ -44,12 +67,13 @@ def fetch_files(remotehost, pictures):
|
|||
path = picture[0]
|
||||
name = picture[1]
|
||||
user = picture[2]
|
||||
year = picture[3] + "-" if len(picture) > 3 else ""
|
||||
if user == '/volume1/photo':
|
||||
lib_path = "/photo"
|
||||
else:
|
||||
lib_path = "/homes/" + user + "/Photos"
|
||||
remotefile = '\ '.join('/'.join([lib_path, path, name]).split())
|
||||
localfile = '/'.join([dirpath, name])
|
||||
localfile = '/'.join([dirpath, str(year) + name])
|
||||
escaped_remotefile = helper.escape_file_path(remotefile)
|
||||
cmd = 'scp -P 23 "' + remotehost + ':' + escaped_remotefile + '" "' + localfile + '"'
|
||||
if os.system(cmd) == 0:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue