def new_search(self, extendedsearch=False): """ Asks the user to enter his search terms and then performs the search and displays the results. Args: extendedsearch(bool, optionsl): If `True`, the searches are performed both in show title and description. Default is `False` """ settingid = 'lastsearch2' if extendedsearch is True else 'lastsearch1' headingid = 30902 if extendedsearch is True else 30901 # are we returning from playback ? search = self.get_setting(settingid) if search: # restore previous search self.database.search(search, FilmUI(self), extendedsearch) else: # enter search term (search, confirmed) = self.notifier.get_entered_text('', headingid) if len(search) > 2 and confirmed is True: RecentSearches(self, extendedsearch).load().add(search).save() if self.database.search(search, FilmUI(self), extendedsearch) > 0: self.set_setting(settingid, search) else: # pylint: disable=line-too-long self.info( 'The following ERROR can be ignored. It is caused by the architecture of the Kodi Plugin Engine' ) self.end_of_directory(False, cache_to_disc=True)
def new_search(self): """ Asks the user to enter his search terms and then performs the search and displays the results. """ settingid = 'lastsearch1' headingid = 30901 # are we returning from playback ? search = self.get_setting(settingid) if search: # restore previous search ui = FilmlistUi.FilmlistUi(self) ui.generate(self.database.getQuickSearch(search)) else: # enter search term (search, confirmed) = self.notifier.get_entered_text('', headingid) if len(search) > 2 and confirmed is True: RecentSearches(self).load().add(search).save() # ui = FilmlistUi.FilmlistUi(self) rs = self.database.getQuickSearch(search) ui.generate(rs) if len(rs) > 0: self.set_setting(settingid, search) else: # pylint: disable=line-too-long self.logger.debug( 'The following ERROR can be ignored. It is caused by the architecture of the Kodi Plugin Engine' ) self.end_of_directory(False, cache_to_disc=False)
def show_searches(self, extendedsearch=False): self.addFolderItem(30931, { 'mode': "newsearch", 'extendedsearch': extendedsearch }) RecentSearches(self, extendedsearch).load().populate() self.endOfDirectory()
def show_searches(self): """ Fill the search screen with "New Search..." and the list of recent searches """ xbmcplugin.setContent(self.addon_handle, '') self.add_folder_item(30931, {'mode': "newsearch"}, icon=os.path.join(self.path, 'resources', 'icons', 'search-m.png')) RecentSearches(self).load().populate() self.end_of_directory()
def show_searches(self, extendedsearch=False): """ Fill the search screen with "New Search..." and the list of recent searches Args: extendedsearch(bool, optionsl): If `True`, the searches are performed both in show title and description. Default is `False` """ self.add_folder_item( 30931, {'mode': "newsearch", 'extendedsearch': extendedsearch}, icon=os.path.join(self.path, 'resources', 'icons', 'search-m.png') ) RecentSearches(self, extendedsearch).load().populate() self.end_of_directory()
def new_search(self, extendedsearch=False): settingid = 'lastsearch2' if extendedsearch is True else 'lastsearch1' headingid = 30902 if extendedsearch is True else 30901 # are we returning from playback ? search = self.addon.getSetting(settingid) if search: # restore previous search self.database.Search(search, FilmUI(self), extendedsearch) else: # enter search term (search, confirmed) = self.notifier.GetEnteredText('', headingid) if len(search) > 2 and confirmed is True: RecentSearches(self, extendedsearch).load().add(search).save() if self.database.Search(search, FilmUI(self), extendedsearch) > 0: self.addon.setSetting(settingid, search) else: # pylint: disable=line-too-long self.info( 'The following ERROR can be ignored. It is caused by the architecture of the Kodi Plugin Engine' ) self.endOfDirectory(False, cacheToDisc=True)
def run(self): """ Execution of the plugin """ # save last activity timestamp self.settings.reset_user_activity() # process operation self.info("Plugin invoked with parameters {}", self.args) mode = self.get_arg('mode', None) if mode is None: self.show_main_menu() elif mode == 'search': extendedsearch = self.get_arg('extendedsearch', 'False') == 'True' self.show_searches(extendedsearch) elif mode == 'newsearch': self.new_search(self.get_arg('extendedsearch', 'False') == 'True') elif mode == 'research': search = self.get_arg('search', '') extendedsearch = self.get_arg('extendedsearch', 'False') == 'True' self.database.search(search, FilmUI(self), extendedsearch) RecentSearches(self, extendedsearch).load().add(search).save() elif mode == 'delsearch': search = self.get_arg('search', '') extendedsearch = self.get_arg('extendedsearch', 'False') == 'True' RecentSearches( self, extendedsearch).load().delete(search).save().populate() self.run_builtin('Container.Refresh') elif mode == 'livestreams': self.database.get_live_streams( FilmUI(self, [xbmcplugin.SORT_METHOD_LABEL])) elif mode == 'recent': channel = self.get_arg('channel', 0) self.database.get_recents(channel, FilmUI(self)) elif mode == 'recentchannels': self.database.get_recent_channels(ChannelUI(self, nextdir='recent')) elif mode == 'channels': self.database.get_channels(ChannelUI(self, nextdir='shows')) elif mode == 'action-dbinfo': self.show_db_info() elif mode == 'action-dbupdate': self.settings.trigger_update() self.notifier.show_notification(30963, 30964, time=10000) elif mode == 'initial': channel = self.get_arg('channel', 0) self.database.get_initials(channel, InitialUI(self)) elif mode == 'shows': channel = self.get_arg('channel', 0) initial = self.get_arg('initial', None) self.database.get_shows(channel, initial, ShowUI(self)) elif mode == 'films': show = self.get_arg('show', 0) self.database.get_films(show, FilmUI(self)) elif mode == 'downloadmv': filmid = self.get_arg('id', 0) quality = self.get_arg('quality', 1) Downloader(self).download_movie(filmid, quality) elif mode == 'downloadep': filmid = self.get_arg('id', 0) quality = self.get_arg('quality', 1) Downloader(self).download_episode(filmid, quality) elif mode == 'playwithsrt': filmid = self.get_arg('id', 0) Downloader(self).play_movie_with_subs(filmid) # cleanup saved searches if mode is None or mode != 'newsearch': self.set_setting('lastsearch1', '') self.set_setting('lastsearch2', '')
def run(self): """ Execution of the plugin """ start = time.time() # save last activity timestamp self.settings.user_activity() # process operation self.logger.info("Plugin invoked with parameters {}", self.args) self.logger.debug("start View id {}", self.getCurrentViewId()) self.logger.debug("start Skin {}", self.getSkinName()) # mode = self.get_arg('mode', None) if mode is None: self.show_main_menu() self.setViewId(self.resolveViewId('MAIN')) elif mode == 'search': self.show_searches() self.setViewId(self.resolveViewId('MAIN')) elif mode == 'newsearch': self.new_search() elif mode == 'research': search = self.get_arg('search', '') ui = FilmlistUi.FilmlistUi(self) ui.generate(self.database.getQuickSearch(search)) RecentSearches(self).load().add(search).save() # elif mode == 'delsearch': search = self.get_arg('search', '') RecentSearches(self).load().delete(search).save().populate() self.run_builtin('Container.Refresh') self.setViewId(self.resolveViewId('MAIN')) # elif mode == 'extendedSearchScreen': ExtendedSearch(self, self.database, self.get_arg('extendedSearchAction', None), self.get_arg('searchId', None)).show() # elif mode == 'livestreams': ui = LivestreamUi.LivestreamUi(self) ui.generate(self.database.getLivestreams()) # elif mode == 'recent': channel = self.get_arg('channel', "") channel == "" if channel == "0" else channel ui = FilmlistUi.FilmlistUi(self) ui.generate(self.database.getRecentFilms(channel)) # self.database.get_recents(channel, FilmUI(self)) # elif mode == 'recentchannels': # self.add_folder_item(30906, {'mode': 'recent'}, icon=os.path.join(self.path, 'resources', 'icons', 'broadcast-m.png')) ui = ChannelUi.ChannelUi(self, 'recent') ui.generate(self.database.getChannelsRecent()) elif mode == 'channels': # self.add_folder_item(30906, {'mode': 'initial'}, icon=os.path.join(self.path, 'resources', 'icons', 'broadcast-m.png')) # ui = ChannelUi.ChannelUi(self, 'shows') ui.generate(self.database.getChannels()) elif mode == 'action-dbinfo': self.run_builtin("ActivateWindow(busydialognocancel)") self.show_db_info() self.run_builtin("Dialog.Close(busydialognocancel)") elif mode == 'action-dbupdate': self.settings.set_update_triggered('true') self.notifier.show_notification(30963, 30964) elif mode == 'initial': ui = LetterUi.LetterUi(self) ui.generate(self.database.getStartLettersOfShows()) elif mode == 'shows': channel = self.get_arg('channel', "") channel == "" if channel == "0" else channel initial = self.get_arg('initial', "") initial == "" if initial == "0" else initial # self.database.get_shows(channel, initial, ShowUI(self)) ui = ShowUi.ShowUi(self) if initial == "": ui.generate(self.database.getShowsByChannnel(channel)) else: ui.generate(self.database.getShowsByLetter(initial)) elif mode == 'films': show = self.get_arg('show', "") show == "" if show == "0" else show channel = self.get_arg('channel', "") channel == "" if channel == "0" else channel # self.database.get_films(show, FilmUI(self)) ui = FilmlistUi.FilmlistUi(self, pLongTitle=False) ui.generate(self.database.getFilms(channel, show)) # elif mode == 'downloadmv': filmid = self.get_arg('id', "") quality = self.get_arg('quality', 1) Downloader(self).download_movie(filmid, quality) elif mode == 'downloadep': filmid = self.get_arg('id', "") quality = self.get_arg('quality', 1) Downloader(self).download_episode(filmid, quality) elif mode == 'playwithsrt': filmid = self.get_arg('id', "") Downloader(self).play_movie_with_subs(filmid) # cleanup saved searches if self.get_setting('lastsearch1') != '' and (mode is None or mode != 'newsearch'): self.set_setting('lastsearch1', '') # self.logger.info('request processed: {} sec', time.time() - start) # self.logger.debug(" View id {}", self.getCurrentViewId()) self.logger.debug(" Skin {}", self.getSkinName())
def run(self): # save last activity timestamp self.settings.ResetUserActivity() # process operation mode = self.get_arg('mode', None) if mode is None: self.show_main_menu() elif mode == 'search': extendedsearch = self.get_arg('extendedsearch', 'False') == 'True' self.show_searches(extendedsearch) elif mode == 'newsearch': self.new_search(self.get_arg('extendedsearch', 'False') == 'True') elif mode == 'research': search = self.get_arg('search', '') extendedsearch = self.get_arg('extendedsearch', 'False') == 'True' self.database.Search(search, FilmUI(self), extendedsearch) RecentSearches(self, extendedsearch).load().add(search).save() elif mode == 'delsearch': search = self.get_arg('search', '') extendedsearch = self.get_arg('extendedsearch', 'False') == 'True' RecentSearches( self, extendedsearch).load().delete(search).save().populate() self.runBuiltin('Container.Refresh') elif mode == 'livestreams': self.database.GetLiveStreams( FilmUI(self, [xbmcplugin.SORT_METHOD_LABEL])) elif mode == 'recent': channel = self.get_arg('channel', 0) self.database.GetRecents(channel, FilmUI(self)) elif mode == 'recentchannels': self.database.GetRecentChannels(ChannelUI(self, nextdir='recent')) elif mode == 'channels': self.database.GetChannels(ChannelUI(self, nextdir='shows')) elif mode == 'action-dbinfo': self.show_db_info() elif mode == 'action-dbupdate': self.settings.TriggerUpdate() self.notifier.ShowNotification(30963, 30964, time=10000) elif mode == 'initial': channel = self.get_arg('channel', 0) self.database.GetInitials(channel, InitialUI(self)) elif mode == 'shows': channel = self.get_arg('channel', 0) initial = self.get_arg('initial', None) self.database.GetShows(channel, initial, ShowUI(self)) elif mode == 'films': show = self.get_arg('show', 0) self.database.GetFilms(show, FilmUI(self)) elif mode == 'downloadmv': filmid = self.get_arg('id', 0) quality = self.get_arg('quality', 1) Downloader(self).download_movie(filmid, quality) elif mode == 'downloadep': filmid = self.get_arg('id', 0) quality = self.get_arg('quality', 1) Downloader(self).download_episode(filmid, quality) elif mode == 'playwithsrt': filmid = self.get_arg('id', 0) only_sru = self.get_arg('only_set_resolved_url', 'False') == 'True' Downloader(self).play_movie_with_subs(filmid, only_sru) # cleanup saved searches if mode is None or mode != 'search': self.addon.setSetting('lastsearch1', '') if mode is None or mode != 'searchall': self.addon.setSetting('lastsearch2', '')