Add systemd files and passing room-id for matrix
This commit is contained in:
parent
52f935a084
commit
85fd862db4
8 changed files with 96 additions and 16 deletions
32
synology.py
32
synology.py
|
@ -35,7 +35,7 @@ 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
|
||||
|
@ -58,6 +58,34 @@ LIMIT %s;
|
|||
cur.close()
|
||||
|
||||
return pictures
|
||||
|
||||
def fetch_path_for_names_exclude_day_and_month(conn, names, exclude, month, day, limit=1):
|
||||
if exclude == None:
|
||||
return fetch_path_for_names_day_and_month(conn, names, month, day, limit)
|
||||
|
||||
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
|
||||
face.id_person not 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 + ')%', '%(' + exclude + ')%', month, day, limit))
|
||||
pictures = cur.fetchall()
|
||||
cur.close()
|
||||
|
||||
return pictures
|
||||
|
||||
def fetch_files(remotehost, pictures):
|
||||
dirpath = tempfile.mkdtemp()
|
||||
|
@ -67,7 +95,7 @@ def fetch_files(remotehost, pictures):
|
|||
path = picture[0]
|
||||
name = picture[1]
|
||||
user = picture[2]
|
||||
year = picture[3] + "-" if len(picture) > 3 else ""
|
||||
year = str(picture[3]) + "-" if len(picture) > 3 else ""
|
||||
if user == '/volume1/photo':
|
||||
lib_path = "/photo"
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue