Skip to content

Commit

Permalink
Fix ssl error with some (turkish) LC_CTYPE
Browse files Browse the repository at this point in the history
On OpenATV 7.1 an individual file LC_CTYPE is used for each language. On turkish this cause ssl error unable to find public key parameters.
Thefore add workaround which changes locale LC_CTYPE to default en_US while using the plugin.
In fact this should be fixed in the image, but for now, while there is no clear reason, I will leave this here.
  • Loading branch information
Taapat committed Mar 22, 2022
1 parent 9de935f commit 872c501
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/YouTubeUi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import os
from copy import copy
from locale import LC_CTYPE, Error, getlocale, setlocale

from enigma import eServiceReference, eTimer, iPlayableService
from Components.ActionMap import ActionMap
Expand Down Expand Up @@ -387,6 +388,14 @@ def __init__(self, session):
self.yts = [{}]
self.onLayoutFinish.append(self.layoutFinish)
self.onClose.append(self.cleanVariables)
self.locale = getlocale(LC_CTYPE)
if self.locale[0] not in (None, 'en_US'):
# Workaround to fix ssl error unable to find public key parameters with some (turkish) LC_CTYPE
try:
setlocale(LC_CTYPE, locale=('en_US', 'UTF-8'))
except Error as e:
print('[YouTube] Error on set locale:', e)
self.locale = (None, None)
for p in plugins.getPlugins(where=PluginDescriptor.WHERE_MENU):
if 'ServiceApp' in p.path:
break
Expand Down Expand Up @@ -431,6 +440,8 @@ def cleanVariables(self):
self.thumbnails = None
self.ytapi = None
self.ytdl = None
if self.locale[0] not in (None, 'en_US'):
setlocale(LC_CTYPE, locale=self.locale)

def showButtons(self):
self['red'].show()
Expand Down

0 comments on commit 872c501

Please sign in to comment.