2022-07-29, 20:23
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 ?
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 ?