Python xbmcplugin.addDirectoryItem() Examples

The following are 30 code examples of xbmcplugin.addDirectoryItem(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module xbmcplugin , or try the search function .
Example #1
Source File: main.py    From kodi.kino.pub with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def bookmarks():
    img = plugin.routing.build_icon_path("create_bookmarks_folder")
    li = plugin.list_item("Создать папку", iconImage=img, thumbnailImage=img)
    url = plugin.routing.build_url("create_bookmarks_folder")
    xbmcplugin.addDirectoryItem(plugin.handle, url, li, False)
    response = plugin.client("bookmarks").get()
    for folder in response["items"]:
        img = plugin.routing.build_icon_path("bookmark")
        li = plugin.list_item(
            folder["title"],
            iconImage=img,
            thumbnailImage=img,
            properties={"folder-id": str(folder["id"]), "views": str(folder["views"])},
        )
        url = plugin.routing.build_url("remove_bookmarks_folder", folder["id"])
        li.addContextMenuItems([("Удалить", "Container.Update({})".format(url))])
        url = plugin.routing.build_url("bookmarks", folder["id"])
        xbmcplugin.addDirectoryItem(plugin.handle, url, li, True)
    xbmcplugin.endOfDirectory(plugin.handle) 
Example #2
Source File: plugin.py    From kodi with GNU General Public License v3.0 6 votes vote down vote up
def process(kp_id, media_title, image):
    if (not kp_id):
        kp_id, media_title, media_title, image = prepare("process", kp_id, media_title, media_title, image)
    if (not kp_id):
        return
    list_li = []
    list_li = search.process(kp_id)
    
    for li in list_li:
        engine = get_engine(li[1].getLabel())
        
        li[0] = li[0] + ("&media_title=%s&image=%s&engine=%s" % ((urllib.quote_plus(encode_("utf-8", media_title))) if (media_title != "") else "", image, engine))
        li[1].setIconImage(image)
        li[1].setThumbnailImage(image)
        if ("*T*" in li[1].getLabel()):
            title = li[1].getLabel().replace("*T*", media_title)
            li[1].setLabel(title)
            li[0] = li[0] + ("&title=%s" % (urllib.quote_plus(title)))
                
        li[1].setInfo(type='Video', infoLabels={'title': li[1].getLabel(), 'label': media_title, 'plot': media_title})
        xbmcplugin.addDirectoryItem(HANDLE, li[0], li[1], li[2])
    xbmcplugin.setContent(HANDLE, 'movies')
    xbmcplugin.endOfDirectory(HANDLE, True) 
Example #3
Source File: default.py    From tdw with GNU General Public License v3.0 6 votes vote down vote up
def add_item (name, mode="", path = Pdir, ind="0", cover=None, funart=None):
	#print name
	#print path
	if   path.find("720p")>0: qual="[COLOR FFA900EF][ 720p ] [/COLOR]"
	elif path.find("480p")>0: qual="[COLOR FFFF0090][ 480p ] [/COLOR]"
	elif path.find("400p")>0: qual="[COLOR FF70F020][ 400p ] [/COLOR]"
	elif path.find("1080p")>0:qual="[COLOR FF50FF50][1080p] [/COLOR]"
	else: qual="[ ???? ] "
	if cover==None:	listitem = xbmcgui.ListItem(qual+"[B]"+name+"[/B]")
	else:			listitem = xbmcgui.ListItem(qual+"[B]"+name+"[/B]", iconImage=cover)
	listitem.setProperty('fanart_image', funart)
	uri = sys.argv[0] + '?mode='+mode
	uri += '&url='  + urllib.quote_plus(path.encode('utf-8'))
	uri += '&name='  + urllib.quote_plus(xt(name))
	uri += '&ind='  + urllib.quote_plus(ind)
	if cover!=None:uri += '&cover='  + urllib.quote_plus(cover)
	if funart!=None and funart!="":uri += '&funart='  + urllib.quote_plus(funart)
	
	if mode=="play": fld=False
	else: fld=True

	xbmcplugin.addDirectoryItem(handle, uri, listitem, fld) 
Example #4
Source File: default.py    From kodi with GNU General Public License v3.0 6 votes vote down vote up
def getCategories(url):
    result = common.fetchPage({"link": url})

    if result["status"] == 200:
        content = common.parseDOM(result["content"], "div", attrs = { "class":"mcont" })
        categories = common.parseDOM(content, "a", ret="href")
        descriptions = common.parseDOM(content, "a")

        for i in range(0, len(categories)):
            uri = sys.argv[0] + '?url=' + BASE_URL + categories[i]
            title = unescape(descriptions[i], 'cp1251')

            item = xbmcgui.ListItem(title)
            xbmcplugin.addDirectoryItem(pluginhandle, uri, item, True)

    xbmcplugin.setContent(pluginhandle, 'files')
    xbmcplugin.endOfDirectory(pluginhandle, True) 
Example #5
Source File: default.py    From kodi with GNU General Public License v3.0 6 votes vote down vote up
def show(self, link, image, name):
        response = common.fetchPage({"link": link})
        cid = link.split(self.url + "/")[-1].split("-")[0]
        playlist = self.getPlaylist(response['content'])
        if playlist:
            description = self.strip(response['content'].split("<!--dle_image_end-->")[1].split("<div")[0])
            currname = '' 
            duration = ''
            #description = common.parseDOM(response['content'], "meta", attrs={"name": "description"}, ret = "content")[0]
            if (self.use_epg == "true"):
                currname, duration, listItems = self.getEPG(cid = cid, cname=name, image=image)
            uri = sys.argv[0] + '?mode=play&url=%s&url2=%s' % (urllib.quote_plus(playlist), link)
            item = xbmcgui.ListItem("[COLOR=FF7B68EE]%s[/COLOR]" % self.language(1004),  iconImage=image, thumbnailImage=image)
            item.setInfo(type='Video', infoLabels={'title': currname if currname != '' else name, 'plot': description, 'duration': duration})
            item.setProperty('IsPlayable', 'true')
            xbmcplugin.addDirectoryItem(self.handle, uri, item, False)
    
            if (self.use_epg == "true"):
                xbmcplugin.addDirectoryItems(self.handle, listItems)
    
            xbmcplugin.setContent(self.handle, 'files')
            xbmcplugin.endOfDirectory(self.handle, True) 
Example #6
Source File: main.py    From bugatsinho.github.io with GNU General Public License v3.0 6 votes vote down vote up
def addLinkItem(name, url, mode, params=1, iconimage='DefaultFolder.png', infoLabels=False, IsPlayable=True,
                fanart=FANART, itemcount=1, contextmenu=None):
    u = build_url({'mode': mode, 'foldername': name, 'ex_link': url, 'params': params})

    liz = xbmcgui.ListItem(name)

    art_keys = ['thumb', 'poster', 'banner', 'fanart', 'clearart', 'clearlogo', 'landscape', 'icon']
    art = dict(zip(art_keys, [iconimage for x in art_keys]))
    art['landscape'] = fanart if fanart else art['landscape']
    art['fanart'] = fanart if fanart else art['landscape']
    liz.setArt(art)

    if not infoLabels:
        infoLabels = {"title": name}
    liz.setInfo(type="video", infoLabels=infoLabels)
    if IsPlayable:
        liz.setProperty('IsPlayable', 'true')

    if contextmenu:
        contextMenuItems = contextmenu
        liz.addContextMenuItems(contextMenuItems, replaceItems=True)

    ok = xbmcplugin.addDirectoryItem(handle=addon_handle, url=u, listitem=liz, isFolder=False, totalItems=itemcount)
    xbmcplugin.addSortMethod(addon_handle, sortMethod=xbmcplugin.SORT_METHOD_NONE, label2Mask="%R, %Y, %P")
    return ok 
Example #7
Source File: main.py    From bugatsinho.github.io with GNU General Public License v3.0 6 votes vote down vote up
def addDir(name, ex_link=None, params=1, mode='folder', iconImage='DefaultFolder.png', infoLabels=None, fanart=FANART,
           contextmenu=None):
    url = build_url({'mode': mode, 'foldername': name, 'ex_link': ex_link, 'params': params})

    nofolders = ['take_stream', 'opensettings', 'enable_input', 'forceupdate', 'open_news', 'ccache', 'showalts']
    folder = False if mode in nofolders else True

    li = xbmcgui.ListItem(name)
    if infoLabels:
        li.setInfo(type="video", infoLabels=infoLabels)
    li.setProperty('fanart_image', fanart)
    art_keys = ['thumb', 'poster', 'banner', 'fanart', 'clearart', 'clearlogo', 'landscape', 'icon']
    art = dict(zip(art_keys, [iconImage for x in art_keys]))
    art['landscape'] = fanart if fanart else art['landscape']
    art['fanart'] = fanart if fanart else art['landscape']
    li.setArt(art)

    if contextmenu:
        contextMenuItems = contextmenu
        li.addContextMenuItems(contextMenuItems, replaceItems=True)

    xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=folder)
    xbmcplugin.addSortMethod(addon_handle, sortMethod=xbmcplugin.SORT_METHOD_NONE, label2Mask="%R, %Y, %P") 
Example #8
Source File: default.py    From bugatsinho.github.io with GNU General Public License v3.0 6 votes vote down vote up
def downloads_root():
    movie_downloads = control.setting('movie.download.path')
    tv_downloads = control.setting('tv.download.path')
    cm = [(control.lang(32007).encode('utf-8'),
           'RunPlugin(plugin://plugin.video.releaseBB/?mode=settings)'),
          (control.lang(32008).encode('utf-8'), 'RunPlugin(plugin://plugin.video.releaseBB/?mode=ClearCache)')]
    if len(control.listDir(movie_downloads)[0]) > 0:
        item = control.item(label='Movies')
        item.addContextMenuItems(cm)
        item.setArt({'icon': IconPath + 'movies.png', 'fanart': FANART})
        xbmcplugin.addDirectoryItem(int(sys.argv[1]), movie_downloads, item, True)

    if len(control.listDir(tv_downloads)[0]) > 0:
        item = control.item(label='Tv Shows')
        item.addContextMenuItems(cm)
        item.setArt({'icon': IconPath + 'tv_shows.png', 'fanart': FANART})
        xbmcplugin.addDirectoryItem(int(sys.argv[1]), tv_downloads, item, True)

    control.content(int(sys.argv[1]), 'videos')
    control.directory(int(sys.argv[1]))
    view.setView('addons', {'skin.estuary': 55, 'skin.confluence': 500}) 
Example #9
Source File: directoryhandle.py    From program.plexus with GNU General Public License v2.0 6 votes vote down vote up
def addDir(name,url,mode,iconimage,total,pasta,fan_art="%s/fanart.jpg"%settings.getAddonInfo("path"),parser=None,parserfunction=None):
    if "plugin://" in sys.argv[0]: u = sys.argv[0]; sysargv = sys.argv[0]
    else: u = 'plugin://plugin.video.p2p-streams/'; sysargv = 'plugin://plugin.video.p2p-streams/'
    u += "?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)+"&iconimage="+urllib.quote_plus(iconimage)
    try: u += "&parser="+urllib.quote_plus(parser)
    except: pass
    try: u += "&parserfunction="+urllib.quote_plus(parserfunction)
    except: pass
    contextmen = []
    liz=xbmcgui.ListItem(name,iconImage="DefaultFolder.png", thumbnailImage=iconimage)
    liz.setInfo( type="Video", infoLabels={ "Title": name} )
    liz.setProperty('fanart_image', fan_art)
    if mode == 1 or mode == 2:
        fic = hashlib.md5(name + '|' + url).hexdigest() + '.txt'
        if os.path.exists(os.path.join(mystrm_folder,fic)):
            contextmen.append((translate(30025), 'XBMC.RunPlugin(%s?mode=13&url=%s&name=%s&iconimage=%s)' % (sysargv, urllib.quote_plus(url),name,iconimage)))
        else:
            contextmen.append((translate(30026), 'XBMC.RunPlugin(%s?mode=12&url=%s&name=%s&iconimage=%s)' % (sysargv,urllib.quote_plus(url),name,iconimage)))
    liz.addContextMenuItems(contextmen,replaceItems=False)
    return xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=pasta,totalItems=total) 
Example #10
Source File: plugin_content.py    From plugin.audio.spotify with GNU General Public License v3.0 6 votes vote down vote up
def add_next_button(self, listtotal):
        # adds a next button if needed
        params = self.params
        if listtotal > self.offset + self.limit:
            params["offset"] = self.offset + self.limit
            url = "plugin://plugin.audio.spotify/"
            for key, value in params.iteritems():
                if key == "action":
                    url += "?%s=%s" % (key, value[0])
                elif key == "offset":
                    url += "&%s=%s" % (key, value)
                else:
                    url += "&%s=%s" % (key, value[0])
            li = xbmcgui.ListItem(
                xbmc.getLocalizedString(33078),
                path=url,
                iconImage="DefaultMusicAlbums.png"
            )
            li.setProperty('do_not_analyze', 'true')
            li.setProperty('IsPlayable', 'false')
            xbmcplugin.addDirectoryItem(handle=self.addon_handle, url=url, listitem=li, isFolder=True) 
Example #11
Source File: directoryhandle.py    From program.plexus with GNU General Public License v2.0 6 votes vote down vote up
def addDir(name,url,mode,iconimage,total,pasta,fan_art="%s/fanart.jpg"%settings.getAddonInfo("path")):
    if "plugin://" in sys.argv[0]: u = sys.argv[0]; sysargv = sys.argv[0]
    else: u = 'plugin://program.plexus/'; sysargv = 'plugin://program.plexus/'
    u += "?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)+"&iconimage="+urllib.quote_plus(iconimage)
    contextmen = []
    liz=xbmcgui.ListItem(name,iconImage="DefaultFolder.png", thumbnailImage=iconimage)
    liz.setInfo( type="Video", infoLabels={ "Title": name} )
    liz.setProperty('fanart_image', fan_art)
    if mode == 1 or mode == 2:
        fic = hashlib.md5(name + '|' + url).hexdigest() + '.txt'
        if os.path.exists(os.path.join(mystrm_folder,fic)):
            contextmen.append((translate(30025), 'XBMC.RunPlugin(%s?mode=13&url=%s&name=%s&iconimage=%s)' % (sysargv, urllib.quote_plus(url),name,iconimage)))
        else:
            contextmen.append((translate(30026), 'XBMC.RunPlugin(%s?mode=12&url=%s&name=%s&iconimage=%s)' % (sysargv,urllib.quote_plus(url),name,iconimage)))
    liz.addContextMenuItems(contextmen,replaceItems=False)
    return xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=pasta,totalItems=total) 
Example #12
Source File: kodi.py    From script.module.urlresolver with GNU General Public License v2.0 6 votes vote down vote up
def add_item(queries, list_item, fanart='', is_folder=None, is_playable=None, total_items=0, menu_items=None, replace_menu=False):
    if menu_items is None:
        menu_items = []
    if is_folder is None:
        is_folder = False if is_playable else True

    if is_playable is None:
        playable = 'false' if is_folder else 'true'
    else:
        playable = 'true' if is_playable else 'false'

    liz_url = get_plugin_url(queries)
    if fanart:
        list_item.setProperty('fanart_image', fanart)
    list_item.setInfo('video', {'title': list_item.getLabel()})
    list_item.setProperty('isPlayable', playable)
    list_item.addContextMenuItems(menu_items, replaceItems=replace_menu)
    xbmcplugin.addDirectoryItem(int(sys.argv[1]), liz_url, list_item, isFolder=is_folder, totalItems=total_items) 
Example #13
Source File: addon.py    From repository.evgen_dev.xbmc-addons with GNU General Public License v2.0 6 votes vote down vote up
def addDirLink(title, url, mode, page=0, icon="DefaultFolder.png", inbookmarks=False):
    sys_url = sys.argv[0] + '?title=' + urllib.quote_plus(title) + '&url=' + urllib.quote_plus(url) + \
              '&mode=' + urllib.quote_plus(str(mode)) + '&page=' + urllib.quote_plus(str(page))
    id = url.split('/')

    item = xbmcgui.ListItem(title, iconImage=icon, thumbnailImage='')
    item.setIconImage(siteUrl+'/posters/'+id[1]+'.jpg')


    contextMenuItems = []
    if inbookmarks:
        contextMenuItems.append(('Удалить из закладок', 'XBMC.RunScript(%s,%i,%s)' %
                            (context_path, 1, 'mode=remove_bookmark&url='+id[1])))
    else:
        contextMenuItems.append(('Добавить в закладки', 'XBMC.RunScript(%s,%i,%s)' %
                            (context_path, 1, 'mode=add_bookmark&url='+id[1])))

    item.addContextMenuItems(contextMenuItems, replaceItems=True)
    xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=sys_url, listitem=item, isFolder=False) 
Example #14
Source File: main.py    From kodi.kino.pub with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def collections():
    img = plugin.routing.build_icon_path("fresh")
    li = plugin.list_item("Последние", iconImage=img, thumbnailImage=img)
    url = plugin.routing.build_url("collections", "created")
    xbmcplugin.addDirectoryItem(plugin.handle, url, li, True)

    img = plugin.routing.build_icon_path("hot")
    li = plugin.list_item("Просматриваемые", iconImage=img, thumbnailImage=img)
    url = plugin.routing.build_url("collections", "watchers")
    xbmcplugin.addDirectoryItem(plugin.handle, url, li, True)

    img = plugin.routing.build_icon_path("popular")
    li = plugin.list_item("Популярные", iconImage=img, thumbnailImage=img)
    url = plugin.routing.build_url("collections", "views")
    xbmcplugin.addDirectoryItem(plugin.handle, url, li, True)

    xbmcplugin.endOfDirectory(plugin.handle) 
Example #15
Source File: main.py    From kodi.kino.pub with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def watching():
    response = plugin.client("watching/serials").get(data={"subscribed": 1})
    xbmcplugin.setContent(plugin.handle, "tvshows")
    for item in response["items"]:
        title = u"{} : [COLOR FFFFF000]+{}[/COLOR]".format(item["title"], item["new"])
        li = plugin.list_item(
            title,
            str(item["new"]),
            poster=item["posters"]["big"],
            properties={"id": str(item["id"]), "in_watchlist": "1"},
            video_info={"mediatype": content_type_map[item["type"].lower()]},
            addContextMenuItems=True,
        )
        url = plugin.routing.build_url("seasons", item["id"])
        xbmcplugin.addDirectoryItem(plugin.handle, url, li, True)
    xbmcplugin.endOfDirectory(plugin.handle, cacheToDisc=False) 
Example #16
Source File: default.py    From tdw with GNU General Public License v3.0 6 votes vote down vote up
def play_url(params):
	torr_link=params['file']
	img=urllib.unquote_plus(params["img"])
	#showMessage('heading', torr_link, 10000)
	TSplayer=tsengine()
	out=TSplayer.load_torrent(torr_link,'TORRENT',port=aceport)
	if out=='Ok':
		for k,v in TSplayer.files.iteritems():
			li = xbmcgui.ListItem(urllib.unquote(k))
			uri = construct_request({
				'torr_url': torr_link,
				'title': k,
				'ind':v,
				'img':img,
				'mode': 'play_url2'
			})
			xbmcplugin.addDirectoryItem(handle, uri, li, False)
	xbmcplugin.addSortMethod(handle, xbmcplugin.SORT_METHOD_LABEL)
	xbmcplugin.endOfDirectory(handle)
	TSplayer.end() 
Example #17
Source File: default.py    From kodi with GNU General Public License v3.0 5 votes vote down vote up
def listGenres():
    genres = [
                 BASE_URL + '/otechestvennue/',
                 BASE_URL + '/detectiv/',
                 BASE_URL + '/romance/',
                 BASE_URL + '/action/',
                 BASE_URL + '/fantastika/',
                 BASE_URL + '/kriminal/',
                 BASE_URL + '/comedi/',
                 BASE_URL + '/teleshou/',
                 BASE_URL + '/multfilms/',
                 BASE_URL + '/adventure/',
                 BASE_URL + '/fantasy/',
                 BASE_URL + '/horror/',
                 BASE_URL + '/drama/',
                 BASE_URL + '/history/',
                 BASE_URL + '/triller/',
                 BASE_URL + '/mystery/',
                 BASE_URL + '/sport/',
                 BASE_URL + '/musical/',
                 BASE_URL + '/dokumentalnii/',
                 BASE_URL + '/war/'
    ]


    for i in range(0, len(genres)):
        uri = sys.argv[0] + '?&url=' + genres[i] + '/'
        item = xbmcgui.ListItem(localize(language(1000+i)))
        xbmcplugin.addDirectoryItem(pluginhandle, uri, item, True)

    xbmcplugin.setContent(pluginhandle, 'files')
    xbmcplugin.endOfDirectory(pluginhandle, True) 
Example #18
Source File: default.py    From kodi with GNU General Public License v3.0 5 votes vote down vote up
def parse(self, data, url = '', page = 0, filter = None):
        content = common.parseDOM(data, "div", attrs={"id": "dle-content"})
        pagenav = common.parseDOM(data, "div", attrs={"class": "bot-navigation"}) 
        
        boxes = common.parseDOM(content, "div", attrs={"class": "all_tv"})
        links = common.parseDOM(boxes, "a", ret='href')
        titles = common.parseDOM(boxes, "a", ret='title')
        if not titles:
            titles = common.parseDOM(content, "div", attrs={"class": "all_tv"}, ret='title')
        images = common.parseDOM(boxes, "img", ret='src')
        items = 0

        for i, title in enumerate(titles):
            if (not filter) or (title[:len(filter)].upper() == filter.upper()):
                items += 1

                if links[i] == "http://tivix.co/263-predlozheniya-pozhelaniya-zamechaniya-po-saytu.html":
                    continue

                image = self.url + images[i]

                uri = sys.argv[0] + '?mode=show&url=%s&name=%s&image=%s' % (links[i], title, image)
                item = xbmcgui.ListItem(title, iconImage=image, thumbnailImage=image)
                item.setInfo(type='Video', infoLabels={'title': title, 'plot': title})
                #item.setProperty('IsPlayable', 'true')
                xbmcplugin.addDirectoryItem(self.handle, uri, item, True)

        if pagenav and (not (items < 119)):
            uri = sys.argv[0] + '?mode=%s&url=%s&page=%s' % ("index", url, str(int(page) + 1))
            item = xbmcgui.ListItem('%s' % self.language(1003), iconImage=self.icon, thumbnailImage=self.icon)
            item.setInfo(type='Video', infoLabels={'title': 'ЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯЯ'})
            xbmcplugin.addDirectoryItem(self.handle, uri, item, True)

        xbmcplugin.addSortMethod(self.handle, xbmcplugin.SORT_METHOD_TITLE)
        xbmcplugin.setContent(self.handle, 'tvshows')
        xbmcplugin.endOfDirectory(self.handle, True) 
Example #19
Source File: plugintools.py    From tvalacarta with GNU General Public License v3.0 5 votes vote down vote up
def add_item( action="" , title="" , plot="" , url="" , thumbnail="" , fanart="" , show="" , episode="" , extra="", category="", page="", info_labels = None, context_menu_items = [] , isPlayable = False , folder=True ):
    _log("add_item action=["+action+"] title=["+title+"] url=["+url+"] thumbnail=["+thumbnail+"] fanart=["+fanart+"] show=["+show+"] episode=["+episode+"] extra=["+extra+"] category=["+category+"] page=["+page+"] isPlayable=["+str(isPlayable)+"] folder=["+str(folder)+"]")

    listitem = xbmcgui.ListItem( title, iconImage="DefaultVideo.png", thumbnailImage=thumbnail )
    if info_labels is None:
        info_labels = { "Title" : title, "FileName" : title, "Plot" : plot }
    listitem.setInfo( "video", info_labels )

    if len(context_menu_items)>0:
        listitem.addContextMenuItems ( context_menu_items, replaceItems=False)

    if fanart!="":
        listitem.setProperty('fanart_image',fanart)
        xbmcplugin.setPluginFanart(int(sys.argv[1]), fanart)
    
    if url.startswith("plugin://"):
        itemurl = url
        listitem.setProperty('IsPlayable', 'true')
        xbmcplugin.addDirectoryItem( handle=int(sys.argv[1]), url=itemurl, listitem=listitem, isFolder=folder)
    elif isPlayable:
        listitem.setProperty("Video", "true")
        listitem.setProperty('IsPlayable', 'true')
        itemurl = '%s?action=%s&title=%s&url=%s&thumbnail=%s&fanart=%s&plot=%s&extra=%s&category=%s&page=%s' % ( sys.argv[ 0 ] , action , urllib.quote_plus( title ) , urllib.quote_plus(url) , urllib.quote_plus( thumbnail ) , urllib.quote_plus( fanart ) , urllib.quote_plus( plot ) , urllib.quote_plus( extra ) , urllib.quote_plus( category ) , urllib.quote_plus( page ))
        xbmcplugin.addDirectoryItem( handle=int(sys.argv[1]), url=itemurl, listitem=listitem, isFolder=folder)
    else:
        itemurl = '%s?action=%s&title=%s&url=%s&thumbnail=%s&fanart=%s&plot=%s&extra=%s&category=%s&page=%s' % ( sys.argv[ 0 ] , action , urllib.quote_plus( title ) , urllib.quote_plus(url) , urllib.quote_plus( thumbnail ) , urllib.quote_plus( fanart ) , urllib.quote_plus( plot ) , urllib.quote_plus( extra ) , urllib.quote_plus( category ) , urllib.quote_plus( page ))
        xbmcplugin.addDirectoryItem( handle=int(sys.argv[1]), url=itemurl, listitem=listitem, isFolder=folder) 
Example #20
Source File: plugin_content.py    From plugin.audio.spotify with GNU General Public License v3.0 5 votes vote down vote up
def add_playlist_listitems(self, playlists):

        for item in playlists:

            if KODI_VERSION > 17:
                li = xbmcgui.ListItem(item["name"], path=item['url'], offscreen=True)
            else:
                li = xbmcgui.ListItem(item["name"], path=item['url'])
            li.setProperty('do_not_analyze', 'true')
            li.setProperty('IsPlayable', 'false')

            li.addContextMenuItems(item["contextitems"], True)
            li.setArt({"fanart": "special://home/addons/plugin.audio.spotify/fanart.jpg", "thumb": item['thumb']})
            xbmcplugin.addDirectoryItem(handle=self.addon_handle, url=item["url"], listitem=li, isFolder=True) 
Example #21
Source File: plugin_content.py    From plugin.audio.spotify with GNU General Public License v3.0 5 votes vote down vote up
def add_album_listitems(self, albums, append_artist_to_label=False):

        # process listing
        for item in albums:

            if append_artist_to_label:
                label = "%s - %s" % (item["artist"], item['name'])
            else:
                label = item['name']

            if KODI_VERSION > 17:
                li = xbmcgui.ListItem(label, path=item['url'], offscreen=True)
            else:
                li = xbmcgui.ListItem(label, path=item['url'])

            infolabels = {
                "title": item['name'],
                "genre": item["genre"],
                "year": item["year"],
                "album": item["name"],
                "artist": item["artist"],
                "rating": item["rating"]
            }
            li.setInfo(type="Music", infoLabels=infolabels)
            li.setArt({"thumb": item['thumb']})
            li.setProperty('do_not_analyze', 'true')
            li.setProperty('IsPlayable', 'false')
            li.addContextMenuItems(item["contextitems"], True)
            xbmcplugin.addDirectoryItem(handle=self.addon_handle, url=item["url"], listitem=li, isFolder=True) 
Example #22
Source File: plugin_content.py    From plugin.audio.spotify with GNU General Public License v3.0 5 votes vote down vote up
def browse_main_explore(self):
        # explore nodes
        xbmcplugin.setContent(self.addon_handle, "files")
        xbmcplugin.setProperty(self.addon_handle, 'FolderName', self.addon.getLocalizedString(11014))
        items = []
        items.append(
            (self.addon.getLocalizedString(11015),
             "plugin://plugin.audio.spotify/?action=browse_playlists&applyfilter=featured",
             "DefaultMusicPlaylists.png"))
        items.append(
            (self.addon.getLocalizedString(11016),
             "plugin://plugin.audio.spotify/?action=browse_newreleases",
             "DefaultMusicAlbums.png"))

        # add categories
        items += self.get_explore_categories()

        for item in items:
            li = xbmcgui.ListItem(
                item[0],
                path=item[1],
                iconImage=item[2]
            )
            li.setProperty('do_not_analyze', 'true')
            li.setProperty('IsPlayable', 'false')
            li.setArt({"fanart": "special://home/addons/plugin.audio.spotify/fanart.jpg"})
            li.addContextMenuItems([], True)
            xbmcplugin.addDirectoryItem(handle=self.addon_handle, url=item[1], listitem=li, isFolder=True)
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED)
        xbmcplugin.endOfDirectory(handle=self.addon_handle) 
Example #23
Source File: default.py    From kodi with GNU General Public License v3.0 5 votes vote down vote up
def menu(self):
        uri = sys.argv[0] + "?mode=search" 
        item = xbmcgui.ListItem("[COLOR=lightgreen]%s[/COLOR]" % self.language(1000), thumbnailImage=self.icon)
        xbmcplugin.addDirectoryItem(self.handle, uri, item, True)
    
        self.getMainItems()
    
        uri = sys.argv[0] + "?mode=alphabet" 
        item = xbmcgui.ListItem("[COLOR=orange]%s[/COLOR]" % self.language(1001), thumbnailImage=self.icon)
        xbmcplugin.addDirectoryItem(self.handle, uri, item, True)

        xbmcplugin.setContent(self.handle, 'files')
        xbmcplugin.endOfDirectory(self.handle, True) 
Example #24
Source File: plugin_content.py    From plugin.audio.spotify with GNU General Public License v3.0 5 votes vote down vote up
def browse_main(self):
        # main listing
        xbmcplugin.setContent(self.addon_handle, "files")
        items = []
        items.append(
            (self.addon.getLocalizedString(11013),
             "plugin://plugin.audio.spotify/?action=browse_main_library",
             "DefaultMusicCompilations.png", True))
        items.append(
            (self.addon.getLocalizedString(11014),
             "plugin://plugin.audio.spotify/?action=browse_main_explore",
             "DefaultMusicGenres.png", True))
        items.append(
            (xbmc.getLocalizedString(137),
             "plugin://plugin.audio.spotify/?action=search",
             "DefaultMusicSearch.png", True))
        items.append(
            ("%s: %s" % (self.addon.getLocalizedString(11039), self.playername),
             "plugin://plugin.audio.spotify/?action=browse_playback_devices",
             "DefaultMusicPlugins.png", True))
        cur_user_label = self.sp.me()["display_name"]
        if not cur_user_label:
            cur_user_label = self.sp.me()["id"]
        label = "%s: %s" % (self.addon.getLocalizedString(11047), cur_user_label)
        items.append(
            (label,
             "plugin://plugin.audio.spotify/?action=switch_user",
             "DefaultActor.png", False))
        for item in items:
            li = xbmcgui.ListItem(
                item[0],
                path=item[1],
                iconImage=item[2]
            )
            li.setProperty('IsPlayable', 'false')
            li.setArt({"fanart": "special://home/addons/plugin.audio.spotify/fanart.jpg"})
            li.addContextMenuItems([], True)
            xbmcplugin.addDirectoryItem(handle=self.addon_handle, url=item[1], listitem=li, isFolder=item[3])
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED)
        xbmcplugin.endOfDirectory(handle=self.addon_handle)
        self.refresh_connected_device() 
Example #25
Source File: default.py    From kodi with GNU General Public License v3.0 5 votes vote down vote up
def alphabet(self):
        response = common.fetchPage({"link": self.url})
        if response["status"] == 200:
            content = common.parseDOM(response["content"], "div", attrs={"class": "alphabet g-margin"})[0]
            items = common.parseDOM(content, "li")
            labels = common.parseDOM(items, "a")
            links = common.parseDOM(items, "a", ret="href")

            for i, item in enumerate(labels):
                uri = sys.argv[0] + "?mode=subitems2&url=%s" % (self.url + links[i])
                item_ = xbmcgui.ListItem(self.strip(item), iconImage=self.icon, thumbnailImage=self.icon)
                xbmcplugin.addDirectoryItem(self.handle, uri, item_, True)

        xbmcplugin.setContent(self.handle, 'files')
        xbmcplugin.endOfDirectory(self.handle, True) 
Example #26
Source File: main.py    From kodi.kino.pub with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def sorted_collections(sorting):
    data = {"sort": "-{}".format(sorting)}
    data.update(plugin.kwargs)
    response = plugin.client("collections/index").get(data=data)
    xbmcplugin.setContent(plugin.handle, "movies")
    for item in response["items"]:
        li = plugin.list_item(item["title"], thumbnailImage=item["posters"]["medium"])
        url = plugin.routing.build_url("collection", item["id"])
        xbmcplugin.addDirectoryItem(plugin.handle, url, li, True)
    show_pagination(response["pagination"]) 
Example #27
Source File: default.py    From tdw with GNU General Public License v3.0 5 votes vote down vote up
def stft(text):
	RL=tft.Search(text, 4)
	#if len(RL)>0:
	#	Title = "[COLOR F050F050]"+"[-------  Мультимедийный портал «KrasFS.ru»  ---------]"+"[/COLOR]"
	#	row_url = Title
	#	listitem = xbmcgui.ListItem(Title)
	#	listitem.setInfo(type = "Video", infoLabels = {"Title": Title} )
	#	purl = sys.argv[0] + '?mode=Search'\
	#		+ '&url=' + urllib.quote_plus(row_url)\
	#		+ '&title=' + urllib.quote_plus(Title)\
	#		+ '&text=' + urllib.quote_plus('0')
	#	xbmcplugin.addDirectoryItem(handle, purl, listitem, True)

	for itm in RL:
		n=0
		for i in ["PDF","pdf","FLAC","flac","FB2","fb2","MP3","mp3","PNG","png","ISO","iso","JPG","jpg","DJVU","djvu",".APE",".ape",".RTF",".rtf",".TXT",".txt",".DOC",".doc",".AC3",".ac3",".ZIP",".zip",".RAR",".rar",".EXE",".exe"]:
			filtr=itm[2].find(i)
			if filtr>0:n+=1
		if n==0:
				Title = itm[0]+"|"+itm[1]+"|  "+itm[2]
				row_url = itm[3]
				cover=""
				dict={}
				listitem = xbmcgui.ListItem(Title, thumbnailImage=cover, iconImage=cover)
				listitem.setProperty('fanart_image', cover)
				purl = sys.argv[0] + '?mode=play_url'\
					+ '&url=' + urllib.quote_plus(row_url)\
					+ '&title=' + urllib.quote_plus(Title)
				xbmcplugin.addDirectoryItem(handle, purl, listitem, True)


#---------tsengine----by-nuismons----- 
Example #28
Source File: default.py    From kodi with GNU General Public License v3.0 5 votes vote down vote up
def getSubItems1(self, url):
        response = common.fetchPage({"link": url})
        if response["status"] == 200:
            content = common.parseDOM(response["content"], "ul", attrs={"class": "h1__tabs"})[0]
            items = common.parseDOM(content, "li")
            for i, item in enumerate(items):
                label = common.parseDOM(item, "a")[0] if common.parseDOM(item, "a") else common.parseDOM(item, "span")[0]
                link = self.url + common.parseDOM(item, "a", ret="href")[0] if common.parseDOM(item, "a") else self.url + "/akkordi/popular/"
                uri = sys.argv[0] + "?mode=items&url=%s" % (link)
                item_ = xbmcgui.ListItem(self.strip(label), iconImage=self.icon, thumbnailImage=self.icon)
                xbmcplugin.addDirectoryItem(self.handle, uri, item_, True)
        xbmcplugin.setContent(self.handle, 'files')
        xbmcplugin.endOfDirectory(self.handle, True) 
Example #29
Source File: main.py    From kodi.kino.pub with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def episodes(item_id):
    item = plugin.client("items/{}".format(item_id)).get()["item"]
    watching_info = plugin.client("watching").get(data={"id": item_id})["item"]
    xbmcplugin.setContent(plugin.handle, "episodes")
    playback_data = {}
    for video in item["videos"]:
        watching_episode = watching_info["videos"][video["number"] - 1]
        episode_title = "e{:02d}".format(video["number"])
        if video["title"]:
            episode_title = u"{} | {}".format(episode_title, video["title"])
        info = extract_video_info(
            item,
            {
                "episode": video["number"],
                "tvshowtitle": video["title"],
                "time": watching_episode["time"],
                "duration": watching_episode["duration"],
                "playcount": video["watched"],
                "mediatype": "episode",
            },
        )
        li = plugin.list_item(
            episode_title,
            thumbnailImage=video["thumbnail"],
            video_info=info,
            poster=item["posters"]["big"],
            fanart=item["posters"]["wide"],
            properties={"id": item["id"], "isPlayable": "true"},
            addContextMenuItems=True,
        )
        url = plugin.routing.build_url("play", item["id"], video["number"])
        playback_data[video["number"]] = {
            "video_data": video,
            "video_info": info,
            "poster": item["posters"]["big"],
            "title": episode_title,
        }
        xbmcplugin.addDirectoryItem(plugin.handle, url, li, False)
    set_window_property(playback_data)
    xbmcplugin.endOfDirectory(plugin.handle, cacheToDisc=False) 
Example #30
Source File: plugintools.py    From tvalacarta with GNU General Public License v3.0 5 votes vote down vote up
def add_item( action="" , title="" , plot="" , url="" , thumbnail="" , fanart="" , show="" , episode="" , extra="", category="", page="", info_labels = None, context_menu_items = [] , isPlayable = False , folder=True ):
    _log("add_item action=["+action+"] title=["+title+"] url=["+url+"] thumbnail=["+thumbnail+"] fanart=["+fanart+"] show=["+show+"] episode=["+episode+"] extra=["+extra+"] category=["+category+"] page=["+page+"] isPlayable=["+str(isPlayable)+"] folder=["+str(folder)+"]")

    listitem = xbmcgui.ListItem( title, iconImage="DefaultVideo.png", thumbnailImage=thumbnail )
    if info_labels is None:
        info_labels = { "Title" : title, "FileName" : title, "Plot" : plot }
    listitem.setInfo( "video", info_labels )

    if len(context_menu_items)>0:
        listitem.addContextMenuItems ( context_menu_items, replaceItems=False)

    if fanart!="":
        listitem.setProperty('fanart_image',fanart)
        xbmcplugin.setPluginFanart(int(sys.argv[1]), fanart)
    
    if url.startswith("plugin://"):
        itemurl = url
        listitem.setProperty('IsPlayable', 'true')
        xbmcplugin.addDirectoryItem( handle=int(sys.argv[1]), url=itemurl, listitem=listitem, isFolder=folder)
    elif isPlayable:
        listitem.setProperty("Video", "true")
        listitem.setProperty('IsPlayable', 'true')
        itemurl = '%s?action=%s&title=%s&url=%s&thumbnail=%s&fanart=%s&plot=%s&extra=%s&category=%s&page=%s' % ( sys.argv[ 0 ] , action , urllib.quote_plus( title ) , urllib.quote_plus(url) , urllib.quote_plus( thumbnail ) , urllib.quote_plus( fanart ) , urllib.quote_plus( plot ) , urllib.quote_plus( extra ) , urllib.quote_plus( category ) , urllib.quote_plus( page ))
        xbmcplugin.addDirectoryItem( handle=int(sys.argv[1]), url=itemurl, listitem=listitem, isFolder=folder)
    else:
        itemurl = '%s?action=%s&title=%s&url=%s&thumbnail=%s&fanart=%s&plot=%s&extra=%s&category=%s&page=%s' % ( sys.argv[ 0 ] , action , urllib.quote_plus( title ) , urllib.quote_plus(url) , urllib.quote_plus( thumbnail ) , urllib.quote_plus( fanart ) , urllib.quote_plus( plot ) , urllib.quote_plus( extra ) , urllib.quote_plus( category ) , urllib.quote_plus( page ))
        xbmcplugin.addDirectoryItem( handle=int(sys.argv[1]), url=itemurl, listitem=listitem, isFolder=folder)