Skip to content

Commit

Permalink
Added: Better detection for NPO Plus accounts.
Browse files Browse the repository at this point in the history
  • Loading branch information
basrieter committed Nov 20, 2023
1 parent 7d81014 commit 22dfcf3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions channels/channel.nos/nos2010/chn_nos2010.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ def __init__(self, channel_info: ChannelInfo):
return

def log_on(self) -> bool:
if self.loggedOn:
return True

return self.__log_on(False)

def __log_on(self, force_log_off: bool = False) -> bool:
Expand Down Expand Up @@ -668,10 +671,12 @@ def create_api_episode_item(self, result_set: dict, show_info: bool = False) ->
till = DateHelper.get_date_from_posix(till_stamp, tz=pytz.UTC)
if till_stamp and till < datetime.datetime.now(tz=pytz.UTC):
item.isPaid = True
# break
# Due to a bug in the NPO API, this content could be viewed for free.
# for now we just don't show it.
return None
if not self.__has_premium():
return None
else:
break
item.isPaid = False
# Always stop after a "free"
break
Expand Down Expand Up @@ -1329,6 +1334,9 @@ def create_iptv_epg(self, parameter_parser):

def __has_premium(self) -> bool:
if self.__has_premium_cache is None:
if not self.loggedOn:
self.log_on()

data = UriHandler.open("https://npo.nl/start/api/auth/session")
json = JsonHelper(data)
subscriptions = json.get_value("subscription", fallback=None)
Expand Down

0 comments on commit 22dfcf3

Please sign in to comment.