Skip to content

Commit

Permalink
streamline http messages ahead of #28
Browse files Browse the repository at this point in the history
  • Loading branch information
DGrothe-PhD committed Oct 19, 2024
1 parent fa43ba7 commit 2e5394e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
13 changes: 8 additions & 5 deletions getVideoText.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class VTextStatus(VideoTextUtils):
hasrun = False
page = 100
sub = 1
textNews = RbbText(page)
#textNews = RbbText(page)
aliasesErste = {"1", "das erste", "ard"}
aliasesNdr = {"nord", "ndr"}
aliasesBayern = {"6", "bayern", "br"}
Expand All @@ -49,13 +49,13 @@ def start():
station = input(userWhichVideotext + tellAvailableStations + "\n...:")
#
if station.lower() in VTextStatus.aliasesErste:
VTextStatus.textNews = ARDText(100)
VTextStatus.textNews = ARDText(VTextStatus.page)
elif station.lower() in VTextStatus.aliasesNdr:
VTextStatus.textNews = NDRText(100)
VTextStatus.textNews = NDRText(VTextStatus.page)
elif station.lower() in VTextStatus.aliasesBayern:
VTextStatus.textNews = BayernText(100)
VTextStatus.textNews = BayernText(VTextStatus.page)
else:
pass
VTextStatus.textNews = RbbText(VTextStatus.page)
#
mapping = [ ('ü', 'ü'), ('ä', 'ä'), ('ö', 'ö'), \
( 'Ä', 'Ä'), ('Ö', 'Ö'), ('Ãœ', 'Ü'), ('ß', 'ß') \
Expand Down Expand Up @@ -150,4 +150,7 @@ def browsePage():
# HTTP error or anything
printAndSay(f"Entschuldigung, etwas ist schiefgegangen.\nFehlermeldung:\n{e}")

# Play bye-bye sound
printAndSay("Bye bye")

# pylint: enable=W0718
17 changes: 8 additions & 9 deletions videoText.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,7 @@ def validateSoup(self, contents):
`contents` (Soup(), list of Soup(), NoneType): return object of Soup.find()
Returns:
list of Soup() objects or empty list.\n
If Soup has not found anything, an empty list is returned.\n
If Soup has found exactly one entry, a list with that entry.\n
If Soup has found multiple entries, return `contents`
list of Soup() object(s) or empty list.\n
"""
if isinstance(contents, list) and len(contents) > 0:
return contents
Expand Down Expand Up @@ -122,15 +119,17 @@ def extractPage(self, page: int, sub=1):
addline += " " + linkedPages[-1]
self.lines.append(addline)
except requests.exceptions.HTTPError as httpErr:
print(f'HTTP Fehlermeldung: {httpErr}')
message = f"Die Seite kann nicht angezeigt werden " + \
"(Fehler {httpErr.response.status_code})"
self.lines.append(message)
except requests.exceptions.ConnectionError:
print(VideoTextUtils.pageNotAccessible)
self.lines.append(VideoTextUtils.pageNotAccessible)
except requests.exceptions.Timeout:
print("Zeitüberschreitung")
self.lines.append("Zeitüberschreitung")
except requests.exceptions.RequestException as e:
print(f"Konnte Seite {self.api}... nicht aufrufen. \nFehler: {e}")
self.lines.append(f"Konnte Seite {self.api}... nicht aufrufen. \nFehler: {e}")
except Exception as e:
print("Something went wrong.")
self.lines.append("Etwas lief schief...")
print(f"Fehlermeldung: {e}")
#
def extractJumpingPages(self):
Expand Down

0 comments on commit 2e5394e

Please sign in to comment.