Skip to content

Commit

Permalink
Merge pull request #4533 from dimkroon/matrix-viwx-141
Browse files Browse the repository at this point in the history
[plugin.video.viwx] v1.4.1
  • Loading branch information
basrieter authored Jul 3, 2024
2 parents e18689f + 8db7d43 commit e6e8fca
Show file tree
Hide file tree
Showing 10 changed files with 257 additions and 76 deletions.
20 changes: 12 additions & 8 deletions plugin.video.viwx/addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.viwx" name="viwX" version="1.3.0" provider-name="Dimitri Kroon">
<addon id="plugin.video.viwx" name="viwX" version="1.4.1" provider-name="Dimitri Kroon">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="inputstream.adaptive" version="19.0.5"/>
Expand Down Expand Up @@ -30,16 +30,20 @@
<fanart>resources/fanart.png</fanart>
</assets>
<news>
[B]v1.3.0[/B]
[B]v1.4.1[/B]
[B]Fixes:[/B]
* Freezing streams on Kodi 21 (Omega).
* A lot of timeout errors, only experienced by new users, particularly when trying to sign in or open a stream.
* All categories failed to open with KeyError('encodeEpisodeId') due to a change at ITVX.
* A workaround for a bug in ITVX causing full news programmes to fail with FetchError('Not Found').
* Sometimes an episodes listing failed with KeyError('guidance').
* Yet again sign-in errors. Now affecting both new users and existing users who had signed out.

[B]v1.4.0[/B]
[B]Fixes:[/B]
* Collection ITV sport failed with KeyError('collection')
* Again occasional sign-in errors for new users. Hopefully the final fix.
* A rare failure to list live channels.
* Adapt to changes at ITVX causing submenu 'My ITVX' to fail sometimes.

[B]New Features:[/B]
* Support for IPTV Manager.
* Support for signed programmes. (Enable the new setting 'Use signed programmes whenever available').
* Live hero items (those in orange on the main menu) now have a context menu 'Watch from the start'.
</news>
<reuselanguageinvoker>true</reuselanguageinvoker>
</extension>
Expand Down
15 changes: 15 additions & 0 deletions plugin.video.viwx/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
v1.4.1
Fixes:
- Yet again sign-in errors. Now affecting both new users and existing users who had signed out.

v1.4.0
New features:
- Support for signed programmes. (Enable the new setting 'Use signed programmes whenever available').
- Live hero items (those in orange on the main menu) now have a context menu 'Watch from the start'.

Fixes:
- Collection ITV sport failed with KeyError('collection')
- Again occasional sign-in errors for new users. Hopefully the final fix.
- A rare failure to list live channels.
- Adapt to changes at ITVX causing submenu 'My ITVX' to fail sometimes.

v1.3.0
Fixes:
- Freezing streams on Kodi 21 (Omega).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ msgctxt "#30106"
msgid "Minimum number of items for A-Z listing."
msgstr ""

msgctxt "#30107"
msgid "Use signed programmes whenever available."
msgstr ""

msgctxt "#30110"
msgid "Logging"
msgstr ""
Expand Down
11 changes: 6 additions & 5 deletions plugin.video.viwx/resources/lib/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
from resources.lib import utils


WEB_TIMEOUT = (3.5, 7)
USER_AGENT = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/118.0'
USER_AGENT_VERSION = '118.0'
WEB_TIMEOUT = (3.5, 12)
USER_AGENT = 'Mozilla/5.0 (X11; Linux x86_64; rv:127.0) Gecko/20100101 Firefox/127.0'
USER_AGENT_VERSION = '127.0'


logger = logging.getLogger('.'.join((logger_id, __name__.split('.', 2)[-1])))
Expand Down Expand Up @@ -74,6 +74,7 @@ def __init__(self):
super(HttpSession, self).__init__()
self.headers.update({
'User-Agent': USER_AGENT,
'Accept-Language': 'en-GB,en;q=0.5',
'Origin': 'https://www.itv.com',
'Referer': 'https://www.itv.com/',
'Sec-Fetch-Dest': 'empty',
Expand Down Expand Up @@ -185,10 +186,10 @@ def set_default_cookies(cookiejar: RequestsCookieJar = None):
{"FieldID":"s137_c128","IsChecked":0}],
"appCodeName":"Mozilla",
"appName":"Netscape",
"appVersion":"5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
"appVersion":"5.0 (X11)",
"cookieEnabled":True,
"geolocation":"",
"language":"en",
"language":"en-GB",
"platform":"Linux x86_64",
"referrer":"",
"submissionSource":"prebanner_reject_all",
Expand Down
52 changes: 37 additions & 15 deletions plugin.video.viwx/resources/lib/itv_account.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ----------------------------------------------------------------------------------------------------------------------
# Copyright (c) 2022-2023 Dimitri Kroon.
# Copyright (c) 2022-2024 Dimitri Kroon.
# This file is part of plugin.video.viwx.
# SPDX-License-Identifier: GPL-2.0-or-later
# See LICENSE.txt
Expand Down Expand Up @@ -93,11 +93,13 @@ def login(self, uname: str, passw: str):
Returns True on success, raises exception on failure.
Raises AuthenticationError if login fails, or other exceptions as they occur, like e.g. FetchError.
"""
import requests
from resources.lib.telemetry_data import telemetry_factory
self.account_data = {}

req_data = {
'grant_type': 'password',
'nonce': utils.random_string(20),
'nonce': 'cerberus-auth-request-' + str(int(time.time() * 1000)),
'username': uname,
'password': passw,
'scope': 'content'
Expand All @@ -106,29 +108,49 @@ def login(self, uname: str, passw: str):
logger.info("Trying to sign in to ITV account")
try:
# Post credentials
session_data = fetch.post_json(
'https://auth.prd.user.itv.com/auth',
req_data,
headers={'Accept': 'application/vnd.user.auth.v2+json',
'Akamai-BM-Telemetry': 'a=&&&e=QzNGMDA0RjYzRDkxQ0IxOTgzOTg1NTYzNURDMkJEMjl+WUFBUU5NWWN1S2p0cHl1TEFRQUFJcUNhTkJXaWlSczVGWHRaWUtKRWdCd0VyWDI0L0ZiY051QkZwYUwyWTZldUxkWVQxYTNJSnRtQWxnQkh3UTA1MGt0cWVkR2t4YTVlbzZhZ2VhN1h0QjVTQXZDOE5CYkZsa3Y3cXJZbzB1WGJXbXd3cFlSQkZDeUNTUVZGNWRpTXQwc1RCWm84UGxGVEEvTVF5ZHlJemlob0NuSXpJMFpHRkVjVVJWNndockRLL0xnRzJLZ2poYVdiNDBTYitROW5oRjd3S2JoZW13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i5Fbl80PX05PnlrfXlgQ1lAOmQqaD0ueHdTRyBhc0lGQF4rI1llYiZ4KCEha1guVlpXOkQhaGU/TjMtX0l7SFBDd0M2LSwwQU1eZWZhTixTc0ZaUT8xK3B0Y3RJPF0xNTlvTD09VkIlU2EtSz4+cE1HVSp5TS9edC1vc1JGUGFeMmRNTTxfZyk0TF94bnhXLUBKMGFWRU09T0t1LmFyVGR1Wzw8O0soc2U='
}
resp = requests.post(
'https://auth.prd.user.itv.com/v2/auth',
json=req_data,
headers={
'user-agent': fetch.USER_AGENT,
'accept': 'application/vnd.user.auth.v2+json',
'accept-language': 'en-GB,en;q=0.5',
'accept-encoding': 'gzip, deflate',
'content-type': 'application/json',
'akamai-bm-telemetry': telemetry_factory.get_data(),
'origin': 'https://www.itv.com',
'referer': 'https://www.itv.com/',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-site',
'priority': 'u=1',
'te': 'trailers'
},
timeout=fetch.WEB_TIMEOUT
)

resp.raise_for_status()
session_data = resp.json()
self.account_data = {
'vers': SESS_DATA_VERS,
'refreshed': time.time(),
'itv_session': session_data,
'cookies': {'Itv.Session': build_cookie(session_data)}
}
except FetchError as e:
# Testing showed that itv hub can return various HTTP status codes on a failed sign in attempt.
# Sometimes returning a json string containing the reason of failure, sometimes and HTML page.
except requests.HTTPError as e:
logger.error("Error signing in to ITV account: %r" % e)
if isinstance(e, AuthenticationError) or (isinstance(e, HttpError) and e.code in (400, 401, 403)):
logger.info("Sign in failed: %r", e)
raise AuthenticationError(str(e)) from None
status_code = e.response.status_code
if status_code in (400, 403):
msg = {
400: 'Invalid username or password',
403: 'Forbidden\nIf this error persists wait a few hours before trying again.'
}.get(status_code, 'Sign in failed.')
logger.info("Sign in failed: %r: %r", e, e.response.content)
raise AuthenticationError(msg) from None
else:
raise
except:
logger.error("Error signing in to ITV account:\n", exc_info=True)
raise
else:
logger.info("Sign in successful.")
self._user_id, self._user_nickname, self._expire_time = parse_token(session_data.get('access_token'))
Expand Down
Loading

0 comments on commit e6e8fca

Please sign in to comment.