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
2 changes: 1 addition & 1 deletion src/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

__version__ = "2.3"
__version__ = "2.4"
198 changes: 127 additions & 71 deletions src/forumparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#######################################################################################################

# PYTHON IMPORTS
from bs4 import BeautifulSoup
from bs4 import BeautifulSoup, Tag
from getopt import getopt, GetoptError
from json import dump
from re import compile
Expand All @@ -23,32 +23,37 @@


class FParserGlobals:
MODULE_NAME = __name__.split(".")[-1]
BASEURL = "https://www.opena.tv"
MODULE_NAME: str = __name__.split(".")[-1]
BASEURL: str = "https://www.opena.tv"


atvpglobals = FParserGlobals()
fpglobals = FParserGlobals()


class FparserHelper:
def getHTMLdata(self, url, timeout=(3.05, 6)):
errMsg, htmlData = "", ""
try:
response = get(url, timeout=timeout)
response.raise_for_status()
errMsg, htmlData = "", response.text
del response
return errMsg, htmlData
return None, response.text
except exceptions.RequestException as errMsg:
errMsg = str(errMsg).replace(atvpglobals.BASEURL.replace("https://", ""), "").replace("'", "").replace("/", "")
errMsg = str(errMsg).replace(fpglobals.BASEURL.replace("http://", ""), "").replace("host=,'", "")

Check warning on line 39 in src/forumparser.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "errMsg" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=openatv_enigma2-plugin-extensions-openatv-community-reader&issues=AaDX5rYzRgBRhcf64sRx&open=AaDX5rYzRgBRhcf64sRx&pullRequest=46
print(f"[{MODULE_NAME}] ERROR in module 'getHTMLdata': {errMsg}")
return errMsg, htmlData
return errMsg, None

def getBinaryData(self, url, timeout=(3.05, 6)):

Check warning on line 43 in src/forumparser.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename method "getBinaryData" to match the regular expression ^[a-z_][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=openatv_enigma2-plugin-extensions-openatv-community-reader&issues=AaDX5rYzRgBRhcf64sRz&open=AaDX5rYzRgBRhcf64sRz&pullRequest=46
try:
response = get(url, timeout=timeout)
return None, response.content
except exceptions.RequestException as errMsg:
errMsg = str(errMsg).replace(fpglobals.BASEURL.replace("http://", ""), "").replace("host=,'", "")

Check warning on line 48 in src/forumparser.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "errMsg" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=openatv_enigma2-plugin-extensions-openatv-community-reader&issues=AaDX5rYzRgBRhcf64sRy&open=AaDX5rYzRgBRhcf64sRy&pullRequest=46
print(f"[{MODULE_NAME}] ERROR in module 'getBinaryData': {errMsg}")
return errMsg, None

def createThreadUrl(self, threadId, startPage=0):
return f"{atvpglobals.BASEURL}/viewtopic.php?t={threadId}&start={startPage}" if threadId else ""
return f"{fpglobals.BASEURL}/viewtopic.php?t={threadId}&start={startPage}" if threadId else ""

def createPostUrl(self, postId):
return f"{atvpglobals.BASEURL}/viewtopic.php?p={postId}#p{postId}" if postId else ""
return f"{fpglobals.BASEURL}/viewtopic.php?p={postId}#p{postId}" if postId else ""

def parseLatest(self, startPage=0):
def setPostKey(key, value, replacements=[]):
Expand All @@ -60,27 +65,42 @@
latestDict[key] = text

latestList, latestUser = [], []
url = f"{atvpglobals.BASEURL}/index.php?recent_topics_start={startPage}"
url = f"{fpglobals.BASEURL}/index.php?recent_topics_start={startPage}"
errMsg, htmlData = fparser.getHTMLdata(url)
if errMsg:
if errMsg or not htmlData:
return errMsg, {}
pageList, pageUser = [], []
try:
xml = BeautifulSoup(htmlData, features="lxml") # .replace('&', '&') # work around BeautifulSoup bug
except Exception as errMsg:
print(f"[{MODULE_NAME}] ERROR in module 'parseLatest': {errMsg}")
errText = f"[{MODULE_NAME}] ERROR in module 'parseLatest': {errMsg}"

Check warning on line 76 in src/forumparser.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "errText" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=openatv_enigma2-plugin-extensions-openatv-community-reader&issues=AaDX5rYzRgBRhcf64sR0&open=AaDX5rYzRgBRhcf64sR0&pullRequest=46
print(errText)
return errText, {}
threadTitle = "aktuelle Themen"
currPost = startPage
topicList = xml.find("ul", {"class": "topiclist topics collapsible"})
for post in topicList.find_all("dl"):
posts = topicList.find_all("dl") if isinstance(topicList, Tag) else []
for post in posts:
if not isinstance(post, Tag):
continue
latestDict = {}
topicTitle = post.find("a", class_="topictitle")
if not isinstance(topicTitle, Tag):
continue
setPostKey("title", topicTitle)
url = topicTitle.get("href", "")
setPostKey("threadId", url[url.find("?t=") + 3:url.rfind("&sid=")])
href = str(topicTitle.get("href", "") or "")
tThreadPos = href.find("?t=")

Check warning on line 92 in src/forumparser.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "tThreadPos" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=openatv_enigma2-plugin-extensions-openatv-community-reader&issues=AaDX5rYzRgBRhcf64sR2&open=AaDX5rYzRgBRhcf64sR2&pullRequest=46
if tThreadPos == -1:
continue
sidPos = href.rfind("&sid=")

Check warning on line 95 in src/forumparser.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "sidPos" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=openatv_enigma2-plugin-extensions-openatv-community-reader&issues=AaDX5rYzRgBRhcf64sR1&open=AaDX5rYzRgBRhcf64sR1&pullRequest=46
threadId = href[tThreadPos + 3:sidPos if sidPos != -1 else len(href)]

Check warning on line 96 in src/forumparser.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "threadId" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=openatv_enigma2-plugin-extensions-openatv-community-reader&issues=AaDX5rYzRgBRhcf64sR3&open=AaDX5rYzRgBRhcf64sR3&pullRequest=46
setPostKey("threadId", threadId)
respShow = post.find("div", class_="responsive-show")
if not isinstance(respShow, Tag):
continue
userName = respShow.get_text(strip=True)[19:] # "Letzter Beitrag von Testomat « 23 Okt 2025 16:26"
userName = userName[:userName.find("«")]
separator = userName.find("«")
userName = userName[:separator] if separator != -1 else userName
setPostKey("userName", userName)
setPostKey("latestLine", respShow, replacements=(["\t", "\n"]))
setPostKey("sourceLine", post.find('div', class_="responsive-hide"), replacements=(["\t", "\n"]))
Expand Down Expand Up @@ -110,44 +130,65 @@
print(f"[{MODULE_NAME}] ERROR in module 'parseThread': {errMsg}")
return errMsg, {}
errMsg, htmlData = fparser.getHTMLdata(threadUrl)
if errMsg:
if errMsg or not htmlData:
return errMsg, {}
xml = None
try:
xml = BeautifulSoup(htmlData, features="lxml") # .replace('&', '&') # work around BeautifulSoup bug
except Exception as errMsg:
print(f"[{MODULE_NAME}] ERROR in module 'parseThread': {errMsg}")
titleLine = xml.title.string.replace(" - openATV Forum", "") # "LCD4linux - Seite 150"
return f"Failed to parse thread page: {errMsg}", {}
if xml is None:
print(f"[{MODULE_NAME}] ERROR in module 'parseThread': {errMsg}")
return f"Failed to parse thread page: {errMsg}", {}
titleLine = xml.title.string if xml.title else "" # "LCD4linux - Seite 150"

Check warning on line 144 in src/forumparser.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "titleLine" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=openatv_enigma2-plugin-extensions-openatv-community-reader&issues=AaDX5rYzRgBRhcf64sSB&open=AaDX5rYzRgBRhcf64sSB&pullRequest=46
titleLine = titleLine.replace(" - openATV Forum", "") if titleLine else ""
foundpos = titleLine.rfind("Seite")
threadTitle = titleLine[:foundpos - 3] if foundpos != -1 else titleLine
threadId = xml.find("input", {"name": "t", "type": "hidden"}).get("value")
threadInput = xml.find("input", {"name": "t", "type": "hidden"})

Check warning on line 148 in src/forumparser.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "threadInput" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=openatv_enigma2-plugin-extensions-openatv-community-reader&issues=AaDX5rYzRgBRhcf64sR_&open=AaDX5rYzRgBRhcf64sR_&pullRequest=46
threadId = threadInput.get("value") if isinstance(threadInput, Tag) else None

Check warning on line 149 in src/forumparser.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "threadId" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=openatv_enigma2-plugin-extensions-openatv-community-reader&issues=AaDX5rYzRgBRhcf64sR-&open=AaDX5rYzRgBRhcf64sR-&pullRequest=46
pagination = xml.find("div", {"class": "pagination"}) # <div class="pagination"> 21 Beiträge <ul>
pagination = pagination.get_text().strip().split(" ")[0] if pagination else "1"
pagination = pagination.get_text().strip().split(" ")[0] if isinstance(pagination, Tag) else "1"
maxPages = ((int(pagination) - 1) // 20) + 1 if pagination.isdigit() else 1
active = xml.find("li", {"class": "active"}) # <li class="active"><span>11</span></li>
active = active.get_text() if active else "1"
active = active.get_text() if isinstance(active, Tag) else "1"
currPage = int(active) if active.isdigit() else 1
threadList, threadUser = [], []
for post in xml.find_all("div", {"class": compile("post has-profile bg(.*?)")}):
if not post or not isinstance(post, Tag):
continue
threadDict = {}
setThreadKey("postId", post.get("id", "").strip("profile"))
postId = str(post.get("id") or "").strip("profile")

Check warning on line 161 in src/forumparser.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "postId" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=openatv_enigma2-plugin-extensions-openatv-community-reader&issues=AaDX5rYzRgBRhcf64sR7&open=AaDX5rYzRgBRhcf64sR7&pullRequest=46
setThreadKey("postId", postId)
postProfile = post.find("dl", {"class": "postprofile"})
if postProfile:
if isinstance(postProfile, Tag):
userName = postProfile.find("a", {"class": compile("username(.*?)")}) or postProfile.find("span", {"class": compile("username(.*?)")})
userName = userName.get_text()
if userName not in threadUser:
threadUser.append(userName)
setThreadKey("userName", userName)
if isinstance(userName, Tag):
userName = userName.get_text()
if userName not in threadUser:
threadUser.append(userName)
setThreadKey("userName", userName)
avatar = postProfile.find("img", {"class": "avatar"})
if avatar:
avatarUrl = avatar.get("src", "").strip(".")
setThreadKey("avatarUrl", f"{atvpglobals.BASEURL.rstrip('/')}{avatarUrl}" if avatarUrl else None)
profilePosts = postProfile.find_all("dd", {"profile-posts"})
setThreadKey("postsCounter", profilePosts[0].get_text() if len(profilePosts) > 0 else "")
setThreadKey("online", "online" if "online" in post.get("class") else "")
if isinstance(avatar, Tag):
avatarUrl = str(avatar.get("src") or "").strip(".")

Check warning on line 173 in src/forumparser.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "avatarUrl" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=openatv_enigma2-plugin-extensions-openatv-community-reader&issues=AaDX5rYzRgBRhcf64sR4&open=AaDX5rYzRgBRhcf64sR4&pullRequest=46
setThreadKey("avatarUrl", f"{fpglobals.BASEURL}{avatarUrl}" if avatarUrl else "")
profilePosts = postProfile.find_all("dd", class_="profile-posts")

Check warning on line 175 in src/forumparser.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "profilePosts" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=openatv_enigma2-plugin-extensions-openatv-community-reader&issues=AaDX5rYzRgBRhcf64sR9&open=AaDX5rYzRgBRhcf64sR9&pullRequest=46
if profilePosts:
setThreadKey("postsCounter", profilePosts[0].get_text())
postClasses = post.get("class") or []

Check warning on line 178 in src/forumparser.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "postClasses" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=openatv_enigma2-plugin-extensions-openatv-community-reader&issues=AaDX5rYzRgBRhcf64sR6&open=AaDX5rYzRgBRhcf64sR6&pullRequest=46
if isinstance(postClasses, str):
postClasses = [postClasses]
setThreadKey("online", "online" if "online" in postClasses else "")
postBody = post.find("div", {"class": "postbody"})
setThreadKey("postNumber", postBody.find("p", {"class": "author post-number post-number-phpbb post-number-bold"}), replacements=["\n"])
setThreadKey("postTime", postBody.find("time").get_text())
setThreadKey("shortContent", postBody.find("div", {"class": "content"}).get_text(separator=" ", strip=True)[:300]) # limit content as preview
if isinstance(postBody, Tag):
postNumber = postBody.find("p", {"class": "author post-number post-number-phpbb post-number-bold"})

Check warning on line 184 in src/forumparser.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "postNumber" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=openatv_enigma2-plugin-extensions-openatv-community-reader&issues=AaDX5rYzRgBRhcf64sR8&open=AaDX5rYzRgBRhcf64sR8&pullRequest=46
setThreadKey("postNumber", postNumber, replacements=["\n"])
timeEl = postBody.find("time")

Check warning on line 186 in src/forumparser.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "timeEl" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=openatv_enigma2-plugin-extensions-openatv-community-reader&issues=AaDX5rYzRgBRhcf64sSA&open=AaDX5rYzRgBRhcf64sSA&pullRequest=46
if isinstance(timeEl, Tag):
setThreadKey("postTime", timeEl.get_text())
contentEl = postBody.find("div", {"class": "content"})

Check warning on line 189 in src/forumparser.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "contentEl" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=openatv_enigma2-plugin-extensions-openatv-community-reader&issues=AaDX5rYzRgBRhcf64sR5&open=AaDX5rYzRgBRhcf64sR5&pullRequest=46
if isinstance(contentEl, Tag):
setThreadKey("shortContent", contentEl.get_text(separator=" ", strip=True)[:300]) # limit content as preview
threadList.append(threadDict)
return errMsg, {
"threadTitle": threadTitle, "threadId": threadId,
Expand All @@ -156,8 +197,8 @@
}

def checkServerStatus(self):
atvpglobals.BASEURL = bytes.fromhex("687474703A2F2F7265616465722E6F70656E612E7476E"[:-1]).decode()
errMsg, htmlData = self.getHTMLdata(f"{atvpglobals.BASEURL}/index.php")
fpglobals.BASEURL = bytes.fromhex("687474703A2F2F7265616465722E6F70656E612E7476E"[:-1]).decode()
errMsg, _ = self.getHTMLdata(f"{fpglobals.BASEURL}/index.php")

Check warning on line 201 in src/forumparser.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "errMsg" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=openatv_enigma2-plugin-extensions-openatv-community-reader&issues=AaDX5rYzRgBRhcf64sSC&open=AaDX5rYzRgBRhcf64sSC&pullRequest=46
return errMsg

def parsePost(self, postId=""):
Expand All @@ -168,64 +209,79 @@
for replacement in replacements:
text = text.replace(replacement, "")
postDict[key] = text

postDict = {}
if postId:
url = f"{atvpglobals.BASEURL}/viewtopic.php?p={postId}#p{postId}"
url = f"{fpglobals.BASEURL}/viewtopic.php?p={postId}#p{postId}"
else:
errMsg = "Neither threadId nor postId given."
print(f"[{MODULE_NAME}] ERROR in module 'parseThread': {errMsg}")
return errMsg, []
return errMsg, {}
errMsg, htmlData = fparser.getHTMLdata(url)
if errMsg:
return errMsg, []
if errMsg or not htmlData:
return errMsg, {}
try:
xml = BeautifulSoup(htmlData, features="lxml") # .replace('&amp;', '&') # work around BeautifulSoup bug
except Exception as errMsg:
print(f"[{MODULE_NAME}] ERROR in module 'parseThread': {errMsg}")
return str(errMsg), {}
for post in xml.find_all("div", class_=compile("post has-profile .*?")):
pId = post.get("id", "").strip("profile")
if not isinstance(post, Tag):
continue
pId = str(post.get("id", "") or "").strip("profile")

Check warning on line 231 in src/forumparser.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "pId" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=openatv_enigma2-plugin-extensions-openatv-community-reader&issues=AaDX5rYzRgBRhcf64sSG&open=AaDX5rYzRgBRhcf64sSG&pullRequest=46
if postId != pId:
continue
postDict = {}
setPostKey("postId", pId)
postProfile = post.find("dl", {"class": "postprofile"})
if postProfile:
setPostKey("userName", postProfile.find("a", {"class": compile("username(.*?)")}))
if isinstance(postProfile, Tag):
userName = postProfile.find("a", {"class": compile("username(.*?)")})

Check warning on line 238 in src/forumparser.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "userName" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=openatv_enigma2-plugin-extensions-openatv-community-reader&issues=AaDX5rYzRgBRhcf64sSL&open=AaDX5rYzRgBRhcf64sSL&pullRequest=46
if isinstance(userName, Tag):
setPostKey("userName", userName)
setPostKey("online", "online" if "online" in str(post) else "")
avatar = postProfile.find("img", {"class": "avatar"})
if avatar:
avatarUrl = avatar.get("src", "").strip(".")
setPostKey("avatarUrl", f"{atvpglobals.BASEURL.rstrip('/')}{avatarUrl}" if avatarUrl else None)
if isinstance(avatar, Tag):
avatarUrl = str(avatar.get("src", "") or "").strip(".")

Check warning on line 244 in src/forumparser.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "avatarUrl" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=openatv_enigma2-plugin-extensions-openatv-community-reader&issues=AaDX5rYzRgBRhcf64sSD&open=AaDX5rYzRgBRhcf64sSD&pullRequest=46
setPostKey("avatarUrl", f"{fpglobals.BASEURL}{avatarUrl}" if avatarUrl else "")
profileRank = postProfile.find("dd", {"class": "profile-rank"})
if profileRank:
rankUrl = profileRank.img.get("src", "").strip(".")
setPostKey("userTitle", profileRank.img.get("title", ""))
setPostKey("userRank", f"{atvpglobals.BASEURL.rstrip('/')}{rankUrl}" if rankUrl else None)
setPostKey("registered", postProfile.find("dd", {"class": "profile-joined"}).get_text()[:-6])
if isinstance(profileRank, Tag):
rankImg = profileRank.find("img")

Check warning on line 248 in src/forumparser.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "rankImg" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=openatv_enigma2-plugin-extensions-openatv-community-reader&issues=AaDX5rYzRgBRhcf64sSI&open=AaDX5rYzRgBRhcf64sSI&pullRequest=46
if isinstance(rankImg, Tag):
rankUrl = str(rankImg.get("src", "") or "").strip(".")

Check warning on line 250 in src/forumparser.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "rankUrl" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=openatv_enigma2-plugin-extensions-openatv-community-reader&issues=AaDX5rYzRgBRhcf64sSJ&open=AaDX5rYzRgBRhcf64sSJ&pullRequest=46
setPostKey("userTitle", rankImg.get("title", ""))
setPostKey("userRank", f"{fpglobals.BASEURL}{rankUrl}" if rankUrl else "")
joined = postProfile.find("dd", {"class": "profile-joined"})
if isinstance(joined, Tag):
setPostKey("registered", joined.get_text()[:-6])
location = postProfile.find("dd", {"class": "profile-custom-field profile-phpbb_location"})
if location:
if isinstance(location, Tag):
setPostKey("residence", location.get_text())
receivers = postProfile.find_all("dd", {"class": compile("profile-custom-field profile-receiver_.*?")})
receiverList = []
for receiver in receivers:
receiverList.append(receiver.get_text())
if isinstance(receiver, Tag):
receiverList.append(receiver.get_text())
if receiverList:
postDict["receivers"] = receiverList
profilePosts = postProfile.find_all("dd", {"profile-posts"})
profilePosts = postProfile.find_all("dd", class_="profile-posts")

Check warning on line 266 in src/forumparser.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "profilePosts" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=openatv_enigma2-plugin-extensions-openatv-community-reader&issues=AaDX5rYzRgBRhcf64sSH&open=AaDX5rYzRgBRhcf64sSH&pullRequest=46
setPostKey("postsCounter", profilePosts[0].get_text() if len(profilePosts) > 0 else "")
setPostKey("thxGiven", profilePosts[1].get_text() if len(profilePosts) > 1 else "")
setPostKey("thxReceived", profilePosts[2].get_text() if len(profilePosts) > 2 else "")
postBody = post.find("div", {"class": "postbody"})
if postBody:
if isinstance(postBody, Tag):
setPostKey("postNumber", postBody.find("p", {"class": "author post-number post-number-phpbb post-number-bold"}), replacements=["\n"])
setPostKey("postTime", postBody.find("time").get_text())
fullContent = postBody.find("div", {"class": "content"}).get_text()
while "\n\n\n" in fullContent: # remove multiple '\n\
fullContent = fullContent.replace("\n\n\n", "\n\n")
setPostKey("fullContent", fullContent)
changeLine = postBody.find("div", {"class": "notice"})
if changeLine:
setPostKey("changeLine", changeLine.get_text().strip())
timeEl = postBody.find("time")

Check warning on line 273 in src/forumparser.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "timeEl" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=openatv_enigma2-plugin-extensions-openatv-community-reader&issues=AaDX5rYzRgBRhcf64sSK&open=AaDX5rYzRgBRhcf64sSK&pullRequest=46
if isinstance(timeEl, Tag):
setPostKey("postTime", timeEl.get_text())
contentEl = postBody.find("div", {"class": "content"})

Check warning on line 276 in src/forumparser.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "contentEl" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=openatv_enigma2-plugin-extensions-openatv-community-reader&issues=AaDX5rYzRgBRhcf64sSE&open=AaDX5rYzRgBRhcf64sSE&pullRequest=46
if isinstance(contentEl, Tag):
fullContent = contentEl.get_text()

Check warning on line 278 in src/forumparser.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "fullContent" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=openatv_enigma2-plugin-extensions-openatv-community-reader&issues=AaDX5rYzRgBRhcf64sSF&open=AaDX5rYzRgBRhcf64sSF&pullRequest=46
while "\n\n\n" in fullContent:
fullContent = fullContent.replace("\n\n\n", "\n\n")
setPostKey("fullContent", fullContent)
changeLine = postBody.find("div", {"class": "notice"})
if isinstance(changeLine, Tag):
setPostKey("changeLine", changeLine.get_text().strip())
return errMsg, postDict


Expand All @@ -237,7 +293,7 @@
resultDict = {}
helpstring = "forumparser v1.0: try 'python forumparser.py -h' for more information"
try:
opts, args = getopt(argv, "j:l:t:p:h", ["json=", "latest=", "thread=", "post=", "help"])
opts, _ = getopt(argv, "j:l:t:p:h", ["json=", "latest=", "thread=", "post=", "help"])
except GetoptError as error:
print(f"ERROR: {error}\n{helpstring}")
exit(2)
Expand Down Expand Up @@ -270,7 +326,7 @@
threadId, pageNo = arguments[0], arguments[1] if len(arguments) > 1 else "0"
if pageNo != "0":
if pageNo.isdigit():
threadUrl = f"{atvpglobals.BASEURL}/viewtopic.php?t={threadId}&start={(int(pageNo) - 1) * 20}"
threadUrl = f"{fpglobals.BASEURL}/viewtopic.php?t={threadId}&start={(int(pageNo) - 1) * 20}"

Check warning on line 329 in src/forumparser.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable "threadUrl" to match the regular expression ^[_a-z][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=openatv_enigma2-plugin-extensions-openatv-community-reader&issues=AaDX5rYzRgBRhcf64sSM&open=AaDX5rYzRgBRhcf64sSM&pullRequest=46
errMsg, resultDict = fparser.parseThread(threadUrl)
if errMsg:
print("ERROR:", errMsg)
Expand Down
Loading
Loading