mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
4de012144a
commit
6c460743b8
|
|
@ -389,6 +389,35 @@ def _textOnlyContent(content: str) -> str:
|
||||||
return removeHtml(content)
|
return removeHtml(content)
|
||||||
|
|
||||||
|
|
||||||
|
def _getImageDescription(postJsonObject: {}) -> str:
|
||||||
|
"""Returns a image description/s on a post
|
||||||
|
"""
|
||||||
|
imageDescription = ''
|
||||||
|
if not postJsonObject['object'].get('attachment'):
|
||||||
|
return imageDescription
|
||||||
|
|
||||||
|
attachList = postJsonObject['object']['attachment']
|
||||||
|
if not isinstance(attachList, list):
|
||||||
|
return imageDescription
|
||||||
|
|
||||||
|
# for each attachment
|
||||||
|
for img in attachList:
|
||||||
|
if not isinstance(img, dict):
|
||||||
|
continue
|
||||||
|
if not img.get('name'):
|
||||||
|
continue
|
||||||
|
if not isinstance(img['name'], str):
|
||||||
|
continue
|
||||||
|
messageStr = img['name']
|
||||||
|
if messageStr:
|
||||||
|
messageStr = messageStr.strip()
|
||||||
|
if not messageStr.endswith('.'):
|
||||||
|
imageDescription += messageStr + '. '
|
||||||
|
else:
|
||||||
|
imageDescription += messageStr + ' '
|
||||||
|
return imageDescription
|
||||||
|
|
||||||
|
|
||||||
def _readLocalBoxPost(session, nickname: str, domain: str,
|
def _readLocalBoxPost(session, nickname: str, domain: str,
|
||||||
httpPrefix: str, baseDir: str, boxName: str,
|
httpPrefix: str, baseDir: str, boxName: str,
|
||||||
pageNumber: int, index: int, boxJson: {},
|
pageNumber: int, index: int, boxJson: {},
|
||||||
|
|
@ -440,6 +469,7 @@ def _readLocalBoxPost(session, nickname: str, domain: str,
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
content = \
|
content = \
|
||||||
_textOnlyContent(postJsonObject2['object']['content'])
|
_textOnlyContent(postJsonObject2['object']['content'])
|
||||||
|
content += _getImageDescription(postJsonObject2)
|
||||||
messageStr, detectedLinks = \
|
messageStr, detectedLinks = \
|
||||||
speakableText(baseDir, content, translate)
|
speakableText(baseDir, content, translate)
|
||||||
sayStr = content
|
sayStr = content
|
||||||
|
|
@ -451,6 +481,7 @@ def _readLocalBoxPost(session, nickname: str, domain: str,
|
||||||
actor = postJsonObject['object']['attributedTo']
|
actor = postJsonObject['object']['attributedTo']
|
||||||
nameStr = getNicknameFromActor(actor)
|
nameStr = getNicknameFromActor(actor)
|
||||||
content = _textOnlyContent(postJsonObject['object']['content'])
|
content = _textOnlyContent(postJsonObject['object']['content'])
|
||||||
|
content += _getImageDescription(postJsonObject)
|
||||||
|
|
||||||
if isPGPEncrypted(content):
|
if isPGPEncrypted(content):
|
||||||
sayStr = 'Encrypted message. Please enter your passphrase.'
|
sayStr = 'Encrypted message. Please enter your passphrase.'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue