Catch-up-TV-and-More / plugin.video.catchuptvandmore

Replay, Live TV and websites videos addon for Kodi
https://catch-up-tv-and-more.github.io
GNU General Public License v2.0
281 stars 89 forks source link

UKTV Play - Live TV channels and Catch up TV not working #1274

Closed berkhornet closed 6 months ago

berkhornet commented 7 months ago

⚠️ Please try the last beta version and check existing issues before issuing a bug. ⚠️

Describe the bug

When selecting Dave, Yesterday or Drama channels from Live TV an Index Error - list index out of range occurs.

When selecting anything from UKTV Play catch up an Attribute Error - module 'kodi_six.xbmc' has no attribute 'translatePath'

To Reproduce

Steps to reproduce the behaviour:

  1. Select Dave, Yesterday or Drama channels from Live TV / United Kingdom OR
  2. Select any program from Catch Up TV / United Kingdom / UKTV Play

Expected behaviour

Selected channel or program should play

Actual behaviour

  1. For Live Channels and Index Error - list index out of message is displayed
  2. For Catch Up TV - an Attribute Error is displayed

Screenshots

If applicable, add screenshots to help explain your problem:

Your environment

Additional context

Add any other context about the problem here:

Debug log

For each type of error, there are two log entries. The first is the actual cause of the error. The second is less important, detailing an error in uploading the log file.

========================= LIVE TV ERROR LOG ENTRIES

2024-02-10 12:11:39.288 T:2564 error : [Catch-up-TV-&-More.support] list index out of range Traceback (most recent call last): File "C:\Users\mickr\AppData\Roaming\Kodi\addons\script.module.codequick\lib\codequick\support.py", line 306, in run_callback redirect = parent_ins(route, arg_params, self.callback_params) File "C:\Users\mickr\AppData\Roaming\Kodi\addons\script.module.codequick\lib\codequick\resolver.py", line 67, in call results = super(Resolver, self).call(route, args, kwargs) File "C:\Users\mickr\AppData\Roaming\Kodi\addons\script.module.codequick\lib\codequick\script.py", line 169, in call return route.function(self, *args, *kwargs) File "C:\Users\mickr\AppData\Roaming\Kodi\addons\plugin.video.catchuptvandmore\resources\lib\channels\uk\uktvplay.py", line 383, in get_live_url data_channel = re.compile(r'channelStreamId:(.?)}').findall( IndexError: list index out of range 2024-02-10 12:11:39.297 T:2564 error : EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--

2024-02-10 12:11:39.714 T:32292 error : Playlist Player: skipping unplayable item: 0, path [plugin://plugin.video.catchuptvandmore/resources/lib/channels/uk/uktvplay/get_live_url/?pickle=80049546000000000000007d94288c075f7469746c655f948c0444617665948c08786d6c74765f6964948c113433322e747667756964652e636f2e756b948c076974656d5f6964948c046461766594752e]

============================= CATCH UP TV ERROR LOG ENTRIES

                                               Traceback (most recent call last):
                                                 File "C:\Users\mickr\AppData\Roaming\Kodi\addons\script.module.codequick\lib\codequick\support.py", line 306, in run_callback
                                                   redirect = parent_ins(route, arg_params, self.callback_params)
                                                 File "C:\Users\mickr\AppData\Roaming\Kodi\addons\script.module.codequick\lib\codequick\resolver.py", line 67, in __call__
                                                   results = super(Resolver, self).__call__(route, args, kwargs)
                                                 File "C:\Users\mickr\AppData\Roaming\Kodi\addons\script.module.codequick\lib\codequick\script.py", line 169, in __call__
                                                   return route.function(self, *args, **kwargs)
                                                 File "C:\Users\mickr\AppData\Roaming\Kodi\addons\plugin.video.catchuptvandmore\resources\lib\channels\uk\uktvplay.py", line 285, in get_video_url
                                                   data_account = data_account_player.group(1)
                                               AttributeError: 'NoneType' object has no attribute 'group'

2024-02-10 12:16:26.746 T:38124 error : EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--

mcowell commented 7 months ago

Seems the issue starts on line 249 of /resources/lib/channels/uk/uktvplay.py

resp = session_requests.get(URL_ROOT);

This makes a GET request to https://uktvplay.uktv.co.uk which is successful but then we look for the following regular expression in the contents that is returned:

re.search('//players\.brightcove\.net/([0-9]+)/([A-Za-z0-9]+)_default/', resp.text)

Unfortunately this response is no longer found and so we cannot fetch the account of player. We use this information to find the policy key.

This key is needed for playback. We need a way to fetch the new key or discover a new way of requesting the video file.

mcowell commented 7 months ago

I see @joaopa00 worked on it last. Would they be around to offer advice?

berkhornet commented 7 months ago

@mcowell many thanks for your responses. A very good start in getting a fix.

@joaopa00 hopefully you can help out with this. Thanks for any help you can provide.

joaopa00 commented 7 months ago

Website now requests an account to watch the videos. So someone (else than me) should send patches.

mcowell commented 7 months ago

I raised a PR @joaopa00. If you could review I would appreciate it.

So far you would not have to login from Kodi and the plugin will work with this fix. I would suspect however that UKTV Play is trying to cut down on third party access and some additional work will be required in the future.

https://github.com/Catch-up-TV-and-More/plugin.video.catchuptvandmore/pull/1276

Thanks!

nictjir commented 7 months ago

Thanx for this saved me a lot of debugging. Using the static data_account,data_player works for me as well, but I do not know where the data_player comes from.

From multiple captures I get a data_player value of 0RyQs9qPh

To get it programmatically I do the following

IDS = 'https://uktvplay.co.uk/_next/static/chunks/app/(navigation)/shows/[brand]/[series]/[episode]/[videoId]/page-af077c3ba4e5c8fe.js'

def get_ids(): resp = urlquick.get(IDS) data_account = re.search('accountId:"(.+?)",', resp.text).group(1) data_player = re.search('playerId:"(.+?)",', resp.text).group(1) return(data_account,data_player)

Get data_account / data_player

data_account,data_player = get_ids()

mikekhowe commented 6 months ago

Hi. Any further advances on getting UKTV Play working? I have tried adding the video addon from the zip file in github, both the recommended and beta. Of course its not working from any of my other repositories either. I have been using KODI since start of 2024 and have realised its limitations. But was relying on Crackle, Invidious, Documentary Heaven and Catch Up TV and More.... Thanks MH

mcowell commented 6 months ago

@mikekhowe all we need to do is to get a maintainer to approve my pull request. After that, assuming this project is still being built, it should come out in the next release.

joaopa00 commented 6 months ago

Commited in git a patch based on nictjir's work.

mikekhowe commented 6 months ago

This is great. I don't really understand process but get the gist of it. Will look out for the next release and re-install the addon. Thanks for your hard work! MH

nictjir commented 6 months ago

@mikekhowe as @joaopa00 was kind enough to update the uktvplay file in the dev tree, to get the latest version of everything

Go to https://github.com/Catch-up-TV-and-More/plugin.video.catchuptvandmore Click on the down arrow on the Green code button Select download as zip

This will download a zip file called - plugin.video.catchuptvandmore-dev.zip

Go to Kodi and install an app from zip and select this zip file

Hope this helps.

joaopa00 commented 6 months ago

Beta released.

berkhornet commented 6 months ago

Thank you. Tested successfully

mikekhowe commented 6 months ago

Hi. Sorry but I have an 404 Client error Not found for URL on UKTV Play. Was working a couple of weeks ago. Done as Nictjr suggested above. Deleted old addon and re-installed using the the downloaded zip file

I have not worked out how to get a snapshot of the error file. Just spotted the addition of Channel 4 which is great and works for me. MH

mcowell commented 6 months ago

Yeah. 404 for me too.

I had a PR that I tested and is working (it's still working) but was closed by @joaopa00.

I'm happy to raise a new PR if you wish. Please let me know.

nictjir commented 6 months ago

Can you download this file uktvplay.txt

Rename it to uktvplay.py and overwrite the exiting file of this name in your kodi add-ons folder (addons/plugin.video.catchuptvandmore/resources/lib/channels/uk)

I have submitted the above file as a Pull Request to fix the live playback issue For me this file makes live and catchup uktbplay work

mikekhowe commented 6 months ago

Hi nictjir. Did the file change. No luck. Trying to upload the error log. kodi.log

Hope this is of use. I cleared the log. Opened KODI went straight for the program, got the error and closed the program so everything in the log is the report of one error. MH

mcowell commented 6 months ago

Here is the relevant error @mikekhowe

404 Client Error: Not Found for url: https://uktvplay.co.uk/_next/static/chunks/app/(navigation)/shows/%5Bbrand%5D/%5Bseries%5D/%5Bepisode%5D/%5BvideoId%5D/page-af077c3ba4e5c8fe.js

joaopa00 commented 6 months ago

page-af077c3ba4e5c8fe.js is not fix. It changes depending on (the video played? user account?). One has to recover the page id programmatically.

nictjir commented 6 months ago

thankyou @mikekhowe for the error message and @joaopa00 for analysis

Made some changes to will extract the file name dynamically to get accountId and playerId Not sure if there is a more elegant way to find this

Can somebodies please download uktvplay.txt

Rename it to uktvplay.py and overwrite the exiting file of this name in your kodi add-ons folder (addons/plugin.video.catchuptvandmore/resources/lib/channels/uk)

And see if this works for you for both live and catchup

berkhornet commented 6 months ago

@nictjir i've just tested the file uktvplay.txt. Both live and catch up tv are working again. Thank you

nictjir commented 6 months ago

Thankyou @berkhornet

i want to add this as a pull request but flake8 is whining about the regexp string I am using match = re.search('(static/chunks/app/(navigation)/shows/[brand]/[series]/[episode]/[videoId]/page)(.+?)."]', resp.text, re.DOTALL)

lots of these :263:43: W605 invalid escape sequence '('

Any pointers from anybody on how to get it flak8 compliant so it will pass the pull request test?

mikekhowe commented 6 months ago

Updated uktvplay.py. All working great now. Thanks to all involved. MH

mikekhowe commented 6 months ago

@nictjir. Have you tried ChatGPT for help on resolving the python code errors against the PEP 8 style guide. It debugs my PHP code. MH

mikekhowe commented 6 months ago

For example: match = re.search(r'(static/chunks/app/(navigation)/shows/[brand]/[series]/[episode]/[videoId]/page)(.+?)."]', resp.text, re.DOTALL) Just a thought MH

SebMourlhou commented 6 months ago

I copied/pasted your uktvplay.py file and I don't have the same flake8 errors : 219:23: E126 continuation line over-indented for hanging indent 328:9: E125 continuation line with same indent as next logical line

When you execute the flake8 command, are you at the root directory of the project ? If not, the file setup.cfg is not used to configure the preferences defined by the author.