Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- import os
- from xbmc import executebuiltin
- from xbmc import sleep
- from xbmc import getLocalizedString
- from xbmc import Player
- from xbmc import getInfoLabel
- from xbmcgui import WindowXML
- from xbmcgui import ListItem
- from xbmcgui import ACTION_PREVIOUS_MENU
- from xbmcgui import ACTION_NAV_BACK
- from xbmcgui import KEY_ASCII
- from xbmcgui import KEY_UNICODE
- class SearchWindow(WindowXML):
- def __init__(self, xmlFilename, scriptPath, library=None, defaultSkin='PromoTV', defaultRes='720p'):
- super(SearchWindow, self).__init__(xmlFilename, scriptPath, defaultSkin, defaultRes)
- self.__library = library
- self.__list = None
- def setDefaultFocus(self):
- self.setFocus(self.getControl(10))
- def onInit(self):
- self.__edit = self.getControl(10)
- self.__list = self.getControl(80)
- # def onAction(self, action):
- # if (action == ACTION_PREVIOUS_MENU) or (action == ACTION_NAV_BACK):
- # print 'CLOSED FOCUS'
- # #if self.getFocusId() != 20:
- # self.setFocusId(11)
- # #self.removeControl(self.getControl(31))
- # print 'CLOSED ABOUT'
- # self.close()
- # print 'CLOSED ALL'
- def onClick(self, control):
- if control == 61:
- if getInfoLabel('Skin.String(numeric)') != 'true':
- executebuiltin('Skin.SetString(numeric, true)')
- self.setFocusId(61)
- else:
- executebuiltin('Skin.SetString(numeric, false)')
- self.setFocusId(61)
- elif control == 11:
- print 'BEGIN START'
- self.search()
- print 'SEARCH ENDED'
- elif control == 80:
- item = self.getControl(control).getSelectedItem()
- path = item.getProperty('path')
- Player().play(path, item)
- if self.getControl(control).getSelectedItem().getProperty('type') == "audio":
- executebuiltin('Action(fullscreen)')
- def search(self):
- self.__list.reset()
- search_text = self.getControl(10).getText()
- results = self.__library.librarySearch(search_text)
- for movie in results['movies']:
- title, path = movie
- type_ = "video"
- self.__list.addItem(self.createListItem(title, 'DefaultMovies.png', path, type_))
- for tvshow in results['tvshows']:
- title, path = tvshow
- type_ = "video"
- self.__list.addItem(self.createListItem(title, 'DefaultTvShows.png', path, type_))
- for musicvideo in results['musicvideos']:
- title, path = musicvideo
- type_ = "video"
- self.__list.addItem(self.createListItem(title, 'DefaultMusicVideos.png', path, type_))
- for song in results['songs']:
- title, path = song
- type_ = "audio"
- self.__list.addItem(self.createListItem(title, 'DefaultMusicSongs.png', path, type_))
- def createListItem(self, label, icon, path, type_):
- item = ListItem(label, iconImage=icon, thumbnailImage=icon)
- item.setProperty('path', path)
- item.setProperty('type', type_)
- return item
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement