Advertisement
Guest User

Untitled

a guest
Oct 30th, 2016
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1.  
  2. # Copyright (C) 2013-2014
  3. # Sean Poyser (seanpoyser@gmail.com)
  4. #
  5. # This Program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2, or (at your option)
  8. # any later version.
  9. #
  10. # This Program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with XBMC; see the file COPYING. If not, write to
  17. # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  18. # http://www.gnu.org/copyleft/gpl.html
  19. #
  20.  
  21. # This script is to allow the excellent XBMC GlobalSearch script by Ronie to be
  22. # used without the need for manual entry via the on-screen keyboard.
  23. # It should be called like this:
  24. #
  25. # xbmc.executebuiltin('RunScript('FULLPATHTOSCRIPT/globalsearch.py', searchstring:SEARCHTERM)')
  26. #
  27.  
  28.  
  29. import os, sys
  30. import xbmc, xbmcaddon
  31.  
  32. ADDON = xbmcaddon.Addon('script.globalsearch')
  33. ADDONID = ADDON.getAddonInfo('id')
  34. ADDONVERSION = ADDON.getAddonInfo('version')
  35. LANGUAGE = ADDON.getLocalizedString
  36. CWD = ADDON.getAddonInfo('path').decode("utf-8")
  37. RESOURCE = xbmc.translatePath( os.path.join( CWD, 'resources', 'lib' ).encode("utf-8") ).decode("utf-8")
  38.  
  39. sys.path.append(RESOURCE)
  40.  
  41. def doSearch():
  42. searchstring = None
  43. if len(sys.argv) > 1:
  44. try:
  45. param = sys.argv[1]
  46. if param.startswith('searchstring:'):
  47. import urllib
  48. searchstring = param.split(':', 1)[-1]
  49. searchstring = urllib.unquote_plus(searchstring)
  50. searchstring = searchstring.replace('\'', '')
  51. searchstring = searchstring.replace('"', '')
  52. except:
  53. searchstring = None
  54.  
  55. if not searchstring:
  56. keyboard = xbmc.Keyboard( '', LANGUAGE(32101), False )
  57. keyboard.doModal()
  58. if ( keyboard.isConfirmed() ):
  59. searchstring = keyboard.getText()
  60.  
  61. if searchstring:
  62. params = {}
  63. import gui
  64. ui = gui.GUI( "script-globalsearch-main.xml", CWD, "Default", searchstring=searchstring, params=params )
  65. ui.doModal()
  66. del ui
  67. sys.modules.clear()
  68.  
  69. doSearch()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement