mirror of https://gitlab.com/bashrc2/epicyon
Function for valid item ID
parent
544c8745ad
commit
00ba237ab9
10
shares.py
10
shares.py
|
@ -22,6 +22,12 @@ from utils import loadJson
|
||||||
from utils import saveJson
|
from utils import saveJson
|
||||||
from media import removeMetaData
|
from media import removeMetaData
|
||||||
|
|
||||||
|
def getValidItemID(displayName: str) -> str:
|
||||||
|
"""Removes any invalid characters from the display name to
|
||||||
|
produce an item ID
|
||||||
|
"""
|
||||||
|
return displayName.replace(' ','').replace('/','-').replace('\\','-').replace('.','_').replace('?','-').replace('\n','').replace("’","'")
|
||||||
|
|
||||||
def removeShare(baseDir: str,nickname: str,domain: str, \
|
def removeShare(baseDir: str,nickname: str,domain: str, \
|
||||||
displayName: str) -> None:
|
displayName: str) -> None:
|
||||||
"""Removes a share for a person
|
"""Removes a share for a person
|
||||||
|
@ -30,7 +36,7 @@ def removeShare(baseDir: str,nickname: str,domain: str, \
|
||||||
if os.path.isfile(sharesFilename):
|
if os.path.isfile(sharesFilename):
|
||||||
sharesJson=loadJson(sharesFilename)
|
sharesJson=loadJson(sharesFilename)
|
||||||
|
|
||||||
itemID=displayName.replace(' ','')
|
itemID=getValidItemID(displayName)
|
||||||
if sharesJson.get(itemID):
|
if sharesJson.get(itemID):
|
||||||
# remove any image for the item
|
# remove any image for the item
|
||||||
itemIDfile=baseDir+'/sharefiles/'+itemID
|
itemIDfile=baseDir+'/sharefiles/'+itemID
|
||||||
|
@ -79,7 +85,7 @@ def addShare(baseDir: str, \
|
||||||
if 'year' in durationList[1]:
|
if 'year' in durationList[1]:
|
||||||
durationSec=published+(int(durationList[0])*60*60*24*365)
|
durationSec=published+(int(durationList[0])*60*60*24*365)
|
||||||
|
|
||||||
itemID=displayName.replace(' ','').replace('/','-').replace('\\','-').replace('.','_').replace('?','-').replace('\n','').replace("’","'")
|
itemID=getValidItemID(displayName)
|
||||||
|
|
||||||
# has an image for this share been uploaded?
|
# has an image for this share been uploaded?
|
||||||
imageUrl=None
|
imageUrl=None
|
||||||
|
|
Loading…
Reference in New Issue