Video Addon: Displaying a Picture?
#1
Question 
Hello,

I am scraping a mainly video-serving website. However, sometimes they also offer pictures. I wanted it to remain a video plugin, and was wondering, if it is possible to display a picture from within a video plugin?


I did try setting the property:

liz.setInfo( type="image", infoLabels={ "Title": name } )

But alas, no luck Smile Any advice would be appreciated.
Reply
#2
currently not possible to mix images and other media.
Reply
#3
spiff Wrote:currently not possible to mix images and other media.

I noticed, and then, I worked around it, with the help from __y Smile

What I ended up doing is using the built-in execute of the Slideshow thanks to __y !
So the addon currently downloads the images to a temporary folder, then does initiate the slideshow.

For those interested, here is a some of the source:

This will Launch it - I used mode 4
Code:
elif mode==4:
    screenshots = common.get_screenshots(url)
    directory = xbmc.translatePath(os.path.join('special://profile/addon_data/plugin.video.xxx/', 'cache'))
    common.Generate_Slideshow(screenshots)
    xbmc.executebuiltin("XBMC.SlideShow(" + directory + ")")

from my common.py

Code:
def get_screenshots(url):
    UAS = 'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10 ( .NET CLR 3.5.30729; .NET4.0C)'
    req = urllib2.Request(url)
    req.add_header('User-Agent', UAS)
    response = urllib2.urlopen(req)
    html=response.read()
    response.close()
    html = html.replace("\n", "")
    html = html.replace("\r", "")

    # Cache Folder Preparation - automatically deletes it
    folder = xbmc.translatePath(os.path.join('special://profile/addon_data/plugin.video.xxx/', 'cache'))
    if os.path.isdir(folder)==False:
        os.makedirs(folder)

    for the_file in os.listdir(folder):
        file_path = xbmc.translatePath(os.path.join(folder, the_file))
        if os.path.isfile(file_path):
            os.unlink(file_path)

                
    #regex it
    regex = '<a href="#" onclick="openimagepopup.+?;return false;"><img src="(.+?)".+?</a>'
    images = re.compile(regex).findall(html)
    screenshots = []
    if len(images) > 0:
        total = len(images)
        for image in images:
            screenshots.append(image)
    else:
        print "Error"
        return "ERROR"
    
    return screenshots

Slideshow Generator Function:

Code:
def Generate_Slideshow(screenshots):
    global pDialog
    name = "JESUS"
    pDialog = xbmcgui.DialogProgress()
    dia_title = "Getting Image(s)"
    dia_l1 = name
    ret = pDialog.create(dia_title, dia_l1)
    current_item = 0
    total = len(screenshots)
    for image in screenshots:
        current_item = current_item + 1

        name = image.replace('blahblah', '')    
        thumbnail = image
        filename = xbmc.translatePath(os.path.join('special://profile/addon_data/plugin.video.xxx/', 'cache', name))
        print "Filename: " + str(filename)
        print "URL: " + str(screenshot)
        img_download(filename, screenshot, current_item, total)
        
    return

And the image downloader:

Code:
def img_download(fname,url,current_item,total):
    from urllib2 import Request, urlopen, URLError, HTTPError
    req = Request(url)
    try:
        global pDialog
        percent = (float(current_item) / float(total)) * float(100)
        name = url.replace('xxx', '')
        pDialog.update(int(percent), name)
        
        f = urlopen(req)
        local_file = open(fname, "wb")
        local_file.write(f.read())
        local_file.close()

    except HTTPError, e:
        print "HTTP Error:",e.code , url
    except URLError, e:
        print "URL Error:",e.reason , url
    return

Its simple and straight forward imho - I don't do any error checking as of yet, whether I returned error or a list (Array), but that shouldnt be too hard Smile
Reply
#4
Hi,
Could you please tell us in detail. Like where do I add these codes to create a video add on. I want to display a slideshow at the bottom of a screen when I am playing a video.
Reply
#5
I am not sure I follow you sarosh? Could you explain in more detail what you wish to do ?
Reply
#6
Hi
I would like to display a slideshow at the bottom of the screen when a video is running on the screen.


So for example I am watching a video, at the bottom of that video I would like to display a slideshow which will list the latest movies that have been added to our site. So people can download those vidoes from my site.

Thanks

Sarosh
Reply
#7
that's completely unrelated to this. you would need to write yourself a custom dialog and activate it. in the dialog you'd use image controls.
Reply
#8
Thanks Insayne for the tip. A workaround I found was to set your addon to <provides>video image</provides> in addon.xml
When your addon is run as a pictures addon, it will show the pictures and play videos too!
Reply
#9
The slideshow workaround only works on windows
Reply

Logout Mark Read Team Forum Stats Members Help
Video Addon: Displaying a Picture?0