mirror of https://gitlab.com/bashrc2/epicyon
Merge branch 'main' of ssh://code.freedombone.net:2222/bashrc/epicyon into main
commit
5bd95384dd
72
shares.py
72
shares.py
|
|
@ -54,15 +54,11 @@ def removeShare(baseDir: str, nickname: str, domain: str,
|
||||||
# remove any image for the item
|
# remove any image for the item
|
||||||
itemIDfile = baseDir + '/sharefiles/' + nickname + '/' + itemID
|
itemIDfile = baseDir + '/sharefiles/' + nickname + '/' + itemID
|
||||||
if sharesJson[itemID]['imageUrl']:
|
if sharesJson[itemID]['imageUrl']:
|
||||||
if sharesJson[itemID]['imageUrl'].endswith('.png'):
|
formats = ('png', 'jpg', 'gif', 'webp', 'avif')
|
||||||
if os.path.isfile(itemIDfile + '.png'):
|
for ext in formats:
|
||||||
os.remove(itemIDfile + '.png')
|
if sharesJson[itemID]['imageUrl'].endswith('.' + ext):
|
||||||
if sharesJson[itemID]['imageUrl'].endswith('.jpg'):
|
if os.path.isfile(itemIDfile + '.' + ext):
|
||||||
if os.path.isfile(itemIDfile + '.jpg'):
|
os.remove(itemIDfile + '.' + ext)
|
||||||
os.remove(itemIDfile + '.jpg')
|
|
||||||
if sharesJson[itemID]['imageUrl'].endswith('.gif'):
|
|
||||||
if os.path.isfile(itemIDfile + '.gif'):
|
|
||||||
os.remove(itemIDfile + '.gif')
|
|
||||||
# remove the item itself
|
# remove the item itself
|
||||||
del sharesJson[itemID]
|
del sharesJson[itemID]
|
||||||
saveJson(sharesJson, sharesFilename)
|
saveJson(sharesJson, sharesFilename)
|
||||||
|
|
@ -76,7 +72,7 @@ def addShare(baseDir: str,
|
||||||
displayName: str, summary: str, imageFilename: str,
|
displayName: str, summary: str, imageFilename: str,
|
||||||
itemType: str, itemCategory: str, location: str,
|
itemType: str, itemCategory: str, location: str,
|
||||||
duration: str, debug: bool) -> None:
|
duration: str, debug: bool) -> None:
|
||||||
"""Updates the likes collection within a post
|
"""Adds a new share
|
||||||
"""
|
"""
|
||||||
sharesFilename = baseDir + '/accounts/' + \
|
sharesFilename = baseDir + '/accounts/' + \
|
||||||
nickname + '@' + domain + '/shares.json'
|
nickname + '@' + domain + '/shares.json'
|
||||||
|
|
@ -112,15 +108,11 @@ def addShare(baseDir: str,
|
||||||
if not imageFilename:
|
if not imageFilename:
|
||||||
sharesImageFilename = \
|
sharesImageFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + '/upload'
|
baseDir + '/accounts/' + nickname + '@' + domain + '/upload'
|
||||||
if os.path.isfile(sharesImageFilename + '.png'):
|
formats = ('png', 'jpg', 'gif', 'webp', 'avif')
|
||||||
imageFilename = sharesImageFilename + '.png'
|
for ext in formats:
|
||||||
moveImage = True
|
if os.path.isfile(sharesImageFilename + '.' + ext):
|
||||||
elif os.path.isfile(sharesImageFilename + '.jpg'):
|
imageFilename = sharesImageFilename + '.' + ext
|
||||||
imageFilename = sharesImageFilename + '.jpg'
|
moveImage = True
|
||||||
moveImage = True
|
|
||||||
elif os.path.isfile(sharesImageFilename + '.gif'):
|
|
||||||
imageFilename = sharesImageFilename + '.gif'
|
|
||||||
moveImage = True
|
|
||||||
|
|
||||||
domainFull = domain
|
domainFull = domain
|
||||||
if port:
|
if port:
|
||||||
|
|
@ -136,27 +128,15 @@ def addShare(baseDir: str,
|
||||||
if not os.path.isdir(baseDir + '/sharefiles/' + nickname):
|
if not os.path.isdir(baseDir + '/sharefiles/' + nickname):
|
||||||
os.mkdir(baseDir + '/sharefiles/' + nickname)
|
os.mkdir(baseDir + '/sharefiles/' + nickname)
|
||||||
itemIDfile = baseDir + '/sharefiles/' + nickname + '/' + itemID
|
itemIDfile = baseDir + '/sharefiles/' + nickname + '/' + itemID
|
||||||
if imageFilename.endswith('.png'):
|
formats = ('png', 'jpg', 'gif', 'webp', 'avif')
|
||||||
removeMetaData(imageFilename, itemIDfile + '.png')
|
for ext in formats:
|
||||||
if moveImage:
|
if imageFilename.endswith('.' + ext):
|
||||||
os.remove(imageFilename)
|
removeMetaData(imageFilename, itemIDfile + '.' + ext)
|
||||||
imageUrl = \
|
if moveImage:
|
||||||
httpPrefix + '://' + domainFull + \
|
os.remove(imageFilename)
|
||||||
'/sharefiles/' + nickname + '/' + itemID + '.png'
|
imageUrl = \
|
||||||
if imageFilename.endswith('.jpg'):
|
httpPrefix + '://' + domainFull + \
|
||||||
removeMetaData(imageFilename, itemIDfile + '.jpg')
|
'/sharefiles/' + nickname + '/' + itemID + '.' + ext
|
||||||
if moveImage:
|
|
||||||
os.remove(imageFilename)
|
|
||||||
imageUrl = \
|
|
||||||
httpPrefix + '://' + domainFull + \
|
|
||||||
'/sharefiles/' + nickname + '/' + itemID + '.jpg'
|
|
||||||
if imageFilename.endswith('.gif'):
|
|
||||||
removeMetaData(imageFilename, itemIDfile + '.gif')
|
|
||||||
if moveImage:
|
|
||||||
os.remove(imageFilename)
|
|
||||||
imageUrl = \
|
|
||||||
httpPrefix + '://' + domainFull + \
|
|
||||||
'/sharefiles/' + nickname + '/' + itemID + '.gif'
|
|
||||||
|
|
||||||
sharesJson[itemID] = {
|
sharesJson[itemID] = {
|
||||||
"displayName": displayName,
|
"displayName": displayName,
|
||||||
|
|
@ -201,7 +181,7 @@ def expireShares(baseDir: str) -> None:
|
||||||
|
|
||||||
|
|
||||||
def expireSharesForAccount(baseDir: str, nickname: str, domain: str) -> None:
|
def expireSharesForAccount(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
"""Removes expired items from shares
|
"""Removes expired items from shares for a particular account
|
||||||
"""
|
"""
|
||||||
handleDomain = domain
|
handleDomain = domain
|
||||||
if ':' in handleDomain:
|
if ':' in handleDomain:
|
||||||
|
|
@ -222,12 +202,10 @@ def expireSharesForAccount(baseDir: str, nickname: str, domain: str) -> None:
|
||||||
# remove any associated images
|
# remove any associated images
|
||||||
itemIDfile = \
|
itemIDfile = \
|
||||||
baseDir + '/sharefiles/' + nickname + '/' + itemID
|
baseDir + '/sharefiles/' + nickname + '/' + itemID
|
||||||
if os.path.isfile(itemIDfile + '.png'):
|
formats = ('png', 'jpg', 'gif', 'webp', 'avif')
|
||||||
os.remove(itemIDfile + '.png')
|
for ext in formats:
|
||||||
if os.path.isfile(itemIDfile + '.jpg'):
|
if os.path.isfile(itemIDfile + '.' + ext):
|
||||||
os.remove(itemIDfile + '.jpg')
|
os.remove(itemIDfile + '.' + ext)
|
||||||
if os.path.isfile(itemIDfile + '.gif'):
|
|
||||||
os.remove(itemIDfile + '.gif')
|
|
||||||
saveJson(sharesJson, sharesFilename)
|
saveJson(sharesJson, sharesFilename)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue