v16 Youtube videos play via my addon on Kodi 17, not playable in Kodi 16
#1
Hello everyone,

I have attempted to create a simple video addon, which will contain a few links to video links from Youtube, DailyMotion, and Google Drive. I have no issues with the Google Drive and Dailymotion files, when I click on the link it will play the video correctly. But when I click on any of the Youtube links, nothing seems to happen. When I right click on the file there is only Addon Settings and Addon information displayed in the context menu, nothing like "Play from here" is mentioned.

What I don't understand is if I run the same addon via Kodi 17 RC, if I right click on the link, there is a "Play" option shown, and the Youtube videos load without any issues.

My code is below:


addon.py
Code:
import sys
import xbmcgui
import xbmcplugin
import xbmc
import os
import urlresolver
import urllib
import urlparse
import re

player = xbmc.Player()
icon1 = 'http://sportschedule.xyz/css/tv.png'
icon2 = 'http://sportschedule.xyz/css/tv2.png'



addon_handle = int(sys.argv[1])


def addDir(dir_type, mode, url, name, iconimage, fanart):
   base_url =  sys.argv[0]
   base_url += "?url="      +urllib.quote_plus(url)
   base_url += "&mode="     +str(mode)
   base_url += "&name="     +urllib.quote_plus(name)
   base_url += "&iconimage" +urllib.quote_plus(iconimage)
   base_url += "&fanart"    +urllib.quote_plus(fanart)


   li = xbmcgui.ListItem(name, iconImage=iconimage)
    
   li.setInfo( type="Video", infoLabels={"Title": name} )
   li.setProperty( "Fanart_Image", fanart )
  
   if dir_type != '':
       link = xbmcplugin.addDirectoryItem(handle=addon_handle,url=base_url,listitem=li,isFolder=True)

   else:
       link = xbmcplugin.addDirectoryItem(handle=addon_handle,url=url,listitem=li,isFolder=False)

   return link
    
def pm():
   video1 = media_url = urlresolver.resolve('https://drive.google.com/file/d/0B2L3RxWjsgN3X1RWQjhia0dsWFU/view?usp=drivesdk')
   addDir('', '', video1, 'S01E01', icon1, icon2)
   video2 = 'http://sportschedule.xyz/test.mkv'
   addDir('', '', video2, 'S01E02', icon1, icon2)  
  
def dm():
   video6 = media_url = urlresolver.resolve('http://www.dailymotion.com/video/x2uhtzd_it-s-peanut-butter-jelly-time-10-minutes-family-guy-brian-griffin_shortfilms')
   addDir('', '', video6, 'Peanut Butter Jelly Time', icon1, icon2)  

  
def yt():
   video7 = media_url = urlresolver.resolve('https://www.youtube.com/watch?v=7OXVPgu6urw')
   addDir('', '', video7, 'Surfin Bird', icon1, icon2)  

def his_Stuff():
   video3 = 'http://sportschedule.xyz/test.mkv'
   addDir('', '', video3, 'Mini Short', icon1, icon2)
   video4 = media_url = urlresolver.resolve('https://drive.google.com/file/d/0B2L3RxWjsgN3X1RWQjhia0dsWFU/view?usp=drivesdk')
   addDir('', '', video4, 'DM', icon1, icon2)


def my_Stuff():
   addDir('folder', 'pm', '', 'PM', icon1, icon2)
  
def her_Stuff():
   addDir('folder', 'yt', '', 'Youtube Links', icon1, icon2)
   addDir('folder', 'dm', '', 'Dailymotion Links', icon1, icon2)

def Main_Menu():
   addDir('folder', 'my_stuff', '', 'my Stuff', icon1, icon2)
   addDir('folder', 'his_stuff', '', 'his Stuff', icon1, icon2)
   addDir('folder', 'her_stuff', '', 'her Stuff', icon1, icon2)

mode = None

args = sys.argv[2]

if len(args) > 0:
    mode = args.split('mode=')
    mode = mode[1].split('&')
    mode = mode[0]

if mode == None : Main_Menu()
elif mode == 'my_stuff' : my_Stuff()
elif mode == 'his_stuff' : his_Stuff()
elif mode == 'her_stuff' : her_Stuff()
elif mode == 'dm' : dm()
elif mode == 'pm' : pm()
elif mode == 'yt' : yt()

xbmcplugin.endOfDirectory(addon_handle)

addon.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>

-<addon provider-name="Brendan R" name="Nadnerbsregdor" version="2.1.0" id="plugin.video.nadnerbsregdor">


-<requires>

<import version="2.24.0" addon="xbmc.python"/>

<import version="3.0.26" addon="script.module.urlresolver"/>

<import version="5.3.6" addon="plugin.video.youtube"/>

</requires>


-<extension library="addon.py" point="xbmc.python.pluginsource">

<provides>video</provides>

</extension>


-<network>

<cachemembuffersize>20971520</cachemembuffersize>

</network>


-<extension point="xbmc.addon.metadata">

<summary lang="en">Brendan - Example Video Folders</summary>

<description lang="en">Testing</description>

<disclaimer lang="en">None.</disclaimer>


-<assets>

<icon>icon.png</icon>

</assets>
<news>None</news>

</extension>

</addon>

Kodi 16 Log: (seems to mention about "attempt to use invalid handle -1", just after I select the video quality)

Kodi 16 Log


What is strange to me is why it would play with no issues in Kodi 17, but in Kodi 16 it won't work but every other link works correctly (GVideo and Dailymotion), could it be that I have structured the Youtube link incorrectly?

Many Thanks to anyone who can provide a possible solution or insight into this issue.
Reply
#2
I think no problem in code. Problem in settings (configuration) of urlresolver or youtube.
Reply
#3
(2017-01-10, 19:22)Taifxx Wrote: I think no problem in code. Problem in settings (configuration) of urlresolver or youtube.

Hi Taifxx, thanks for the suggestion. Everything seems ok in urlresolver and YouTube addons. UrlResolver also has no problems playing other links except YouTube and YouTube videos will load through other addons without issue.

One thing I was looking at that may need to be added to my code is setResolvedUrl to get the resolved URL from urlresolver to be able to play it. Do you think this might be a solution to this problem?

Many thanks for your suggestions and assistance.
Reply
#4
setResolvedURL it is a method for playing video by link. When you call it you start playing video.
Example from Kodi wiki:
Code:
def play_video(path):
    # Create a playable item with a path to play.
    play_item = xbmcgui.ListItem(path=path)
    # Pass the item to the Kodi player.
    xbmcplugin.setResolvedUrl(__handle__, True, listitem=play_item)

Full example: HOW-TO:Video_addon (wiki)

How urlresolver addon works (quote):
The URLResolver Kodi add-on works in the background of Kodi (called a dependency) to decode file hosts in order to play the root movie or TV video stream. If you are new to Kodi, you probably notice that a lot of add-ons use the same filehosts – Gvideo, clicknupload, zshare, dizilab are some of the popular ones. The URLResolver Kodi add-on knows how to navigate through these hosts, clicking through captcha’s and virtually retrieving the streaming file which you see in Kodi.

That's why i think you need search problem inside it or youTube addon.
Reply

Logout Mark Read Team Forum Stats Members Help
Youtube videos play via my addon on Kodi 17, not playable in Kodi 160