Skip to content

Commit

Permalink
Extract serialNumbert from SkyQ
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerSelwyn committed May 17, 2020
1 parent 4603066 commit c84a5d0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions pyskyqremote/country/remote_gb.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def __init__(self, host):
self.channel_image_url = CHANNEL_IMAGE_URL
self.pvr_image_url = PVR_IMAGE_URL
self._host = host
self.country = "GBR"

def getEpgData(self, sid, channelno, epgDate):
"""Get EPG data for UK."""
Expand Down
1 change: 1 addition & 0 deletions pyskyqremote/country/remote_it.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def __init__(self, host):
self.pvr_image_url = PVR_IMAGE_URL
self._host = host
self._channellist = None
self.country = "ITA"

self._getChannels()

Expand Down
21 changes: 14 additions & 7 deletions pyskyqremote/skyq_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,14 @@ def __init__(
):
"""Stand up a new SkyQ box."""
self.host = host
self.country = None
self.serialNumber = None
self.deviceSetup = False
self._channel = None
self._test_channel = test_channel
self._port = port
self._jsonport = jsonport
self._overrideCountry = overrideCountry
self.deviceSetup = False
self.channel = None
self._soapControlURL = None
self._lastEpg = None
self._currentApp = APP_EPG
Expand Down Expand Up @@ -189,7 +191,7 @@ def getEpgData(self, sid, epgDate, days=2):

epg = str(sid) + epgDate.strftime("%Y%m%d")
if self._lastEpg == epg:
return self.channel
return self._channel

programmes = set()
for n in range(days):
Expand All @@ -206,11 +208,11 @@ def getEpgData(self, sid, epgDate, days=2):
if len(programmes) == 0:
_LOGGER.info(f"I0020 - Programme data not found for {sid} : {epgDate}")

self.channel = Channel(
self._channel = Channel(
sid, channelno, channelname, channelImageUrl, sorted(programmes)
)

return self.channel
return self._channel

def getProgrammeFromEpgJSON(self, sid, epgDate, queryDate):
"""Get programme from EPG for specfied time and channel as json."""
Expand Down Expand Up @@ -483,7 +485,11 @@ def _setupDevice(self):
url_index += 1

SkyQCountry = self._importCountry(deviceInfo)
if "serialNumber" in deviceInfo:
self.serialNumber = deviceInfo["serialNumber"]

self._remoteCountry = SkyQCountry(self.host)
self.country = self._remoteCountry.country

if not self._test_channel:
self._channels = self._http_json(REST_CHANNEL_LIST)
Expand Down Expand Up @@ -522,14 +528,15 @@ def _importCountry(self, deviceInfo):

try:
country = pycountry.countries.get(alpha_3=alpha3).alpha_2.casefold()
return importlib.import_module(
SkyQCountry = importlib.import_module(
"pyskyqremote.country.remote_" + country
).SkyQCountry

except (AttributeError, ModuleNotFoundError) as err:
_LOGGER.warning(
f"W0030 - Invalid country, defaulting to GBR : {self.host} : {alpha3} : {err}"
)

from pyskyqremote.country.remote_gb import SkyQCountry

return SkyQCountry
return SkyQCountry

0 comments on commit c84a5d0

Please sign in to comment.