Continous Loop - mikey1234 - 2012-07-06
problem i have is that when video is playing if i select back or stop it rescrapes and plays
keeps doing that like a continuous loop....
Code: import urllib,urllib2,re,xbmcplugin,xbmcgui,xbmcaddon
url= "???"'
thumbnail= 'icon.png'
def CATEGORIES():
addDir('Search Mikeys Karaoke','url',1,'icon.png')
def INDEX(url):
search_entered = ''
keyboard = xbmc.Keyboard(search_entered, 'Search Mikeys Karaoke')
keyboard.doModal()
if keyboard.isConfirmed():
search_entered = keyboard.getText() .replace(' ','+') # sometimes you need to replace spaces with + or %20#
if search_entered == None:
return False
url = ???/%s/' % (search_entered)
req = urllib2.Request(url)
req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
response = urllib2.urlopen(req)
link=response.read()
response.close()
match=re.compile('\t<a href="(.+?)">(.+?)</a>').findall(link)
for url,name in match:
addDir(name,url,2,'icon.png')
def VIDEOLINKS(url):
req = urllib2.Request(url)
req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
response = urllib2.urlopen(req)
link=response.read()
response.close()
match=re.search(r'<embed src="http://www.youtube.com/v/(.+?)&hl', link)
youtube_id = match.group(1)
xbmc_url = 'plugin://plugin.video.youtube/?path=/root/search/new&action=play_video&videoid=%s' % youtube_id
xbmc.executebuiltin('XBMC.PlayMedia(%s)' % xbmc_url)
def get_params():
param=[]
paramstring=sys.argv[2]
if len(paramstring)>=2:
params=sys.argv[2]
cleanedparams=params.replace('?','')
if (params[len(params)-1]=='/'):
params=params[0:len(params)-2]
pairsofparams=cleanedparams.split('&')
param={}
for i in range(len(pairsofparams)):
splitparams={}
splitparams=pairsofparams[i].split('=')
if (len(splitparams))==2:
param[splitparams[0]]=splitparams[1]
return param
def addDir(name,url,mode,iconimage):
u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)
ok=True
liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=iconimage)
liz.setInfo( type="Video", infoLabels={ "Title": name } )
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True)
return ok
params=get_params()
url=None
name=None
mode=None
try:
url=urllib.unquote_plus(params["url"])
except:
pass
try:
name=urllib.unquote_plus(params["name"])
except:
pass
try:
mode=int(params["mode"])
except:
pass
print "Mode: "+str(mode)
print "URL: "+str(url)
print "Name: "+str(name)
if mode==None or url==None or len(url)<1:
print ""
CATEGORIES()
elif mode==1:
print ""+url
INDEX(url)
elif mode==2:
print ""+url
VIDEOLINKS(url)
xbmcplugin.endOfDirectory(int(sys.argv[1]))
RE: Continous Loop - mikey1234 - 2012-07-12
can someone please help me
Code: def PLAY_KARAOKE(url):
xbmc_url = 'plugin://plugin.video.youtube/?path=/root/search/new&action=play_video&videoid=%s' % url
xbmc.executebuiltin('XBMC.PlayMedia(%s)' % xbmc_url)
still loops i can sort of get round it if i spit out a forced script error with mode is none
Code: def PLAY_KARAOKE(url):
xbmc_url = 'plugin://plugin.video.youtube/?path=/root/search/new&action=play_video&videoid=%s' % url
xbmc.executebuiltin('XBMC.PlayMedia(%s)' % xbmc_url)
addDir('Mikeys Karaoke',url,none,iconimage)
even if isfolder=false it still loops
RE: Continous Loop - spiff - 2012-07-12
see http://forum.xbmc.org/showthread.php?tid=118083
RE: Continous Loop - mikey1234 - 2012-07-12
thank you i thought i cracked it but its still looping
aaaaaaahhhhhhhhhhhhhhh!!!!!!!!!!!!!!!!!
Code: def PLAY_KARAOKE(url):
xbmc_url = 'plugin://plugin.video.youtube/?path=root/video&action=play_video&videoid=%s' % url
xbmc.executebuiltin('XBMC.PlayMedia(%s)' % xbmc_url)
addDir('Search Mikeys Karaoke','url',3,'http://live-tv-stream.googlecode.com/svn/Karaoke%20Icons/Main/Search.png')
addDir('Browse Artist','http://www.sunflykaraoke.com/',1,'http://live-tv-stream.googlecode.com/svn/Karaoke%20Icons/Main/Artist.png')
addDir('Browse Tracks','http://www.sunflykaraoke.com/',2,'http://live-tv-stream.googlecode.com/svn/Karaoke%20Icons/Main/Title.png')
addDir('Genre','http://www.sunflykaraoke.com/',9,'http://live-tv-stream.googlecode.com/svn/Karaoke%20Icons/Main/Genre.png')
xbmc.executebuiltin("Container.SetViewMode(500)")
RE: Continous Loop - spiff - 2012-07-12
you *NEVER* execute playmedia.
either you return a playable url ala http.
OR
you return a playable plugin:// url and mark it as playable. we then do a callback to the plugin to play it, and you return the real url through setResolvedUrl.
READ the link.
RE: Continous Loop - mikey1234 - 2012-07-12
im completely lost here??
RE: Continous Loop - hippojay - 2012-07-12
I think you need to start again, as that plugin extract makes no sense to me - i don;t even see mode being set anywhere on a url, yet you are using it to call your VIDEOLINKS function.
I would suggest that you dig out someone else plugins (a simple one) and have a look at the code. Then add some print commands into it and understand how it flows.
As for the question about "playmedia" - you don't need to specifically call a play function to get XBMC to play your media. If you set the IsPlayable flag and IsFolder False on the listItem, then XBMC will attempt to play the URL passed into that listItem.
If that listItem doesn't actually point to a specific piece of media, then you can use that URL to point back to the plugin (i.e. plugin://plugins.somestuff), perform some extra process and then send the actual media URL inot setResolvedURL - and XBMC will then attempt to play that URL.
RE: Continous Loop - spiff - 2012-07-12
see http://paste.ubuntu.com/1088547/ for a patch or http://paste.ubuntu.com/1088551/ for an untested quick hack that should hopefully help you get it.
RE: Continous Loop - mikey1234 - 2012-07-12
hi its still looping
i have released it now so if you want to have a look you can
http://forum.xbmc.org/showthread.php?tid=135925
|