"Search Video Channel"

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?

Since it got messed up, here’s a pastebin

http://pastebin.com/EBMYhSdq

Answered it myself. Was a stupid question afterwards. Why is it not possible to edit my posts here?

Allright, back to asking questions in hope of an answer

http://pastebin.com/EiC3EWpu

Does somebody know why only one result of the json file will be printed out in the process request? Also i find this error very irritating

“TypeError: ProcessRequest() got an unexpected keyword argument ‘href’”

you may have problems because of the paths in your routes.

@route('/video/helloworldplugin/Streams') going to this path will match the pattern of
@route('/video/helloworldplugin/{title}') with title=“Streams”

if you were to access your server in a web browser, you go to the address http://myserver:32400/video/helloworldplugin/Streams. The server has multiple functions that match the url.

so make the route path for ProcessRequest '/video/helloworldplugin/ProcessRequest/{title}'