2014-12-18, 01:08
Hi everyone,
I am try to load api with playlist from youtube in xbmc using a script.
I can play each video fine but my problem is that I want the next video to play automatically.
I have this on xbmc screen
video 1
video 2
video 3
video 4
If I play video 2 I want it to play video 2+1 next
Please ignore my childish coding.
how to I pass the index of next to xbmc.player
I am try to load api with playlist from youtube in xbmc using a script.
I can play each video fine but my problem is that I want the next video to play automatically.
I have this on xbmc screen
video 1
video 2
video 3
video 4
If I play video 2 I want it to play video 2+1 next
Please ignore my childish coding.
Code:
#YouTube
def listYouTubeVideos(url):
xbmcplugin.setContent(pluginhandle, "episodes")
content = getUrl(url)
match=re.compile("<openSearch:totalResults>(.+?)</openSearch:totalResults>", re.DOTALL).findall(content)
maxIndex=int(match[0])
match=re.compile("<openSearch:startIndex>(.+?)</openSearch:startIndex>", re.DOTALL).findall(content)
startIndex=int(match[0])
spl=content.split('<entry')
count = 1
for i in range(1,len(spl),1):
entry=spl[i]
match=re.compile('v=(.+?)&', re.DOTALL).findall(entry)
id=match[0]
match=re.compile("<media:title type='plain'>(.+?)</media:title>", re.DOTALL).findall(entry)
title=match[0]
title=cleanTitle(title)
thumb="http://i1.ytimg.com/vi/"+id+"/hqdefault.jpg"
addLink(title,id,'playYouTube',thumb.replace("\\", ""))
count += 1
if startIndex+int(itemsPerPage)<=maxIndex:
nextIndex=startIndex+int(itemsPerPage)
addDir("next",url.replace("start-index="+str(startIndex), "start-index="+str(int(nextIndex))),'listYouTubeVideos',"")
xbmcplugin.endOfDirectory(pluginhandle)
def playYouTube(youtubeID):
url = getYoutubeUrl(youtubeID)
listitem = xbmcgui.ListItem(path=url)
return xbmcplugin.setResolvedUrl(pluginhandle, True, listitem)
def getYoutubeUrl(youtubeID):
url = "plugin://plugin.video.youtube/?path=/root/video&action=play_video&videoid=" + youtubeID
return url