v17 Still Confused about setResolvedUrl, IsPlayable & IsFolder for ListItems
#1
I've seen the posts (here and here) about how setResolvedUrl should be used, but I'm still having issues getting it to work correctly in my plugin. I've read the xbmcplugin module documentation (here - This is an outdated documentation, but couldn't find Krypton version) and for all of my menu items I'm setting `IsFolder` to False and the listitem property `IsPlayable` to true and providing the plugin callback as the url. That bit of code is as follows

Code:
list_item = xbmcgui.ListItem(label=label_text)
is_folder = False
list_item.setProperty('IsPlayable','true')
url = get_url(resolve=''.join([base, link[8:]]))
xbmcplugin.addDirectoryItem(_handle, url, list_item, is_folder)

Then, in my routing I pass the link in the `resolve` param to the following procedure

Code:
def play_video(link):
    """
    Play a video by the provided path.
    :param path: str
    :return: None
    """
    print 'link is :' + link
    
    vid = YDStreamExtractor.getVideoInfo(link,quality=1) #quality is 0=SD, 1=720p, 2=1080p and is a maximum
    if vid is not None:
        stream_url = vid.streamURL() #This is what Kodi (XBMC) will play
        print 'stream_url is :' + stream_url
        if stream_url is not None:
            if 'youtube.com' in stream_url:
                print stream_url.split('|')[0].split('=')[1]
                stream_url = 'plugin://plugin.video.youtube/play/?video_id=' + stream_url.split('|')[0].split('=')[1]
                
            # Create a playable item with a path to play.
            play_item = xbmcgui.ListItem(path=stream_url)
            play_item.setProperty('IsPlayable','true')
            xbmcplugin.setResolvedUrl(_handle, True, listitem=play_item)
    else:
        xbmcplugin.setResolvedUrl(_handle, False, listitem=xbmcgui.ListItem())

This is only way I've been able to get the links to play when selected in the directory listing. However, after stopping the video I noticed the following errors/warnings in the debug log

Code:
12:10:57.424 T:2384   DEBUG: CVideoDatabase::RunQuery took 2 ms for 31 items query: SELECT  files.strFilename, files.playCount,  bookmark.timeInSeconds, bookmark.totalTimeInSeconds FROM files  LEFT JOIN bookmark ON    files.idFile = bookmark.idFile AND bookmark.type = 1  WHERE files.idPath=2
12:10:57.441 T:3408   DEBUG: Thread BackgroundLoader start, auto delete: false
12:10:57.455 T:3436   DEBUG: CSaveFileStateJob::DoWork - Saving file state for video item plugin://plugin.video.Squeee/?resolve=http%3A%2F%2Fwww.funnycatsite.com%2Fvideos%2Fkitten-vs-force-field.htm
12:10:58.974 T:2384   DEBUG: CWinEventsWin32::WndProcWindow is active
12:10:58.974 T:2384   DEBUG: CWinEventsWin32::WndProc: Focus switched to process C:\Program Files (x86)\Notepad++\notepad++.exe
12:10:59.218 T:3436   DEBUG: CThumbExtractor::DoWork - trying to extract thumb from video file plugin://plugin.video.Squeee/?resolve=http%3A%2F%2Fwww.dailyhaha.com%2F_vids%2Fan-amazingly-well-trained-dog.htm
12:10:59.218 T:3436 WARNING: XFILE::CFileFactory::CreateLoader - unsupported protocol(plugin) in plugin://plugin.video.Squeee/?resolve=http%3A%2F%2Fwww.dailyhaha.com%2F_vids%2Fan-amazingly-well-trained-dog.htm
12:10:59.218 T:3436   ERROR: InputStream: Error opening, plugin://plugin.video.Squeee/?resolve=http%3A%2F%2Fwww.dailyhaha.com%2F_vids%2Fan-amazingly-well-trained-dog.htm
12:10:59.230 T:3436   DEBUG: CThumbExtractor::DoWork - trying to extract thumb from video file plugin://plugin.video.Squeee/?resolve=http%3A%2F%2Fwww.dailyhaha.com%2F_vids%2Ftetherball-left-in-the-forest.htm
12:10:59.231 T:3436 WARNING: XFILE::CFileFactory::CreateLoader - unsupported protocol(plugin) in plugin://plugin.video.Squeee/?resolve=http%3A%2F%2Fwww.dailyhaha.com%2F_vids%2Ftetherball-left-in-the-forest.htm
12:10:59.231 T:3436   ERROR: InputStream: Error opening, plugin://plugin.video.Squeee/?resolve=http%3A%2F%2Fwww.dailyhaha.com%2F_vids%2Ftetherball-left-in-the-forest.htm
12:10:59.236 T:3436   DEBUG: CThumbExtractor::DoWork - trying to extract thumb from video file plugin://plugin.video.Squeee/?resolve=http%3A%2F%2Fwww.dailyhaha.com%2F_vids%2Fjack-russell-goes-crazy-at-competition.htm

I thought that by following the above links instructions in setting the list_items as IsFolder=False & IsPlayable=True that only the link that is selected will be processed, but from the above debug log it appears all of the list items are trying to be evaluated after stopping a video. What am I doing wrong? I'd really appreciate some input as for some reason I still cannot wrap my head around the correct usage of setResolvedUrl.
Quote:pro·gram·mer (n): An organism capable of converting caffeine into code.
Reply
#2
You can safely ignore the above warnings.
Reply
#3
(2017-06-08, 21:20)Roman_V_M Wrote: You can safely ignore the above warnings.

Ok, thank you for confirming that Roman. So, my usage/implementation is correct (finally)? Why are those warnings raised if the implementation is correct?

Also, am I handling invalid links correctly in the following portion?
Code:
else:
        xbmcplugin.setResolvedUrl(_handle, False, listitem=xbmcgui.ListItem())
Or do I need to do something else in order to keep the user on the same directory? The only other thing I'll do for bad links is show a notification indicating the bad link.
Quote:pro·gram·mer (n): An organism capable of converting caffeine into code.
Reply
#4
Kodi tries to extract thubnails and mediainfo for list items which does not make much sense for a virtual path.
Reply

Logout Mark Read Team Forum Stats Members Help
Still Confused about setResolvedUrl, IsPlayable & IsFolder for ListItems0