def __onClose(self): eRCInput.getInstance().setKeyboardMode(self._keyboardMode) def _onSearchInputChanged(self): self.__searchTimer.startLongTimer(1) def _actionAscii(self): self["needle"].handleAscii(getPrevAsciiCode()) self._onSearchInputChanged() def _keyNumberGlobal(self, number): self["needle"].number(number) self._onSearchInputChanged() def _actionBackspace(self): self["needle"].deleteBackward() self._onSearchInputChanged() def _actionDelete(self): self["needle"].delete() self._onSearchInputChanged() def _onSearchTimeout(self): needle = "%" + self["needle"].getText() + "%" if needle: self._list.search(needle) mediaCore.registerBrowser(MediaBrowserSearch, _("Search"), MediaCore.TYPE_AUDIO)
FEATURE_FILTER_TYPE = True FEATURE_ADD_FOLDER = True TITLE = _("File Browser") def __init__(self, session, type=type, player=None): MediaBrowser.__init__(self, session, type, player=player) self._setList(MediaBrowserFileList(type)) def addFolderToPlaylist(self, folder, recursive=True): if folder == '/': Log.w("refusing to operate on /") return False filelist = FileList(folder, matchingPattern=self._list.filter, useServiceRef=True, showMountpoints=False, isTop=True) for x in filelist.getFileList(): if x[0][1] == True: #isDir if recursive: if x[0][0] != folder: self.addFolderToPlaylist(x[0][0]) else: self.addToPlaylist(x[0][0]) return True mediaCore.registerBrowser(MediaBrowserFile, _("Filesystem"), MediaCore.TYPE_AUDIO_VIDEO)
self.onClose.append(self.__onClose) def __onClose(self): eRCInput.getInstance().setKeyboardMode(self._keyboardMode) def _onSearchInputChanged(self): self.__searchTimer.startLongTimer(1) def _actionAscii(self): self["needle"].handleAscii(getPrevAsciiCode()) self._onSearchInputChanged() def _keyNumberGlobal(self, number): self["needle"].number(number) self._onSearchInputChanged() def _actionBackspace(self): self["needle"].deleteBackward() self._onSearchInputChanged() def _actionDelete(self): self["needle"].delete() self._onSearchInputChanged() def _onSearchTimeout(self): needle = "%" + self["needle"].getText() + "%" if needle: self._list.search(needle) mediaCore.registerBrowser(MediaBrowserSearch, _("Search"), MediaCore.TYPE_AUDIO)
def getItemName(self): item = self.getSelectedItem() if item != None: meta = self._browser.getItemMetadata(item) return meta[Statics.META_TITLE] return "--- error getting item name ---" def getServiceRef(self): item = self.getSelectedItem() if item is None: return eServiceReference() meta = self._browser.getItemMetadata(item) ref = eServiceReference(4097,0, meta[Statics.META_URI]) ref.setName(meta[Statics.META_TITLE]) return ref class MediaBrowserUPnP(MediaBrowser): FEATURE_FILTER_TYPE = True FEATURE_ASYNC = True TITLE = _("UPnP/DLNA Browser") def __init__(self, session, type=type, player=None): MediaBrowser.__init__(self, session, type, player=player) self._setList(MediaBrowserUPnPList(type=type)) def canAddSelected(self): return self._list.isValidType(self._list.getSelectedItem()) mediaCore.registerBrowser(MediaBrowserUPnP, _("DLNA / UPnP"), MediaCore.TYPE_AUDIO_VIDEO)
def canAddSelected(self): return self._list.canAddSelected() @staticmethod def search(needle): db = eMediaDatabase.getInstance() res = db.filterAudio(needle, 0, 250) if res.error(): return [] items = [] for item in res.data(): filename = "%s/%s" % (item[eMediaDatabase.FIELD_PATH], item[eMediaDatabase.FIELD_FILENAME]) if filename.endswith('.ts'): ref = eServiceReference(eServiceReference.idDVB, 0, filename) elif filename.endswith('.m2ts'): ref = eServiceReference(3, 0, filename) else: ref = eServiceReference(eServiceReference.idGST, 0, filename) ref.setName("%s - %s" % (item[eMediaDatabase.FIELD_ARTIST], item[eMediaDatabase.FIELD_TITLE])) items.append((ref.getName(), (ref, dict(item)))) return items mediaCore.registerBrowser(MediaBrowserDB, _("Media Database"), MediaCore.TYPE_AUDIO) mediaCore.registerBrowser(MediaBrowserDB, _("Media Database"), MediaCore.TYPE_VIDEO)
return None def getMeta(self, item): return None class MediaBrowserFile(MediaBrowser): FEATURE_FILTER_TYPE = True FEATURE_ADD_FOLDER = True TITLE = _("File Browser") def __init__(self, session, type=type, player=None): MediaBrowser.__init__(self, session, type, player=player) self._setList(MediaBrowserFileList(type)) def addFolderToPlaylist(self, folder, recursive=True): if folder == '/': Log.w("refusing to operate on /") return False filelist = FileList(folder, matchingPattern=self._list.filter, useServiceRef=True, showMountpoints=False, isTop=True) for x in filelist.getFileList(): if x[0][1] == True: #isDir if recursive: if x[0][0] != folder: self.addFolderToPlaylist(x[0][0]) else: self.addToPlaylist(x[0][0]) return True mediaCore.registerBrowser(MediaBrowserFile, _("Filesystem"), MediaCore.TYPE_AUDIO_VIDEO)
def getServiceRef(self): item = self.getSelectedItem() if item is None: return eServiceReference() meta = self._browser.getItemMetadata(item) filename = meta[Statics.META_URI] if filename.endswith('.ts'): ref = eServiceReference(eServiceReference.idDVB,0,filename) elif filename.endswith('.m2ts'): ref = eServiceReference(3,0,filename) else: ref = eServiceReference(eServiceReference.idGST,0,filename) ref.setName(meta[Statics.META_TITLE]) return ref class MediaBrowserUPnP(MediaBrowser): FEATURE_FILTER_TYPE = True FEATURE_ASYNC = True TITLE = _("UPnP/DLNA Browser") def __init__(self, session, type=type, player=None): MediaBrowser.__init__(self, session, type, player=player) self._setList(MediaBrowserUPnPList(type=type)) def canAddSelected(self): return self._list.isValidType(self._list.getSelectedItem()) mediaCore.registerBrowser(MediaBrowserUPnP, _("DLNA / UPnP"), MediaCore.TYPE_AUDIO_VIDEO)
def addFolderToPlaylist(self, folder, recursive=True): Log.i("called") items = self._list.getAllForSelected() if not items: return False for item in items: item = dict(item) self.addToPlaylist(self._list.getServiceRef(item=item), item) return True def canAddSelected(self): return self._list.canAddSelected() @staticmethod def search(needle): db = eMediaDatabase.getInstance() res = db.filterAudio(needle, 0, 250) if res.error(): return [] items = [] for item in res.data(): filename = "%s/%s" %(item[eMediaDatabase.FIELD_PATH], item[eMediaDatabase.FIELD_FILENAME]) ref = eServiceReference(4097, 0, filename) ref.setName("%s - %s" %(item[eMediaDatabase.FIELD_ARTIST], item[eMediaDatabase.FIELD_TITLE])) items.append( (ref.getName(), (ref, dict(item))) ) return items mediaCore.registerBrowser(MediaBrowserDB, _("Media Database"), MediaCore.TYPE_AUDIO) mediaCore.registerBrowser(MediaBrowserDB, _("Media Database"), MediaCore.TYPE_VIDEO)