Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,15 @@ The resulting lychee structure will be:
|_a3p1.jpg
```

### Album description

If a `desc.txt` file is present at the root of an album directory, its content will be the description of the album.

### Photo tags

If a `.txt` file that has the same name as the picture is present in its folder, its content is going to be interpreted as tags for the pictures. The expected format is as following :
`tag1, tag2, tag3`


### Counters

Expand Down
10 changes: 5 additions & 5 deletions lycheesync/lycheedao.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ def createAlbum(self, album):
cur = self.db.cursor()
# logger.debug("try to createAlbum: %s", query)
# duplicate of previous query to use driver quote protection features
cur.execute("insert into lychee_albums (id, title, sysstamp, public, password) values (%s,%s,%s,%s,NULL)", (album[
'id'], album['name'], datetime.datetime.now().strftime('%s'), str(self.conf["publicAlbum"])))
cur.execute("insert into lychee_albums (id, title, description, sysstamp, public, password) values (%s,%s,%s,%s,%s,NULL)", (album[
'id'], album['name'], album['description'], datetime.datetime.now().strftime('%s'), str(self.conf["publicAlbum"])))
self.db.commit()

cur.execute("select id from lychee_albums where title=%s", (album['name']))
Expand Down Expand Up @@ -490,7 +490,7 @@ def addFileToAlbum(self, photo):
"(id, url, " +
"public, type, " +
"width, height, " +
"size, star, " +
"size, star, tags, " +
"thumbUrl, album, " +
"iso, aperture, make, " +
"model, shutter, focal, " +
Expand All @@ -500,7 +500,7 @@ def addFileToAlbum(self, photo):
"({}, '{}', " +
"{}, '{}', " +
"{}, {}, " +
"'{}', {}, " +
"'{}', {}, '{}', " +
"'{}', '{}', " +
"'{}', '{}', '{}', " +
"'{}', '{}', '{}', " +
Expand All @@ -509,7 +509,7 @@ def addFileToAlbum(self, photo):
).format(photo.id, photo.url,
self.conf["publicAlbum"], photo.type,
photo.width, photo.height,
photo.size, photo.star,
photo.size, photo.star, photo.tags,
photo.thumbUrl, photo.albumid,
photo.exif.iso, photo.exif.aperture, photo.exif.make,
photo.exif.model, photo.exif.exposure, photo.exif.focal,
Expand Down
5 changes: 3 additions & 2 deletions lycheesync/lycheemodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class LycheePhoto:
height = 0
size = ""
star = 0 # no star by default
tags = ""
thumbUrl = ""
srcfullpath = ""
destfullpath = ""
Expand Down Expand Up @@ -129,14 +130,15 @@ def __generateHash(self):
sha1.update(f.read())
self.checksum = sha1.hexdigest()

def __init__(self, id, conf, photoname, album):
def __init__(self, id, conf, photoname, album, tags):
# Parameters storage
self.conf = conf
self.id = id
self.originalname = photoname
self.originalpath = album['path']
self.albumid = album['id']
self.albumname = album['name']
self.tags = tags

# if star in file name, photo is starred
if ('star' in self.originalname) or ('cover' in self.originalname):
Expand Down Expand Up @@ -240,7 +242,6 @@ def __init__(self, id, conf, photoname, album):
logger.exception("focal not readable for %s", self.srcfullpath)

if decode == "ISOSpeedRatings":

try:
if isinstance(value, tuple):
self.exif.iso = list(value)[0]
Expand Down
15 changes: 14 additions & 1 deletion lycheesync/lycheesyncer.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ def sync(self):
# Init album data
album['id'] = None
album['name'] = None
album['description'] = None
album['path'] = None
album['relpath'] = None # path relative to srcdir
album['photos'] = [] # path relative to srcdir
Expand Down Expand Up @@ -381,6 +382,12 @@ def sync(self):
album['relpath'] = os.path.relpath(album['path'], self.conf['srcdir'])
album['name'] = self.getAlbumNameFromPath(album)

# check for desc.txt file existence
if (os.path.exists(album['path']+"/desc.txt")):
fp = open(album['path']+"/desc.txt", "r")
album['description'] = fp.read()
fp.close()

if len(album['name']) > album_name_max_width:
logger.warn("album name too long, will be truncated " + album['name'])
album['name'] = album['name'][0:album_name_max_width]
Expand Down Expand Up @@ -418,9 +425,15 @@ def sync(self):
logger.info("**** Adding %s to lychee album: %s",
os.path.join(root, f),
album['name'])
# check if tags are stored for a given photo
tags = ""
if os.path.isfile(os.path.join(root, os.path.splitext(f)[0] + ".txt")):
fp = open(os.path.join(root, os.path.splitext(f)[0] + ".txt"), "r")
tags = fp.read()
fp.close()
# corruption detected here by launching exception
pid = self.dao.getUniqPhotoId()
photo = LycheePhoto(pid, self.conf, f, album)
photo = LycheePhoto(pid, self.conf, f, album, tags)
if not(self.dao.photoExists(photo)):
res = self.copyFileToLychee(photo)
self.adjustRotation(photo)
Expand Down