Skip to content

Commit

Permalink
[bouquetswriter] use Cyrilic charactes where stipulated by the SI table
Browse files Browse the repository at this point in the history
  • Loading branch information
Huevos committed Feb 29, 2024
1 parent 0321820 commit 512834d
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions AutoBouquetsMaker/src/scanner/bouquetswriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@ def writeLamedb(self, path, transponders):
provider_name = control_char_re.sub('', service["provider_name"]).decode('latin-1').encode("utf8")
else:
service_name = control_char_re.sub('', six.ensure_text(six.ensure_str(service["service_name"], encoding='latin-1'), encoding='utf-8', errors='ignore'))
if "service_name_encoding" in service and service["service_name_encoding"] == 0x01:
service_name = service_name.encode("iso-8859-1").decode("iso-8859-5")
provider_name = control_char_re.sub('', six.ensure_text(six.ensure_str(service["provider_name"], encoding='latin-1'), encoding='utf-8', errors='ignore'))
if "provider_name_encoding" in service and service["provider_name_encoding"] == 0x01:
provider_name = provider_name.encode("iso-8859-1").decode("iso-8859-5")
else:
service_name = service["service_name"]

Expand Down Expand Up @@ -290,7 +294,11 @@ def writeLamedb5(self, path, transponders):
provider_name = control_char_re.sub('', service["provider_name"]).decode('latin1').encode("utf8")
else:
service_name = control_char_re.sub('', six.ensure_text(six.ensure_str(service["service_name"], encoding='latin1'), encoding='utf8', errors='ignore'))
if "service_name_encoding" in service and service["service_name_encoding"] == 0x01:
service_name = service_name.encode("iso-8859-1").decode("iso-8859-5")
provider_name = control_char_re.sub('', six.ensure_text(six.ensure_str(service["provider_name"], encoding='latin1'), encoding='utf8', errors='ignore'))
if "provider_name_encoding" in service and service["provider_name_encoding"] == 0x01:
provider_name = provider_name.encode("iso-8859-1").decode("iso-8859-5")
else:
service_name = service["service_name"]

Expand Down Expand Up @@ -959,24 +967,21 @@ def spacer(self):
return "#SERVICE 1:320:0:0:0:0:0:0:0:0:\n"

def utf8_convert(self, text):
for encoding in ["utf8", "latin1"]:
try:
if six.PY2:
if six.PY2:
for encoding in ["utf8","latin-1"]:
try:
text.decode(encoding=encoding)
except UnicodeDecodeError:
encoding = None
else:
six.ensure_str(text, encoding=encoding)
except UnicodeDecodeError:
encoding = None
else:
break
if encoding == "utf8":
return text
if encoding is None:
encoding = "utf8"
if six.PY2:
return text.decode(encoding=encoding, errors="ignore").encode("utf8")
break
if encoding == "utf8":
return text
if encoding is None:
encoding = "utf8"
return text.decode(encoding, errors="ignore").encode("utf8")
else:
return six.ensure_text(six.ensure_str(text, encoding=encoding, errors='ignore'), encoding='utf8')
return six.ensure_str(text, encoding='utf-8', errors='strict')

def styledBouquetMarker(self, text, caller="bouquets"):
if caller == "index":
Expand Down

0 comments on commit 512834d

Please sign in to comment.