picture plugin question: how to display the picture from an image URL?
#1
Greetings!

I followed https://github.com/romanvm/plugin.video.example to learn to create a  video plugin, and now working on creating a picture plugin. picture_list is the list of pictures, and I'd like to have the images fetched and displayed as a slideshow. Here's the code I've so far:

Code:

# -*- coding: utf-8 -*-
# Module: default
# let's figure this out!
 
import sys
from urllib import urlencode
from urlparse import parse_qsl
import xbmcgui
import xbmcplugin
import time
import requests
import random
 
myReq = requests.Session()
picture_list = ["https://www.vidsplay.com/wp-content/uploads/2017/04/crab-screenshot.jpg",
                'http://www.vidsplay.com/wp-content/uploads/2017/04/alligator-screenshot.jpg',
                'http://www.vidsplay.com/wp-content/uploads/2017/04/turtle-screenshot.jpg' ]
_handle = int(sys.argv[1])
 
 
def play_video(path):
    """
    Play a video by the provided path.
 
    :param path: Fully-qualified video URL
    :type path: str
    """
    logString("fnname play_video")
    # Create a playable item with a path to play.
    play_item = xbmcgui.ListItem(path=path)
    # Pass the item to the Kodi player.
    xbmcplugin.setResolvedUrl(_handle, True, listitem=play_item)
 
 
def logString(*argv):
    try:
        with open("/tmp/kodi.diag", "ab") as fobj:
            fobj.write(time.ctime() + " Params: " + " ".join(argv) + "\n")
    except:
        pass
 
if __name__ == '__main__':
    logString("We are evoked with {args}".format(args= " ".join(sys.argv)))
    logString("handle is {X}".format(X=_handle))
    thisArg = sys.argv[2][1:]
 
    if not thisArg:
        xbmcplugin.setContent(_handle, 'images')
 
    for i in range(3):
        dialog = xbmcgui.Dialog()
        dialog.ok('Kodi', 'How to display', picture_list)

I am able to display the URLs using xbmcgui.Dialog().ok(), https://evuraan.info/screenshots/images/kodi-pic.png shows where I am at.  If this is the right approach how can I further display the actual image on the screen?

Any help would be much appreciated, thanks!

Image
Reply
#2
Answering my own question

python:

    for i in range(5):
        #dialog = xbmcgui.Dialog()
        #dialog.ok('Kodi', 'How to display this image?', picture_list)
        pic = picture_list
[i]        label = pic.split("/")[-1]
        if "thumb" in pic or "sized" in label:
            continue
        url = Base + picture_list
[i]        Head = myReq.head(url)
        if not Head.ok:
            continue
        li = xbmcgui.ListItem(label=label, thumbnailImage=url)
        li.setInfo(type='image', infoLabels={'Title': pic})
        xbmcplugin.addDirectoryItem(
            handle=int(sys.argv[1]),
            url = url,
            listitem=li,
            isFolder=False
        )
    xbmcplugin.endOfDirectory(int(sys.argv[1]))

A good reference point: https://github.com/idleloop-github/scrip.../plugin.py[/i][/i]
Reply
#3
I tried the same, but with the XBMCSourcePlugin:
If it create the directory item:
python:

plugin = XBMCSourcePlugin()

...

        plugin.addDirectoryItem(url=thumb+"|"+cookies, listitem=listitem,  isFolder=False)
Where the thumb is the whole url for the image with query string:
and the cookies is the cookies for the request.
The item is showing but after the select do nothing (I hear the sound). I pass thru an debug proxy, and not even call the url.

If I change the url to inner call and created a new function to show the image:
python:

        xbmc.executebuiltin('ShowPicture(%s|%s)'%(url,cookies))
is working.
(with this solution I have many problem:
1, cant go to the next picture
2, i'd like to use the plugin.getSetting('server'), but in this case (only in this case) give back nothing, look like need somewhere an extra parameter?)

thanks for any help
Reply

Logout Mark Read Team Forum Stats Members Help
picture plugin question: how to display the picture from an image URL?0