Advertisement
Guest User

Untitled

a guest
Oct 10th, 2015
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.67 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.  
  14.   oc = ObjectContainer(header="Empty", message="Search something")
  15.   oc.add(InputDirectoryObject(key = Callback(Search), title = "Stream Search...", prompt = "Search for Streams"))
  16.  
  17.   return oc
  18. ####################################################################################################
  19. @route('/video/helloworldplugin/search', allow_sync = True)
  20. def Search(query = 'video'):
  21.  
  22.     return ProcessRequest(title = query)
  23.  
  24. ####################################################################################################
  25. @route('/video/helloworldplugin/{title}', params = dict, offset = int, allow_sync = True)
  26. def ProcessRequest(title):
  27.  
  28.    oc = ObjectContainer(title2 = title)
  29.  
  30.    data = JSON.ObjectFromURL(SEARCH_URL+'?search='+title)
  31.  
  32.    for elements in data:
  33.     oc.add(
  34.       DirectoryObject(
  35.         key = Callback(Streams, title=elements['title'], href=elements['href']),
  36.         title = elements['title']
  37.       )
  38.     )
  39.  
  40.     return oc
  41.  
  42. ####################################################################################################
  43. @route('/video/helloworldplugin/Streams')
  44. def Streams(title, href):
  45.  
  46.     oc = ObjectContainer(header="Empty", message="title: "+title+"\n href: "+href)
  47.   #  print(title);
  48.    # print(href);
  49.  
  50.     return oc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement