Skip to content

Commit d44a212

Browse files
committed
fix #26 by regex and word check
1 parent 9d8ab27 commit d44a212

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

videoText.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ class RbbText:
5555
ballgamescorepages = { \
5656
252, 276
5757
}
58+
listOfBallGames = { \
59+
"Fußball", "Handball", "Basketball", \
60+
"Eishockey", "Hockey", "Volleyball" \
61+
}
5862
#
5963
api = 'https://www.rbbtext.de/'
6064
#
@@ -157,16 +161,19 @@ def extractJumpingPages(self):
157161
#
158162
def appendContent(self):
159163
"""process and prettify extracted text lines and append these to content"""
164+
isBallGame = False
160165
for x in self.lines:
161166
xAsText = str(x)
162167
if len(xAsText) > 1 :
163-
# quick first attempt for issue #26
164168
# I am canceling the first line of the text with a timestamp here
165169
# as a timestamp is not a score.
166-
if self.currentPage in self.ballgamescorepages \
170+
if any(sport in xAsText for sport in self.listOfBallGames):
171+
isBallGame = True
172+
if isBallGame or self.currentPage in self.ballgamescorepages \
167173
and not xAsText[0:2].isdigit() and not xAsText.strip().endswith(":"):
174+
xAsText = xAsText.replace("--:--", "noch kein Ergebnis")
168175
xAsText = xAsText.replace("-:-", "noch kein Ergebnis")
169-
xAsText = xAsText.replace(":", " zu ")
176+
xAsText = re.sub(r"([0-9]{1,}):([0-9]{1,})", r"\1 zu \2", xAsText)
170177
self.content += '\n' + xAsText
171178
if len(self.content) < 3:
172179
self.content += "Seite ist leer."

0 commit comments

Comments
 (0)