Check number of web links

merge-requests/30/head
Bob Mottram 2021-03-15 15:30:36 +00:00
parent 93d151039b
commit e4d379bba3
1 changed files with 18 additions and 15 deletions

View File

@ -440,7 +440,8 @@ def _showLocalBox(boxName: str,
while len(content) < 40: while len(content) < 40:
content += ' ' content += ' '
if speakerJson.get('detectedLinks'): if speakerJson.get('detectedLinks'):
content = '🔗' + content if len(speakerJson['detectedLinks']) > 0:
content = '🔗' + content
content = (content[:40]) if len(content) > 40 else content content = (content[:40]) if len(content) > 40 else content
print(indent + str(posStr) + ' | ' + str(name) + ' | ' + print(indent + str(posStr) + ' | ' + str(name) + ' | ' +
str(published) + ' | ' + str(content) + ' |') str(published) + ' | ' + str(content) + ' |')
@ -1159,21 +1160,23 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
_getSpeakerJsonFromIndex(currTimeline, currIndex) _getSpeakerJsonFromIndex(currTimeline, currIndex)
if not speakerJson: if not speakerJson:
speakerJson = {} speakerJson = {}
print('speakerJson: ' + str(speakerJson)) linkOpened = False
if speakerJson.get('detectedLinks'): if speakerJson.get('detectedLinks'):
if ' ' in keyPress: if len(speakerJson['detectedLinks']) > 0:
postIndex = keyPress.split(' ')[1].strip() if ' ' in keyPress:
print('postIndex: ' + str(postIndex)) postIndex = keyPress.split(' ')[1].strip()
if postIndex.isdigit(): if postIndex.isdigit():
speakerJson = \ speakerJson = \
_getSpeakerJsonFromIndex(currTimeline, _getSpeakerJsonFromIndex(currTimeline,
int(postIndex)) int(postIndex))
sayStr = 'Opening web links in browser.' for url in speakerJson['detectedLinks']:
_sayCommand(sayStr, sayStr, originalScreenReader, if '://' in url:
systemLanguage, espeak) webbrowser.open(url)
for url in speakerJson['detectedLinks']: linkOpened = True
if '://' in url: if linkOpened:
webbrowser.open(url) sayStr = 'Opened web links'
_sayCommand(sayStr, sayStr, originalScreenReader,
systemLanguage, espeak)
else: else:
sayStr = 'There are no web links to open.' sayStr = 'There are no web links to open.'
_sayCommand(sayStr, sayStr, originalScreenReader, _sayCommand(sayStr, sayStr, originalScreenReader,