-
Notifications
You must be signed in to change notification settings - Fork 18
Building a search function
- Search function
Moving in menus with directional keys of remote, it is not easy and quick as with a mouse. So the fastest way to get our favorite movie is through textual search. e2iplayer contains some common libraries that make this quite simple with a standard procedure. Developer has only to perform a search in browser and copy the structure of http call (in this context developers tools in Chrome of Firefox are very useful and rich of informations).
In web site we are analysing in these examples (https://filmowood.com/), a search of movies with given words in title opens a page through an url in this form: https://filmowood.com/?s=the+lion+king where the lion king are the words typed in the text input of page.
It is simple to clone this in host. The function quote_plus from library urllib (remember to add import urllib at the top of code) transforms spaces in plus signs and converts special characters in html entities.
def listSearchResult(self, cItem, searchPattern, searchType):
printDBG("Filmowood.listSearchResult cItem[%s], searchPattern[%s] searchType[%s]" % (cItem, searchPattern, searchType))
cItem = dict(cItem)
cItem['url'] = self.getFullUrl('/?s=') + urllib.quote_plus(searchPattern)
cItem['category'] = 'search_items'
self.listItems(cItem)
And this is the result of search in GUI. Don't ask me why there are also three movies without any connection in title with search words, but it is the same thing that happens in browser, so code is right!

thx for this original Text to Maxbambi