Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions src/forumparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ def getHTMLdata(self, url, timeout=(3.05, 6)):
del response
return errMsg, htmlData
except exceptions.RequestException as errMsg:
errMsg = str(errMsg)
errMsg = errMsg[:errMsg.rfind(": ")]
print(f"[{MODULE_NAME}] ERROR in class 'FparserHelper:getHTMLdata': {errMsg}")
errMsg = str(errMsg).replace(atvpglobals.BASEURL.replace("https://", ""), "").replace("'", "").replace("/", "")
print(f"[{MODULE_NAME}] ERROR in module 'getHTMLdata': {errMsg}")
return errMsg, htmlData

def createThreadUrl(self, threadId, startPage=0):
Expand All @@ -69,7 +68,7 @@ def setPostKey(key, value, replacements=[]):
try:
xml = BeautifulSoup(htmlData, features="lxml") # .replace('&', '&') # work around BeautifulSoup bug
except Exception as errMsg:
print(f"[{MODULE_NAME}] ERROR in class 'FparserHelper:parseLatest': {errMsg}")
print(f"[{MODULE_NAME}] ERROR in module 'parseLatest': {errMsg}")
threadTitle = "aktuelle Themen"
currPost = startPage
topicList = xml.find("ul", {"class": "topiclist topics collapsible"})
Expand Down Expand Up @@ -108,15 +107,15 @@ def convert2int(valueStr, fallbackInt=0):

if not threadUrl:
errMsg = "No threadUrl given."
print(f"[{MODULE_NAME}] ERROR in class 'FparserHelper:parseThread': {errMsg}")
print(f"[{MODULE_NAME}] ERROR in module 'parseThread': {errMsg}")
return errMsg, {}
errMsg, htmlData = fparser.getHTMLdata(threadUrl)
if errMsg:
return errMsg, {}
try:
xml = BeautifulSoup(htmlData, features="lxml") # .replace('&', '&') # work around BeautifulSoup bug
except Exception as errMsg:
print(f"[{MODULE_NAME}] ERROR in class 'FparserHelper:parseThread': {errMsg}")
print(f"[{MODULE_NAME}] ERROR in module 'parseThread': {errMsg}")
titleLine = xml.title.string.replace(" - openATV Forum", "") # "LCD4linux - Seite 150"
foundpos = titleLine.rfind("Seite")
threadTitle = titleLine[:foundpos - 3] if foundpos != -1 else titleLine
Expand Down Expand Up @@ -171,15 +170,15 @@ def setPostKey(key, value, replacements=[]):
url = f"{atvpglobals.BASEURL}/viewtopic.php?p={postId}#p{postId}"
else:
errMsg = "Neither threadId nor postId given."
print(f"[{MODULE_NAME}] ERROR in class 'FparserHelper:parseThread': {errMsg}")
print(f"[{MODULE_NAME}] ERROR in module 'parseThread': {errMsg}")
return errMsg, []
errMsg, htmlData = fparser.getHTMLdata(url)
if errMsg:
return errMsg, []
try:
xml = BeautifulSoup(htmlData, features="lxml") # .replace('&', '&') # work around BeautifulSoup bug
except Exception as errMsg:
print(f"[{MODULE_NAME}] ERROR in class 'FparserHelper:parseThread': {errMsg}")
print(f"[{MODULE_NAME}] ERROR in module 'parseThread': {errMsg}")
for post in xml.find_all("div", class_=compile("post has-profile (.*?)")):
pId = post.get("id", "").strip("profile")
if postId != pId:
Expand Down
25 changes: 15 additions & 10 deletions src/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,21 +619,26 @@ def __init__(self, session, threadLinks=[], favlink="", favMenu=False):
self.offline = LoadPixmap(cached=True, path=statusFile) if exists(statusFile) else None
copy2(join(self.PLUGINPATH, "icons/user_stat.png"), self.AVATARPATH)
copy2(join(self.PLUGINPATH, "icons/unknown.png"), self.AVATARPATH)
self.onShown.append(self.onShownFinished)
errMsg = fparser.checkServerStatus()
if errMsg:
self.terminateTimer = eTimer() # in order to avoid E2 modal error
self.terminateTimer.callback.append(boundFunction(self.terminatePlugin, errMsg))
self.terminateTimer.start(200, True)
else:
self.onLayoutFinish.append(self.layoutFinished)

def onShownFinished(self):
def layoutFinished(self):
self.showPic(self["button_page"], join(self.PLUGINPATH, f"icons/key_updown_{self.RESOLUTION}.png"), show=False, scale=False)
self.showPic(self["button_keypad"], join(self.PLUGINPATH, f"icons/keypad_{self.RESOLUTION}.png"), show=False, scale=False)
self.updateYellowButton()
errMsg = fparser.checkServerStatus()
if errMsg:
self.displayHTMLerror(errMsg)
self.keyExit()
if self.favlink or self.threadLink and self.threadLinks:
callInThread(self.makeThread, self.displayHTMLerror)
else:
if self.favlink or self.threadLink and self.threadLinks:
callInThread(self.makeThread, self.displayHTMLerror)
else:
callInThread(self.makeLatest, self.displayHTMLerror)
callInThread(self.makeLatest, self.displayHTMLerror)

def terminatePlugin(self, errMsg):
self.displayHTMLerror(errMsg)
self.keyExit()

def displayHTMLerror(self, errMsg=""):
if errMsg:
Expand Down