Hi,
I wanted to write a channel where I retreive the video urls by a php api which returns json encoded titles and urls.
e.g.
http://example.com/api.php?search=Movie
will return in:
[
{“title”:" Movie 1",“id”:“foo”},
{“title”:" Movie 2",“id”:“bar”},
{“title”:“contains Movie so will be included in Return”,“id”:“baz”},
]
To start with the basics, i copied the Sound Cloud Plugin Service and renamed him to provide a legit ServiceURL Handler. Which wouldn’t get called anyway and took some generic plist files.
My init.py looks like this, but the Channel won’t respond.
`
NAME = ‘helloworldplugin’
SEARCH_URL = ‘http://example.com/api.php’
####################################################################################################
def Start():
ObjectContainer.title1 = NAME
HTTP.CacheTime = CACHE_1HOUR
####################################################################################################
@handler(’/video/helloworldplugin’, NAME)
def MainMenu():
ObjectContainer(header=“Empty”, message=“Search something”)2
return oc
####################################################################################################
@route(’/video/helloworldplugin/search’, allow_sync = True)
def Search(query = ‘music’):
return ProcessRequest(title = query)
####################################################################################################
@route(’/video/helloworldplugin/{title}’, params = dict, offset = int, allow_sync = True)
def ProcessRequest(title, params, offset = 0, id = -1, type = “default”):
oc = ObjectContainer(title2 = title)
data = JSON.ObjectFromURL(SEARCH_URL+’?search=’+title)
for elements in data:
oc.add(
DirectoryObject(
key = Callback(Streams, title=elements[‘title’], href=elements[‘href’]),
title = title
)
)
return oc
####################################################################################################
@route(’/video/helloworldplugin/Streams’)
def Streams(title, href):
print(title);
print(href);
return oc
`
I don’t get it, shouldn’t this work?