Need help to build my first addons categories menu
#1
I use this project template to create my first kodi addon: https://github.com/jrmdev/plugin.video.template

I think it's a good base to start but I'm noobs and need help to understand the code in kodi-python I wish to learn but don't know were to start ??

To my first project of kodi addon I want to add a main menu with some categories 

With this template I need to change the file comm.py to load the categories, the code inside the file is partially explained but I don't understand what to do to create my own "test" categories:

   
I suppose I need to use this part of the code to do what I need:
    # Implement second level here, ex:
    # data = json.loads(fetch_url(config.VIDEOS_URL.format(params['category']))).

     and uncomment this one in the file config.py
   #VIDEOS_URL = "http://example.com/videos/{0}"
   #CATEGORIES_URL = "http://example.com/categories"

In this template there is only one list of videos playable defined here:

    for video in config.PUBLIC_TEST_VIDEOS[start:end]:

        menu_item = MenuItem(playable=True)
        menu_item.title = video['title']
        menu_item.url = video['source']
        menu_item.description = video['description']
        menu_item.genre = video['genre']
        menu_item.actor = video['actor']
        menu_item.thumb = video['thumb']
        menu_item.icon = video['thumb']

        listing.append(menu_item)

I probably need to change that >  for video in config.PUBLIC_TEST_VIDEOS[start:end]: by > for video in config.VIDEOS_URL[start:end]:
but I'm really not sure of what to do next?

From scratch the template show a list of 9 random categories each of them load the json list > PUBLIC_TEST_VIDEOS = [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"source" : "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4",
"subtitle" : "By Blender Foundation",
"thumb" : "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
 },

def get_categories():
# Implement first level here, ex:
# data = json.loads(fetch_url(config.CATEGORIES_URL))
listing = []
for category in range(1, 9):
menu_item = MenuItem()
menu_item.title = 'Random videos %d' % category
menu_item.description = 'Description for %s' % menu_item.title
menu_item.icon = 'https://picsum.photos/300/200?r=%d' % random.randint(0, 10000)
menu_item.thumb = menu_item.icon
listing.append(menu_item)

I need to see an example of how to link 2 different categories named "test1 & test2" with 2 different list of videos like "PUBLIC_TEST_VIDEOS" with that I will learn more easily, please if someone can help ?
Reply
#2
i would suggest to have a look at this video addon tutorial:
https://kodi.wiki/view/HOW-TO:Video_addon
which, imo, is easier to understand for new python coders.
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#3
thanks you but this tutorial don't help about my specific project and this "plugin" don't work with kodi 18
Reply
#4
(2022-07-30, 08:32)Actarus81 Wrote: thanks you but this tutorial don't help about my specific project and this "plugin" don't work with kodi 18

You need to pull down the Python2 branch of the addon,.  The master branch is Python 3 which is for Kodi 19.  The Python 2 branch should work with Kodi 18.

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
#5
Okay thank you I will try it
Reply
#6
How to build a first menu structure like that ?

categories = [
  {
    'name': 'LiveTV_URL',
    'id': 'LiveTV_URL',
    'icon': 'icon.png',
    'thumb': 'http://www.vidsplay.com/wp-content/uploads/2017/04/crab-screenshot.jpg',
    'plot': 'Description LiveTV',
  }, {
    'name': 'PUBLIC_TEST_VIDEOS',
    'id': 'PUBLIC_TEST_VIDEOS',
    'icon': 'movies.png',
    'thumb': 'http://www.vidsplay.com/wp-content/uploads/2017/05/pizza-screenshot.jpg',
    'plot': 'Description Movies',
  }, {
    'name': 'TEST_VIDEOS',
    'id': 'TEST_VIDEOS',
    'icon': 'movies.png',
    'thumb': 'http://www.vidsplay.com/wp-content/uploads/2017/05/pizza-screenshot.jpg',
    'plot': 'Description Movies',
  },
]

I tried to change the original random script

def get_categories():
    # Implement first level here, ex:

    listing = []

     for category in range(1, 9):

        menu_item = MenuItem()
        menu_item.title = 'video %d' % category['name']
        menu_item.description = 'Descripti0n for %s' % menu_item.title
        menu_item.icon = 'https://picsum.photos/300/200?r=%d' % random.randint(0, 10000)
        menu_item.thumb = menu_item.icon

        listing.append(menu_item)

return listing

I tried to modify like this but it won't boot and kodi give me an error what I'am doing wrong ?


def get_categories():

    listing = []

     for category in categories:

        menu_item = MenuItem()
        menu_item.title = 'video %d' % category['name']
        menu_item.description = 'Descripti0n for %s' % menu_item.title
        menu_item.icon = category['thumb']
        menu_item.thumb = menu_item.icon

        listing.append(menu_item)

return listing
Reply
#7
I'd also recommend not to use that overengineered example from your 1-st post and use the Wiki article as your starting point. I doubt that there are many people here who are familiar with that specific wrapper library you are trying to use.
Reply
#8
ok thank you I will try something less difficult
Reply

Logout Mark Read Team Forum Stats Members Help
Need help to build my first addons categories menu0