Skip to content

Commit

Permalink
Einzelupdate ardundzdf.py, util.py
Browse files Browse the repository at this point in the history
  • Loading branch information
rols1 committed May 23, 2023
1 parent 1777295 commit 8ae8675
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
6 changes: 2 additions & 4 deletions ardundzdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# +++++ ARDundZDF - Addon Kodi-Version, migriert von der Plexmediaserver-Version +++++

# VERSION -> addon.xml aktualisieren
# <nr>106</nr> # Numerierung für Einzelupdate
# <nr>107</nr> # Numerierung für Einzelupdate
VERSION = '4.7.3'
VDATE = '23.05.2023'

Expand Down Expand Up @@ -6905,7 +6905,6 @@ def ZDF_PageMenu(DictID, jsonObject="", urlkey="", mark="", li="", homeID=""):
PLog("Satz1_1:")
PLog(stage); PLog(typ); PLog(title);
title = repl_json_chars(title)
descr = repl_json_chars(descr); sdescr=descr.replace(';','.')
tag = repl_json_chars(tag)
if entry["type"]=="video": # Videos
if "channel" in entry: # Zusatz Sender
Expand Down Expand Up @@ -7395,9 +7394,8 @@ def ZDF_get_content(obj, maxWidth="", mark=""):
if len(descr_new) > len(descr):
PLog("descr_new: " + descr_new[:60] )
descr = descr_new


summ = descr
summ = valid_title_chars(descr)
if multi:
tag = "Folgeseiten"
else:
Expand Down
34 changes: 23 additions & 11 deletions resources/lib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
# 02.11.2019 Migration Python3 Modul future
# 17.11.2019 Migration Python3 Modul kodi_six + manuelle Anpassungen
#
# <nr>51</nr> # Numerierung für Einzelupdate
# Stand: 13.05.2023
# <nr>52</nr> # Numerierung für Einzelupdate
# Stand: 23.05.2023

# Python3-Kompatibilität:
from __future__ import absolute_import
Expand Down Expand Up @@ -1464,10 +1464,12 @@ def repl_char(cut_char, line): # problematische Zeichen in Text entfernen, wenn
#PLog(cut_char); PLog(pos); PLog(line_l); PLog(line_r); PLog(line_ret) # bei Bedarf
return line_ret
#----------------------------------------------------------------
# für json.loads (z.B.. in router) json-Zeichen in line entfernen, insbesondere
# Hochkommata (Problem bei Dictbildung)
# doppelte utf-8-Enkodierung führt an manchen Stellen zu Sonderzeichen
# 14.04.2019 entfernt: (':', ' ')
#
def repl_json_chars(line): # für json.loads (z.B.. in router) json-Zeichen in line entfernen
def repl_json_chars(line):
line_ret = line
#PLog(type(line_ret))
for r in ((u'"', u''), (u'\\', u''), (u'\'', u''), (u'%5C', u'')
Expand All @@ -1479,16 +1481,26 @@ def repl_json_chars(line): # für json.loads (z.B.. in router) json-Zeichen in l

return line_ret
#----------------------------------------------------------------
# Verwendung bei übergroßen Mengen an Spezialzeichen (Performance),
# um replace-Aufwand zu reduzieren - Bsp. funk (Hex-Colours 🤯,
# Verwendung bei übergroßen Mengen an Spezialzeichen in Titel + Info-Text
# (Performance), um replace-Aufwand zu reduzieren - Bsp. funk (Hex-Colours 🤯,
# u.a. ✈, 😱, ..).
# valid_chars: Umlaute plus routerkompatible Zeichen, auch einige der in unescape
# übersetzte Zeichen (hier ab &)
# S. docs.python.org/3/library/string.html
#
def valid_title_chars(line):
#PLog("valid_title_chars:")
valid_chars = u"_üöäÜÖÄß%s" % (string.printable)
PLog("valid_title_chars:")

printable = string.printable
# cut ab &: &\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c
printable = printable.split('&')[0]
valid_chars = u' üöäÜÖÄß%s&()*+,-.:<=>?_|~' % printable
line_ret = ''.join(c for c in line if c in valid_chars)
line_ret = line_ret.replace('"', '') # router-komp.
PLog(line_ret)

# Hochkommata, dto urlkodiert - nicht erfasst in valid_chars:
line_ret = (line_ret.replace(u'"', '').replace(u"'", '')\
.replace(u"%27", '').replace(u"%22", '').replace(u"%5B", '')\
.replace(u"%5D", ''))

return line_ret
#----------------------------------------------------------------
Expand Down Expand Up @@ -2366,9 +2378,8 @@ def get_summary_pre(path,ID='ZDF',skip_verf=False,skip_pubDate=False,page='',pat
summ = stringextract('description" content="', '"', page)
summ = mystrip(summ)
if teaserinfo:
summ = "%s\n\n%s" % (teaserinfo, summ)
summ = "%s | %s" % (teaserinfo, summ)
summ = unescape(summ)
summ = repl_json_chars(summ)
# 11.05.2023 neu
postcontent = stringextract('b-post-content">', '"b-post-footer"', page)
if postcontent:
Expand All @@ -2382,6 +2393,7 @@ def get_summary_pre(path,ID='ZDF',skip_verf=False,skip_pubDate=False,page='',pat
if len(addpost) > 0:
summ = summ + " | " + " | ".join(addpost)
summ = mystrip(summ)
summ = valid_title_chars(summ)

if skip_verf == False:
if u'erfügbar bis' in page: # enth. Uhrzeit
Expand Down

0 comments on commit 8ae8675

Please sign in to comment.