Advertisement
Guest User

Untitled

a guest
Oct 10th, 2015
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.52 KB | None | 0 0
  1. NAME  = 'helloworldplugin'
  2.  
  3. SEARCH_URL = 'http://example.com/api.php'
  4.  
  5. ####################################################################################################
  6. def Start():
  7.  
  8.   ObjectContainer.title1 = NAME
  9. # HTTP.CacheTime = CACHE_1HOUR
  10. ####################################################################################################
  11. @handler('/video/helloworldplugin', NAME)
  12. def MainMenu():
  13.   ObjectContainer(header="Empty", message="Search something")2
  14.  
  15.   return oc
  16. ####################################################################################################
  17. @route('/video/helloworldplugin/search', allow_sync = True)
  18. def Search(query = 'video'):
  19.  
  20.     return ProcessRequest(title = query)
  21.  
  22. ####################################################################################################
  23. @route('/video/helloworldplugin/{title}', params = dict, offset = int, allow_sync = True)
  24. def ProcessRequest(title, params, offset = 0, id = -1, type = "default"):
  25.  
  26.    oc = ObjectContainer(title2 = title)
  27.  
  28.    data = JSON.ObjectFromURL(SEARCH_URL+'?search='+title)
  29.  
  30.    for elements in data:
  31.     oc.add(
  32.       DirectoryObject(
  33.         key = Callback(Streams, title=elements['title'], href=elements['href']),
  34.         title = title
  35.       )
  36.     )
  37.  
  38.     return oc
  39.  
  40. ####################################################################################################
  41. @route('/video/helloworldplugin/Streams')
  42. def Streams(title, href):
  43.  
  44.     print(title);
  45.     print(href);
  46.  
  47.     return oc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement