Thread Rating:
  • 1 Vote(s) - 5 Average
Windows - Creating your first Youtube Add-on
#46
The section of code you are concerned with:

Code:
def run():
    plugintools.log("fullycharged.run")
    
    # Get params
    params = plugintools.get_params()
    
    if params.get("action") is None:
        main_list(params)
    else:
        action = params.get("action")
        exec action+"(params)"   <<<---- this line of code with exec
    
plugintools.close_item_list()

We don't need that code at all. Big Grin

Use this instead:

Code:
def run():
    plugintools.log("fullycharged.run")
    
    # Get params
    params = plugintools.get_params()
    
    if params.get("action") is None:
        main_list(params)
    else:
        pass
    
plugintools.close_item_list()

Your youtube add-on will run fine.

Hope that helps.

As far as Addon.id, not sure as I didn't write the plugintools.py. I think with some code examination, what we want to use for creating simple youtube add-ons, the small portion of pertinent code from plugintools.py could probably be extracted and added directly into the main default.py. I haven't dug into the code to see what small portions are used, but it should not be too hard to figure out.
Get Best of NHK, DigitalRev TV and XiveTv add-ons via my repository. Enjoy!
Reply
#47
Thanks, works great!

Agreed on minimizing it down, but one for the future I think.
Image Formally chef Zag
Reply
#48
Hi,

I can not get the SEARCH option and PLAYLIST option working.

Code:
plugintools.add_item(
    #action="",
    title="Youtube Search for 'NHK World'",
    url='plugin://plugin.video.youtube/search/?q=NHK World',
    thumbnail=icon,
    folder=True )

Or

Code:
plugintools.add_item(
    #action="",
    title="UNESCO/NHK",
    url="plugin://plugin.video.youtube/playlist/PLWuYED1WVJIPKU_tUlzLTfkbNnAtkDOhS/",
    thumbnail=icon,
    folder=True )

It does not work for me, I have created multiple channels but when I add these I get error


Any Ideas please ?
Image
Reply
#49
And Youtube live ?
Image
Reply
#50
hey folks im new at this and would like to learn how to do a multi ytoutube channel addon dont understsand this much is there a youtube vid ?
Reply
#51
(2017-06-26, 02:09)johnboy1973 Wrote: hey folks im new at this and would like to learn how to do a multi ytoutube channel addon dont understsand this much is there a youtube vid ?

My code for multiple Youtube channel Add-on: editing default.py

Code:
# -*- coding: utf-8 -*-
#------------------------------------------------------------
#------------------------------------------------------------
# License: GPL (http://www.gnu.org/licenses/gpl-3.0.html)
# Based on code from youtube addon
#------------------------------------------------------------

import os
import sys
import plugintools
import xbmc,xbmcaddon
from addon.common.addon import Addon

addonID = 'plugin.video.vanlife'
addon = Addon(addonID, sys.argv)
local = xbmcaddon.Addon(id=addonID)
icon = local.getAddonInfo('icon')

YOUTUBE_CHANNEL_ID1 = "UCHV7BvFPyD5Lixoo8yMRiLA"
YOUTUBE_CHANNEL_ID2 = "UCSCRVmBT1YyuAlCA8c9FJRA"

# Entry point
def run():
# Get params
    params = plugintools.get_params()

    if params.get("action") is None:
        main_list(params)
    else:
        action = params.get("action")
        exec action+"(params)"

    plugintools.close_item_list()

# Main menu
def main_list(params):
    plugintools.log("vanlife.main_list "+repr(params))

plugintools.add_item(
    #action="",
    title="Kombi Life",
    url="plugin://plugin.video.youtube/channel/"+YOUTUBE_CHANNEL_ID1+"/",
    thumbnail=icon,
    folder=True )

plugintools.add_item(
    #action="",
    title="Nomadic Life",
    url="plugin://plugin.video.youtube/channel/"+YOUTUBE_CHANNEL_ID2+"/",
    thumbnail=icon,
    folder=True )

run()
Image Formally chef Zag
Reply
#52
Great and great this will bring the fun
Reply
#53
cool thanks perfect
Reply



Creating your first Youtube Add-on51