def viewImage(image_url, name, preview_url):
    from guis import cGUI

    log('  viewImage %s, %s, %s' % (image_url, name, preview_url))

    #msg=WINDOW.getProperty(url)
    #WINDOW.clearProperty( url )
    #log( '   msg=' + msg )
    msg = ""
    li = []
    liz = xbmcgui.ListItem(label=msg, label2="")
    liz.setInfo(type='video', infoLabels={
        "plot": msg,
    })
    liz.setArt({"thumb": preview_url, "banner": image_url})

    li.append(liz)
    ui = cGUI('view_450_slideshow.xml',
              addon_path,
              defaultSkin='Default',
              defaultRes='1080i',
              listing=li,
              id=53)
    ui.include_parent_directory_entry = False

    ui.doModal()
    del ui
    return
Ejemplo n.º 2
0
def dictlist_to_RelatedVideo_gui(dictlist, url, url_type, title, type_, poster=None ):
    from utils import dictlist_to_listItems
    from ContextMenus import build_youtube_context_menu_entries, build_add_to_favourites_context_menu_entry

    context_menu_list=[]

    gui_title_text=None
    if dictlist:
        #log(pprint.pformat(dictlist))
        directory_items=dictlist_to_listItems(dictlist)
        for li in directory_items:
            link_url=li.getProperty('link_url')
            video_id=li.getProperty('video_id')
            label=li.getLabel()
            channel_name=li.getProperty('channel_name')
            channel_id=li.getProperty('channel_id')
            onClick_action=li.getProperty('onClick_action')
            thumbnail=li.getArt('thumb')
            del context_menu_list[:] #empty the list
            context_menu_list.extend(build_youtube_context_menu_entries(type_,link_url,video_id, title=label, channel_id_from_previous_listing=channel_id,channel_name=channel_name))
            context_menu_list.extend(build_add_to_favourites_context_menu_entry(label,onClick_action,thumbnail) )
            li.setProperty('context_menu', str(context_menu_list) )

        if type_=='links_in_description':
            from guis import text_to_links_gui
            ui = text_to_links_gui('srr_links_in_text.xml' , addon_path, defaultSkin='Default', defaultRes='1080i', listing=directory_items, title=title, poster=poster)

        else: # 'channel' 'related' default
            if type_=='related':
                gui_title_text="Related videos: {0}".format(title)
            if type_=='search':
                gui_title_text="Search: {0}".format(title)
            elif type_=='channel':
                gui_title_text="Channel: {0}".format(dictlist[0].get('channel_name'))
            elif type_=='playlist':
                gui_title_text="{0}".format(title)
            elif type_=='playlists':
                gui_title_text="Playlists in channel: {0}".format(dictlist[0].get('channel_name'))
            else:#type determined from url
                if url_type=='channel':
                    gui_title_text="Videos in channel"
                elif url_type=='playlist':
                    gui_title_text="{0}".format(title)
                elif url_type=='user':
                    gui_title_text="User Videos"
                elif url_type=='more':
                    gui_title_text="{0}".format(title)

            from guis import cGUI
            ui = cGUI('srr_related_videos.xml' , addon_path, defaultSkin='Default', defaultRes='1080i', listing=directory_items, id=55, title=gui_title_text, poster=poster)
            ui.include_parent_directory_entry=False
        ui.doModal()
        del ui
Ejemplo n.º 3
0
def display_album_from(dictlist, album_name):
    from utils import dictlist_to_listItems

    directory_items=dictlist_to_listItems(dictlist)

    from guis import cGUI

    #msg=WINDOW.getProperty(url)
    #WINDOW.clearProperty( url )
    #log( '   msg=' + msg )

    ui = cGUI('view_450_slideshow.xml' , addon_path, defaultSkin='Default', defaultRes='1080i', listing=directory_items, id=53)
    ui.include_parent_directory_entry=False
    #ui.title_bar_text=WINDOW.getProperty(url)

    ui.doModal()
    del ui
Ejemplo n.º 4
0
def viewImage(image_url, name, preview_url):
    from guis import cGUI

    log('  viewImage %s, %s, %s' %( image_url, name, preview_url))

    msg=""
    li=[]
    liz=xbmcgui.ListItem(label=msg, label2="")
    liz.setInfo( type='video', infoLabels={"plot": msg, } )
    liz.setArt({"thumb": preview_url, "banner":image_url })

    li.append(liz)
    ui = cGUI('view_450_slideshow.xml' , addon_path, defaultSkin='Default', defaultRes='1080i', listing=li, id=53)
    ui.include_parent_directory_entry=False

    ui.doModal()
    del ui
    return
Ejemplo n.º 5
0
def listRecentlyPlayed(url,name,type_):
    from utils import db_getLastPlayedVideos,build_script,ret_info_type_icon,truncate_middle,pretty_datediff_wrap
    from domains import parse_reddit_link,sitesBase
    from ContextMenus import build_youtube_context_menu_entries,build_reddit_search_context_menu_entries

    recently_played_links=db_getLastPlayedVideos()

    directory_items=[]
    for idx, recently_played_tuple in enumerate(recently_played_links):
        #log(repr(recently_played_tuple))
        last_played, recently_played_url=recently_played_tuple
        pretty_date=pretty_datediff_wrap(last_played,use_utc_as_base=False)
        #log("---{0} {1}".format(pretty_date, last_played ) )
        parsed_web_url=parse_web_url_from(recently_played_url) #grabs the (youtube) url from plugin://plugin.video...
        #log('recent{0}:{1}'.format(idx, recently_played_url))
        if not parsed_web_url:
            log('    listRecentlyPlayed skipping:{0}'.format(recently_played_url))
            continue
        link_components=urlparse.urlparse( parsed_web_url )
        domain=link_components.netloc
        label=parsed_web_url     #recently_played_url.split("|", 1)[0] #remove |Useragent:...
        liz=xbmcgui.ListItem(label=truncate_middle(label, 110), label2=pretty_date )

        liz.setInfo( type="Video", infoLabels={ "Title": parsed_web_url, "plot": recently_played_url, "studio": domain } )

        ld=parse_reddit_link(link_url=parsed_web_url, assume_is_video=True, needs_preview=False )
        if ld:
            #use clearart to indicate if link is video, album or image. here, we default to unsupported.
            #clearart=ret_info_type_icon(setInfo_type, mode_type)
            clearart=ret_info_type_icon(ld.media_type, ld.link_action, domain )
            liz.setArt({ "clearart": clearart  })

            if ld.link_action == sitesBase.DI_ACTION_PLAYABLE:
                property_link_type=ld.link_action
                DirectoryItem_url =ld.playable_url
            else:
                property_link_type='script'
                DirectoryItem_url = build_script(mode=ld.link_action,
                                                 url=ld.playable_url,
                                                 name='' ,
                                                 type_='' )

            if DirectoryItem_url:
                #log(DirectoryItem_url)
                liz.setArt({"thumb": ld.thumb,"banner":ld.poster })

                liz.setProperty('item_type',property_link_type)   #script or playable
                liz.setProperty('onClick_action', DirectoryItem_url)  #<-- needed by the xml gui skin
                liz.setProperty('link_url', recently_played_url )  #just used as text at bottom of the screen
                #liz.setPath(DirectoryItem_url)

                context_menu_list=[]
                context_menu_list.extend(build_youtube_context_menu_entries(previous_listing_was_of_type='',youtube_url=parsed_web_url,video_id=None))
                context_menu_list.extend(build_reddit_search_context_menu_entries(False,'',parsed_web_url) )
                #context_menu_list.extend(build_reddit_context_menu_entries(link_url))
                liz.setProperty('context_menu', str(context_menu_list) )

                #directory_items.append( (DirectoryItem_url, liz,) )
        else:
            log("*************not ld*****************")

        directory_items.append( liz )

    #from guis import text_to_links_gui
    #ui = text_to_links_gui('srr_links_in_text.xml' , addon_path, defaultSkin='Default', defaultRes='1080i', listing=directory_items, title='Recently Played', poster=None)
    from guis import cGUI
    ui = cGUI('srr_history_list.xml' , addon_path, defaultSkin='Default', defaultRes='1080i', listing=directory_items, id=55, title='Recently Played')
    ui.include_parent_directory_entry=False

    ui.doModal()
    del ui
def display_album_from(dictlist, album_name):
    from domains import parse_reddit_link, build_DirectoryItem_url_based_on_media_type, sitesBase
    from utils import build_script
    directory_items = []

    album_viewMode = addon.getSetting("album_viewMode")

    if album_viewMode == '450':  #using custom gui
        using_custom_gui = True
    else:
        using_custom_gui = False

    #log( repr(dictlist))
    for _, d in enumerate(dictlist):
        ti = d['li_thumbnailImage']
        media_url = d.get('DirectoryItem_url')

        #log('  display_album_from list:'+ media_url + "  " )
        #There is only 1 textbox for Title and description in our custom gui.
        #  I don't know how to achieve this in the xml file so it is done here:
        #  combine title and description without [CR] if label is empty. [B]$INFO[Container(53).ListItem.Label][/B][CR]$INFO[Container(53).ListItem.Plot]
        #  new note: this is how it is done:
        #     $INFO[Container(53).ListItem.Label,[B],[/B][CR]] $INFO[Container(53).ListItem.Plot]  #if the infolabel is empty, nothing is printed for that block
        #combined = '[B]'+ d['li_label2'] + "[/B][CR]" if d['li_label2'] else ""
        combined = d['infoLabels'].get('plot') if d['infoLabels'].get(
            'plot') else ""
        d['infoLabels']['plot'] = combined

        liz = xbmcgui.ListItem(label=d.get('li_label'),
                               label2=d.get('li_label2'))

        #parse the link so that we can determine whether it is image or video.
        ld = parse_reddit_link(media_url)
        DirectoryItem_url, setProperty_IsPlayable, isFolder, _ = build_DirectoryItem_url_based_on_media_type(
            ld, media_url, '', '', script_to_call="")
        #log('isFolder:' + repr(isFolder)+ ' IsPlayable:'+repr(setProperty_IsPlayable) + ' DirectoryItem_url:' + repr(DirectoryItem_url))
        if using_custom_gui:
            url_for_DirectoryItem = media_url
            liz.setProperty('onClick_action', DirectoryItem_url)
            liz.setProperty('is_video', 'true')
            #if setProperty_IsPlayable=='true':
            if ld:
                if ld.link_action == sitesBase.DI_ACTION_PLAYABLE:
                    liz.setProperty('item_type', 'playable')
                else:
                    #this part is for playing video that needs to be resolved first. (youtube_dl)
                    #I could not get this to work  -->  #Attempt to use invalid handle -1
                    #I think you can't setresolvedUrl a listitem from a custom gui
                    #url_for_DirectoryItem=DirectoryItem_url
                    liz.setProperty('item_type', 'script')
        else:
            #sys.argv[0]+"?url="+ urllib.quote_plus(d['DirectoryItem_url']) +"&mode=viewImage"

            #with xbmc's standard gui, we need to specify to call the plugin to open the gui that shows image
            #log('***'+'isFolder:' + repr(isFolder)+ ' IsPlayable:'+repr(setProperty_IsPlayable) +'**[diu]:'+ DirectoryItem_url)
            liz.setProperty('IsPlayable', setProperty_IsPlayable)
            url_for_DirectoryItem = DirectoryItem_url

        liz.setInfo(
            type='video', infoLabels=d['infoLabels']
        )  #this tricks the skin to show the plot. where we stored the picture descriptions
        liz.setArt({
            "thumb": ti,
            'icon': ti,
            "poster": media_url,
            "banner": media_url,
            "fanart": media_url,
            "landscape": media_url
        })

        directory_items.append((url_for_DirectoryItem, liz, isFolder))

    if using_custom_gui:
        from guis import cGUI
        li = []
        for di in directory_items:
            li.append(di[1])

        ui = cGUI('view_450_slideshow.xml',
                  addon_path,
                  defaultSkin='Default',
                  defaultRes='1080i',
                  listing=li,
                  id=53)
        ui.include_parent_directory_entry = False

        ui.doModal()
        del ui
    else:
        if album_viewMode != '0':
            xbmc.executebuiltin('Container.SetViewMode(' + album_viewMode +
                                ')')

        xbmcplugin.addDirectoryItems(handle=pluginhandle,
                                     items=directory_items)
        xbmcplugin.endOfDirectory(pluginhandle)
Ejemplo n.º 7
0
def display_album_from(dictlist, album_name):
    from domains import sitesBase
    from utils import build_script
    directory_items = []
    label = ""

    for idx, d in enumerate(dictlist):
        ti = d['li_thumbnailImage']
        media_url = d.get('DirectoryItem_url')
        media_type = d.get('type')
        media_thumb = d.get('thumb')
        isPlayable = d.get('isPlayable')

        #Error Type: <type 'exceptions.TypeError'> cannot concatenate 'str' and 'list' objects
        log(
            '  display_album_from list:' + media_url + "  " + repr(media_type)
        )  # ****** don't forget to add "[0]" when using parseDOM    parseDOM(div,"img", ret="src")[0]

        #There is only 1 textbox for Title and description in our custom gui.
        #  I don't know how to achieve this in the xml file so it is done here:
        #  combine title and description without [CR] if label is empty. [B]$INFO[Container(53).ListItem.Label][/B][CR]$INFO[Container(53).ListItem.Plot]
        #  new note: this is how it is done:
        #     $INFO[Container(53).ListItem.Label,[B],[/B][CR]] $INFO[Container(53).ListItem.Plot]  #if the infolabel is empty, nothing is printed for that block
        combined = '[B]' + d['li_label2'] + "[/B][CR]" if d['li_label2'] else ""
        combined += d['infoLabels'].get('plot') if d['infoLabels'].get(
            'plot') else ""
        d['infoLabels']['plot'] = combined
        #d['infoLabels']['genre'] = "0,-2000"
        #d['infoLabels']['year'] = 1998
        #log( d['infoLabels'].get('plot') )

        liz = xbmcgui.ListItem(label=label,
                               label2=d['li_label2'],
                               iconImage=media_thumb,
                               thumbnailImage=media_thumb)

        if media_type == sitesBase.TYPE_VIDEO:
            if isPlayable == 'true':
                liz.setProperty('item_type', 'playable')
                liz.setProperty('onClick_action', media_url)
            else:
                liz.setProperty('item_type', 'script')
                liz.setProperty(
                    'onClick_action',
                    build_script('playYTDLVideo', media_url, '', media_thumb))

        liz.setInfo(
            type='video', infoLabels=d['infoLabels']
        )  #this tricks the skin to show the plot. where we stored the picture descriptions
        #liz.setArt({"thumb": ti, "poster":poster_url, "banner":d['DirectoryItem_url'], "fanart":poster_url, "landscape":d['DirectoryItem_url']   })
        liz.setArt({"thumb": ti, "banner": media_url})

        directory_items.append((
            media_url,
            liz,
            False,
        ))

    from guis import cGUI

    #msg=WINDOW.getProperty(url)
    #WINDOW.clearProperty( url )
    #log( '   msg=' + msg )

    #<label>$INFO[Window(10000).Property(foox)]</label>
    #WINDOW.setProperty('view_450_slideshow_title',WINDOW.getProperty(url))

    li = []
    for di in directory_items:
        #log( str(di[1] ) )
        li.append(di[1])

    ui = cGUI('view_450_slideshow.xml',
              addon_path,
              defaultSkin='Default',
              defaultRes='1080i',
              listing=li,
              id=53)

    ui.include_parent_directory_entry = False
    #ui.title_bar_text=WINDOW.getProperty(url)

    ui.doModal()
    del ui
Ejemplo n.º 8
0
def display_album_from(dictlist, album_name):
    from domains import parse_reddit_link, build_DirectoryItem_url_based_on_media_type, sitesBase
    from utils import build_script
    directory_items=[]

    album_viewMode=addon.getSetting("album_viewMode")

    if album_viewMode=='450': #using custom gui
        using_custom_gui=True
    else:
        using_custom_gui=False

    for _, d in enumerate(dictlist):
        ti=d['li_thumbnailImage']
        media_url=d.get('DirectoryItem_url')

        combined = d['infoLabels'].get('plot') if d['infoLabels'].get('plot') else ""
        d['infoLabels']['plot'] = combined

        liz=xbmcgui.ListItem(label=d.get('li_label'), label2=d.get('li_label2') )

        ld=parse_reddit_link(media_url)
        DirectoryItem_url, setProperty_IsPlayable, isFolder, _ = build_DirectoryItem_url_based_on_media_type(ld, media_url, '', '', script_to_call="")

        if using_custom_gui:
            url_for_DirectoryItem=media_url
            liz.setProperty('onClick_action',  DirectoryItem_url )
            liz.setProperty('is_video','true')

            if ld.link_action == sitesBase.DI_ACTION_PLAYABLE:
                liz.setProperty('item_type','playable')
            else:

                liz.setProperty('item_type','script')
        else:

            liz.setProperty('IsPlayable',setProperty_IsPlayable)
            url_for_DirectoryItem=DirectoryItem_url

        liz.setInfo( type='video', infoLabels=d['infoLabels'] ) #this tricks the skin to show the plot. where we stored the picture descriptions
        liz.setArt({"thumb": ti,'icon': ti, "poster":media_url, "banner":media_url, "fanart":media_url, "landscape":media_url   })

        directory_items.append( (url_for_DirectoryItem, liz, isFolder) )

    if using_custom_gui:
        from guis import cGUI
        li=[]
        for di in directory_items:
            li.append( di[1] )

        ui = cGUI('view_450_slideshow.xml' , addon_path, defaultSkin='Default', defaultRes='1080i', listing=li, id=53)
        ui.include_parent_directory_entry=False

        ui.doModal()
        del ui
    else:
        if album_viewMode!='0':
            xbmc.executebuiltin('Container.SetViewMode('+album_viewMode+')')

        xbmcplugin.addDirectoryItems(handle=pluginhandle, items=directory_items )
        xbmcplugin.endOfDirectory(pluginhandle)
Ejemplo n.º 9
0
def display_album_from(dictlist, album_name):
    from domains import parse_reddit_link, build_DirectoryItem_url_based_on_media_type, sitesBase
    from utils import build_script
    directory_items=[]

    album_viewMode=addon.getSetting("album_viewMode")

    if album_viewMode=='450': #using custom gui
        using_custom_gui=True
    else:
        using_custom_gui=False

    #log( repr(dictlist))
    for _, d in enumerate(dictlist):
        ti=d['li_thumbnailImage']
        media_url=d.get('DirectoryItem_url')

        #log('  display_album_from list:'+ media_url + "  " )
        #There is only 1 textbox for Title and description in our custom gui.
        #  I don't know how to achieve this in the xml file so it is done here:
        #  combine title and description without [CR] if label is empty. [B]$INFO[Container(53).ListItem.Label][/B][CR]$INFO[Container(53).ListItem.Plot]
        #  new note: this is how it is done:
        #     $INFO[Container(53).ListItem.Label,[B],[/B][CR]] $INFO[Container(53).ListItem.Plot]  #if the infolabel is empty, nothing is printed for that block
        #combined = '[B]'+ d['li_label2'] + "[/B][CR]" if d['li_label2'] else ""
        combined = d['infoLabels'].get('plot') if d['infoLabels'].get('plot') else ""
        d['infoLabels']['plot'] = combined

        liz=xbmcgui.ListItem(label=d.get('li_label'), label2=d.get('li_label2') )

        #parse the link so that we can determine whether it is image or video.
        ld=parse_reddit_link(media_url)
        DirectoryItem_url, setProperty_IsPlayable, isFolder, _ = build_DirectoryItem_url_based_on_media_type(ld, media_url, '', '', script_to_call="")
        #log('isFolder:' + repr(isFolder)+ ' IsPlayable:'+repr(setProperty_IsPlayable) + ' DirectoryItem_url:' + repr(DirectoryItem_url))
        if using_custom_gui:
            url_for_DirectoryItem=media_url
            liz.setProperty('onClick_action',  DirectoryItem_url )
            liz.setProperty('is_video','true')
            #if setProperty_IsPlayable=='true':
            if ld:
                if ld.link_action == sitesBase.DI_ACTION_PLAYABLE:
                    liz.setProperty('item_type','playable')
                else:
                    #this part is for playing video that needs to be resolved first. (youtube_dl)
                    #I could not get this to work  -->  #Attempt to use invalid handle -1
                    #I think you can't setresolvedUrl a listitem from a custom gui
                    #url_for_DirectoryItem=DirectoryItem_url
                    liz.setProperty('item_type','script')
        else:
            #sys.argv[0]+"?url="+ urllib.quote_plus(d['DirectoryItem_url']) +"&mode=viewImage"

            #with xbmc's standard gui, we need to specify to call the plugin to open the gui that shows image
            #log('***'+'isFolder:' + repr(isFolder)+ ' IsPlayable:'+repr(setProperty_IsPlayable) +'**[diu]:'+ DirectoryItem_url)
            liz.setProperty('IsPlayable',setProperty_IsPlayable)
            url_for_DirectoryItem=DirectoryItem_url

        liz.setInfo( type='video', infoLabels=d['infoLabels'] ) #this tricks the skin to show the plot. where we stored the picture descriptions
        liz.setArt({"thumb": ti,'icon': ti, "poster":media_url, "banner":media_url, "fanart":media_url, "landscape":media_url   })

        directory_items.append( (url_for_DirectoryItem, liz, isFolder) )

    if using_custom_gui:
        from guis import cGUI
        li=[]
        for di in directory_items:
            li.append( di[1] )

        ui = cGUI('view_450_slideshow.xml' , addon_path, defaultSkin='Default', defaultRes='1080i', listing=li, id=53)
        ui.include_parent_directory_entry=False

        ui.doModal()
        del ui
    else:
        if album_viewMode!='0':
            xbmc.executebuiltin('Container.SetViewMode('+album_viewMode+')')

        xbmcplugin.addDirectoryItems(handle=pluginhandle, items=directory_items )
        xbmcplugin.endOfDirectory(pluginhandle)