Guest - Testers are needed for the reworked CDateTime core component. See... https://forum.kodi.tv/showthread.php?tid=378981 (September 29) x
Can't really add/view label2 in listitem [Add-on development]
#1
I created a simple addon to test how to use label2, i want result like this image :

Image

Or something like youtube addon(left is title,and colored likes and views,on the right duration | date):

Image



But real result is this :

Image


And this is my python code :

python:
import sys
import xbmcgui
import xbmcplugin

_url = sys.argv[0]
_handle = int(sys.argv[1])

def get_videos():
    videos_data = [
        ('njn Ford Coppola Teaser Trailer', '01:31', '14/05/2024', '1K likes', '15K views'),
        ('Francis Ford Coppola Teaser Trailer', '02:16', '04/05/2024', '1K likes', '15K views'),
        ('lll Ford Coppola Teaser Trailer', '28:15', '22/02/2022', '1K likes', '15K views'),
    ]
    return videos_data


def list_videos():
    for title, duration, date, likes, views in get_videos():
        list_item = xbmcgui.ListItem(label=title)
        list_item.setLabel2(' | '.join([duration, date]))
        list_item.setInfo('video', {'title': title, 'duration': duration})
        list_item.setProperty('fanart_image', 'fanart.jpg')
        list_item.setProperty('icon', 'icon.png')
        xbmcplugin.addDirectoryItem(_handle, _url, list_item, isFolder=False)
    xbmcplugin.endOfDirectory(_handle)



list_videos()

addon.xml, if needed :
Code:
<?xml version="1.0" encoding="UTF-8"?>
<addon id="plugin.video.myaddon_w" name="My Movie Addon" version="1.0.0" provider-name="Your Name">
    <requires>
        <import addon="xbmc.python" version="3.0.0"/>
    </requires>
    <extension point="xbmc.addon.metadata">
        <summary>My Video Addon</summary>
        <description>This addon fetches videos with titles, views, likes, date and duration</description>
        <fanart>fanart.jpg</fanart>
        <icon>icon.png</icon>
    </extension>
    <extension point="xbmc.python.pluginsource" library="addon.py">
        <description>My Movie Addon</description>
        <provides>video</provides>
    </extension>
    
</addon>

What's wrong with my code?
Reply
#2
Thread moved to addon development
|Banned add-ons (wiki)|Forum rules (wiki)|VPN policy (wiki)|First time user (wiki)|FAQs (wiki) Troubleshooting (wiki)|Add-ons (wiki)|Free content (wiki)|Debug Log (wiki)|

Kodi Blog Posts
Reply
#3
(2024-06-06, 20:18)FrankWierd Wrote: What's wrong with my code?

Have you looked at the view mode ?  That determines what is displayed by the skin, along with the sort sequence.   Your result looks like a list view.  Depending upon the skin, content type and such you may new to set the view mode.  If you want to go that route I can should you some code for setting the view mode but typically it is easier just to set from the let panel manually and have Kodi remember it.


Thanks,

Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#4
Label2 display is heavily depended on the skin you are using and the content type you set your plugin for. I don't recall offhand which content type will show label2 but one of them should. (Try 'Files')?
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#5
(2024-06-06, 20:18)FrankWierd Wrote: Or something like youtube addon(left is title,and colored likes and views,on the right duration | date):

As others have noted, the use of Label2 will vary depending on a number of factors including the skin being used, the selected view.

The YouTube plugin does not use Label2 to achieve this type of display, it uses label masks as part of applying sort methods to the listings.

https://github.com/anxdpanic/plugin.vide...xt.py#L483

https://xbmc.github.io/docs.kodi.tv/mast...b136025f40
Reply

Logout Mark Read Team Forum Stats Members Help
Can't really add/view label2 in listitem [Add-on development]0