Solved v19 - EDIT: Can't play interal url item from PVR channel
#1
Hi,

I'm trying to run one of my addon by an external url:
But when the code reaches to the listItem.setInfo it makes kodi to crash.

This function works well with Kodi 17.6 using this external url,
And also works well when try to run this item from the addon manually (Kodi 17 & 19).
So it may be something with running it using the external url in Kodi 19.

This is the code:
Code:
listItem = xbmcgui.ListItem(path=url)
listItem.setInfo(type="video", infoLabels={"mediatype": "movie", "studio": channelName, "title": programmeName, "plot": description, "tvshowtitle": channelName, "episode": 0, "season": 0})

Code:
DEBUG <general>: url: https://d18b0e6mopany4.cloudfront.net/ou...ozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36&Referer=https://13tv.co.il/live/
DEBUG <general>: programmeName: [COLOR yellow]ערוץ 13 - רשת (HD)[/COLOR]
DEBUG <general>: description
DEBUG <general>: channelName: [COLOR yellow]ערוץ 13 - רשת (HD)[/COLOR]
(Description also tested as None, '', 'a'. I also tried to change the other variables with different strings, but still the same)

I also checked the variable by printing them to the log on those cases:
- Kodi 17.6 (Internal/External)
- Kodi 19.1 (Internal/External)
All of them show exactly the same values of the setInfo params.

By the way, when trying to run "setInfo" it prints also to the logs this lines:
(Sometimes one, sometimes two,three times) then kodi crash.
Code:
ERROR <general>: 127.0.0.1 - - [02/Sep/2021 00:14:19] "GET /?url=plugin://plugin.video.israelive/&channelid=3&mode=11 HTTP/1.1" 200 -
Also for some reason running again the plugin immediatly after the first try failed by the setInfo failure.
After the second time kodi is crashing.

I made a lot of tests in this thread:
https://forum.kodi.tv/showthread.php?tid=364249

It seems that the problem is in Kodi System level and not Addon level.
Something has probably changed between Kodi 17 to Kodi 19 about running addons by external url.
Maybe it's something in the background the make setInfo to crash Kodi when running the addon with the external url.
Maybe Threding issue or Encoding/Decoding or something else.
Reply
#2
@Fuzzard 
@enen92 
@ronie 
@phunkyfish
Reply
#3
A new finding:
Also listItem.setArt makes Kodi to crash.
So it seems a problem with all the functions that relates to the "ListItem" regarding running a plugin using an external url in Kodi 19.
Reply
#4
A different I found in the logs:
Kodi 17.6
Code:
DEBUG: XFILE::CPluginDirectory::StartScript - calling plugin GlobeTV('plugin://plugin.video.israelive/','19','?channelid=3&mode=11')

Kodi 19.1:
Code:
DEBUG <general>: XFILE::CPluginDirectory::StartScript - calling plugin GlobeTV('plugin://plugin.video.israelive/','2','?channelid=3&mode=11','resume:false')

What is the new arg "resume"?
(Even though, this arg exist also when playing the item internally from the addon, so I don't think this is the problem)

By the way, when kodi crashes by one of the "ListItem" functions, in the "kodi_stacktrace" log it show the thread id which printing the "StartScript" log.
Reply
#5
Well, it seems that I found the fix of the ListItem functions by adding this param: offscreen (Which I found that it was added in v18, and not shown in v19 docs)
Code:
listItem = xbmcgui.ListItem(path=url, offscreen=True)

But I still don't know why it's not playing the ListItem.
Also it still runs the plugin twice as I said from unknown reason.

The code for playing: (I think)
Code:
xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=True, listitem=listItem)

* The ListItem path url is for watch live stream video.

Kodi Debug log: https://paste.ubuntu.com/p/c9Rr5CNpYN
Reply
#6
You might try setting resume to true since this is a live stream, just to see if it makes a difference.  It looks like a lot of this thread has disappeared so the link to your code is gone.  I think, at this point, I'll need to load it and see what I can find.  The live streams are coming from a tuner / PVR ?  if so, which tuner and PVR software are you using ?  One thing you might do is instrument the URL into the Kodi logfile to ensure it is being passed and parsed when calling by URL.


Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#7
(2021-09-04, 22:05)jbinkley60 Wrote: You might try setting resume to true since this is a live stream, just to see if it makes a difference.  It looks like a lot of this thread has disappeared so the link to your code is gone.  I think, at this point, I'll need to load it and see what I can find.  The live streams are coming from a tuner / PVR ?  if so, which tuner and PVR software are you using ?  One thing you might do is instrument the URL into the Kodi logfile to ensure it is being passed and parsed when calling by URL.


Jeff

When I set offscreen=False (False is the default btw) it crash on each ListItem function as before.
When I set offscreen=True it doesn't crash, but there url isn't playing, maybe problem with the player or something else.
As I said, I also don't know why it runs the plugin 4 times!
Code:
XFILE::CPluginDirectory::StartScript - calling plugin GlobeTV('plugin://plugin.video.israelive/'
X4
And each of them is running on different thread id.

I will try to arrange all the code and the data that you need and will update you soon.
Basically it will run through pvr (simple.client), but currently I play a url directly which exist in a "Favorites" list in the addon data.

You can see in the last log which url I'm trying to play:
https://kanlivep2event-i.akamaihd.net/hl...ozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.155 Safari/537.36
(But it also happen with another url)
Reply
#8
@jbinkley60 

And the thread you meant for is in the "migration" subforum:
https://forum.kodi.tv/showthread.php?tid=364249
Reply
#9
Ok.  You might try this too:

listItem = xbmcgui.ListItem(path=url.encode('utf-8','ignore'), offscreen=True)

and

listItem = xbmcgui.ListItem(path=url.encode('utf-8','ignore'))


and see if either work.


Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#10
(2021-09-04, 22:59)jbinkley60 Wrote: Ok.  You might try this too:

listItem = xbmcgui.ListItem(path=url.encode('utf-8','ignore'), offscreen=True)

and

listItem = xbmcgui.ListItem(path=url.encode('utf-8','ignore'))


and see if either work.


Jeff

With the second option, again, ListItem function crash.
With the first one, there is no change, still the same.
Before that there was few times that it even tried to run the player.
And again, I still don't understand why the plugin run more then once.

Log: https://paste.ubuntu.com/p/PwfPJvWBMR
Reply
#11
OK.  Thanks for trying.  It was a long shot.  Once I can see the code and test myself, I might be able to help further.


Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#12
(2021-09-05, 00:39)jbinkley60 Wrote: OK.  Thanks for trying.  It was a long shot.  Once I can see the code and test myself, I might be able to help further.


Jeff

@jbinkley60 

These are the addons to install:
The main addon - https://f2h.io/7aycxf0kijiu
You will need this resolver addon too - https://f2h.io/b6rq8m7r6hp8
Regarding the "LiveStreamer" I think it's optional but here it too - https://f2h.io/q3ko8yh0rgtv

The main Addon data, replace it with your after install the main zip file, so you will have the 'Favorites' list etc - https://f2h.io/ss1g9rxv97df

For testing - open your browser and put one of this urls:
http://127.0.0.1:65007/?url=plugin://plu...=2&mode=11


Focus on 'default.py', on these functions:
- PlayChannelByID
- PlayChannel (There is where the "ListItem" located)
- All start with "mode == 11" (line 816)
There are a lot of log printings Smile So you can change them as you need.

Thanks.
Reply
#13
@jbinkley60 

Hi,
Have you already checked the code?

I think it might be something with the "resolver" addon which run as a service.
It gets the request from the external url and run it with that:
Code:
listitem = xbmcgui.ListItem(path=url)
xbmc.Player().play(url, listitem)
Code:
url: plugin://plugin.video.israelive/?channelid=3&mode=11

What I still don't know is why it runs it several times and not only once.
Reply
#14
Not yet.  I hope to get to it soon.  I'll look at the service component too. 


Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#15
(2021-09-08, 21:26)jbinkley60 Wrote: Not yet.  I hope to get to it soon.  I'll look at the service component too. 


Jeff

Just to mention that I found the problem with the external url.
Forget all what we talked about, it was in the "handler" addon.

It was a specific case that has this code:
livestreamerXBMCLocalProxy.py (line 69)
Code:
self.send_response(200)

So after I changed it to this:
Code:
self.send_response_only(200)
self.end_headers()
(Basically  it works also with the previous "self.send_response" but it will write error to log)

I don't know how it works in kodi 17.6 but, my specific case wasn't have the end_headers()


But now I still have my original problem, play it from my PVR (LiveTV) and not from my browser.
I found a different between kodi 17.6 and 19.1 when playing through PVR:

livestreamerXBMCLocalProxy.py:
Code:
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
class MyHandler(BaseHTTPRequestHandler):
    def answer_request(self, sendData):
         ..........

class ThreadedHTTPServer(ThreadingMixIn, Server):

service.py
Code:

proxy = ThreadedHTTPServer((hostName, portNum), MyHandler)

This arg "sendData" set to "1" on the first call when it's on Kodi 17.6,
While in Kodi 19.1 it returns "0" on the first call (Only on the second it "1")

EDIT:
I did a little workaround like this which maybe solved this issue and I still have a problem to play:

livestreamerXBMCLocalProxy.py:
Code:
elif request_path.startswith("?url="):
                if (KodiPlayer or request_path.startswith('?url=plugin')):
                    if (sendData == 0):
                        return

                    self.send_response_only(200)
                    self.end_headers()                    
                    url = unquote(request_path[5:]).replace('&', '?', 1)
                    listitem = xbmcgui.ListItem(path=url)
                    xbmc.Player().play(url, listitem)
                    return

But as I said it still don't play it, from the log it seems that there is a problem with the demuxer or something when playing it from the Live TV (PVR):
(From the external url it works, and reminder: the pvr channel is pointing to the same external url)

Code:
INFO <general>: VideoPlayer::OpenFile: pvr://channels/tv/All%20channels/pvr.iptvsimple_1260388524.pvr
DEBUG <general>: Thread VideoPlayer start, auto delete: false
DEBUG <general>: CApplication::OnPlayBackStarted: CApplication::OnPlayBackStarted
INFO <general>: Creating InputStream
DEBUG <general>: CurlFile::Open(0xd9b12fe980) http://127.0.0.1:65007/?url=plugin://plu...=2&mode=11
DEBUG <general>: Loading settings for pvr://channels/tv/All%20channels/pvr.iptvsimple_1260388524.pvr
DEBUG <general>: CPlayerGUIInfo::InitCurrentItem(pvr://channels/tv/All%20channels/pvr.iptvsimple_1260388524.pvr)
Code:
INFO <general>: Creating Demuxer
ERROR <general>: CDVDDemuxFFmpeg::Open - error probing input format, http://127.0.0.1:65007/?url=plugin://plu...=2&mode=11
ERROR <general>: CVideoPlayer::OpenDemuxStream - Error creating demuxer
INFO <general>: CVideoPlayer::OnExit()
Reply

Logout Mark Read Team Forum Stats Members Help
v19 - EDIT: Can't play interal url item from PVR channel0