2021-11-22, 12:01
I've got a Kodi 18 and prior addon which I have been helping migrate to Kodi 19. I submitted it to the Kodi repo and got feedback on a section of code which said "Player().play() is to be used by scripts not plugins. Please adjust this to use xbmcplugin.setResolvedUrl" Here's the section of code. This section of the addon is called by the user clicking on a listitem which passes a URL to this section of code to parse the web page and find the real associated URL:
def GET_STREAM(name,url):
smil = get_html(url)
contents = BeautifulSoup(smil,'html5lib')
stream = (re.compile('src="(.+?)"').findall(str(contents))[0])
if mp4base not in stream:
#stream = mp4base + stream
stream = stream
listitem = xbmcgui.ListItem(name)
listitem.setArt({'thumb': defaultimage, 'icon': defaultimage})
xbmc.log('CBC Sports Live Schedule Playback stream: ' + str(stream), xbmc.LOGDEBUG)
if stream.find('Unavailable') > -1:
xbmcgui.Dialog().notification(name, translation(30013), defaultimage, 6000, False)
else:
xbmc.Player().play( stream, listitem )
sys.exit()
xbmcplugin.endOfDirectory(int(sys.argv[1]))
I've tried modifying the code many different ways, as suggested, but it will not play the URL in stream when using xbmcplugin.setResolvedUrl. Here's my latest try. Any ideas on what I am doing wrong ?
def GET_STREAM(name,url):
smil = get_html(url)
contents = BeautifulSoup(smil,'html5lib')
stream = (re.compile('src="(.+?)"').findall(str(contents))[0])
if mp4base not in stream:
#stream = mp4base + stream
stream = stream
if cbclog >= 1:
xbmc.log('CBC Sports Live Schedule Playback stream: ' + str(stream), xbmc.LOGINFO)
listitem = xbmcgui.ListItem(name, path=stream)
listitem.setArt({'thumb': defaultimage, 'icon': defaultimage})
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem)
listitem.setProperty('IsPlayable','true')
#xbmc.Player().play( stream, listitem )
sys.exit()
xbmcplugin.endOfDirectory(int(sys.argv[1]))
Jeff
def GET_STREAM(name,url):
smil = get_html(url)
contents = BeautifulSoup(smil,'html5lib')
stream = (re.compile('src="(.+?)"').findall(str(contents))[0])
if mp4base not in stream:
#stream = mp4base + stream
stream = stream
listitem = xbmcgui.ListItem(name)
listitem.setArt({'thumb': defaultimage, 'icon': defaultimage})
xbmc.log('CBC Sports Live Schedule Playback stream: ' + str(stream), xbmc.LOGDEBUG)
if stream.find('Unavailable') > -1:
xbmcgui.Dialog().notification(name, translation(30013), defaultimage, 6000, False)
else:
xbmc.Player().play( stream, listitem )
sys.exit()
xbmcplugin.endOfDirectory(int(sys.argv[1]))
I've tried modifying the code many different ways, as suggested, but it will not play the URL in stream when using xbmcplugin.setResolvedUrl. Here's my latest try. Any ideas on what I am doing wrong ?
def GET_STREAM(name,url):
smil = get_html(url)
contents = BeautifulSoup(smil,'html5lib')
stream = (re.compile('src="(.+?)"').findall(str(contents))[0])
if mp4base not in stream:
#stream = mp4base + stream
stream = stream
if cbclog >= 1:
xbmc.log('CBC Sports Live Schedule Playback stream: ' + str(stream), xbmc.LOGINFO)
listitem = xbmcgui.ListItem(name, path=stream)
listitem.setArt({'thumb': defaultimage, 'icon': defaultimage})
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem)
listitem.setProperty('IsPlayable','true')
#xbmc.Player().play( stream, listitem )
sys.exit()
xbmcplugin.endOfDirectory(int(sys.argv[1]))
Jeff