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
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
<?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)
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.