Windows - Creating your first Youtube Add-on

  Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
misty01 Offline
Senior Member
Posts: 121
Joined: May 2014
Reputation: 22
Post: #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!
find quote
docwra Offline
Fan
Posts: 528
Joined: Nov 2014
Reputation: 20
Post: #47
Thanks, works great!

Agreed on minimizing it down, but one for the future I think.

[Image: cook.png] Formally chef Zag
(This post was last modified: 2016-11-29 11:30 by docwra.)
find quote
Laser78 Offline
Member
Posts: 78
Joined: May 2009
Reputation: 4
Post: #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: bbb.png]
(This post was last modified: 2017-04-04 08:47 by Laser78.)
find quote
Laser78 Offline
Member
Posts: 78
Joined: May 2009
Reputation: 4
Post: #49
And Youtube live ?

[Image: bbb.png]
find quote
johnboy1973 Offline
Junior Member
Posts: 6
Joined: Jun 2017
Reputation: 0
Post: #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 ?
find quote
docwra Offline
Fan
Posts: 528
Joined: Nov 2014
Reputation: 20
Post: #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: cook.png] Formally chef Zag
(This post was last modified: 2017-09-05 12:00 by docwra.)
find quote
Post Reply