Esempio n. 1
0
	def Do( self ):
		mode = self.args.get( 'mode', None )
		if mode is None:
			self.showMainMenu()
		elif mode[0] == 'search':
			self.showSearch()
		elif mode[0] == 'searchall':
			self.showSearchAll()
		elif mode[0] == 'livestreams':
			self.db.GetLiveStreams( FilmUI( self, [ xbmcplugin.SORT_METHOD_LABEL ] ) )
		elif mode[0] == 'recent':
			channel = self.args.get( 'channel', [0] )
			self.db.GetRecents( channel[0], FilmUI( self ) )
		elif mode[0] == 'recentchannels':
			self.db.GetRecentChannels( ChannelUI( self.addon_handle, nextdir = 'recent' ) )
		elif mode[0] == 'channels':
			self.db.GetChannels( ChannelUI( self.addon_handle ) )
		elif mode[0] == 'action-dbinfo':
			self.showDbInfo()
		elif mode[0] == 'initial':
			channel = self.args.get( 'channel', [0] )
			self.db.GetInitials( channel[0], InitialUI( self.addon_handle ) )
		elif mode[0] == 'shows':
			channel = self.args.get( 'channel', [0] )
			initial = self.args.get( 'initial', [None] )
			self.db.GetShows( channel[0], initial[0], ShowUI( self.addon_handle ) )
		elif mode[0] == 'films':
			show = self.args.get( 'show', [0] )
			self.db.GetFilms( show[0], FilmUI( self ) )
		elif mode[0] == 'download':
			filmid	= self.args.get( 'id', [0] )
			quality	= self.args.get( 'quality', [1] )
			self.doDownloadFilm( filmid[0], quality[0] )
		elif mode[0] == 'enqueue':
			self.doEnqueueFilm( self.args.get( 'id', [0] )[0] )
    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)
Esempio n. 3
0
    def Do(self):
        # save last activity timestamp
        self.settings.ResetUserActivity()
        # process operation
        mode = self.args.get('mode', None)
        if mode is None:
            self.showMainMenu()
        elif mode[0] == 'search':
            self.showSearch()
        elif mode[0] == 'searchall':
            self.showSearch(extendedsearch=True)
        elif mode[0] == 'livestreams':
            self.db.GetLiveStreams(FilmUI(self,
                                          [xbmcplugin.SORT_METHOD_LABEL]))
        elif mode[0] == 'recent':
            channel = self.args.get('channel', [0])
            self.db.GetRecents(channel[0], FilmUI(self))
        elif mode[0] == 'recentchannels':
            self.db.GetRecentChannels(ChannelUI(self, nextdir='recent'))
        elif mode[0] == 'channels':
            self.db.GetChannels(ChannelUI(self, nextdir='shows'))
        elif mode[0] == 'action-dbinfo':
            self.showDbInfo()
        elif mode[0] == 'action-dbupdate':
            self.settings.TriggerUpdate()
            self.notifier.ShowNotification(30963, 30964, time=10000)
        elif mode[0] == 'initial':
            channel = self.args.get('channel', [0])
            self.db.GetInitials(channel[0], InitialUI(self))
        elif mode[0] == 'shows':
            channel = self.args.get('channel', [0])
            initial = self.args.get('initial', [None])
            self.db.GetShows(channel[0], initial[0], ShowUI(self))
        elif mode[0] == 'films':
            show = self.args.get('show', [0])
            self.db.GetFilms(show[0], FilmUI(self))
        elif mode[0] == 'download':
            filmid = self.args.get('id', [0])
            quality = self.args.get('quality', [1])
            self.doDownloadFilm(filmid[0], quality[0])
        elif mode[0] == 'enqueue':
            self.doEnqueueFilm(self.args.get('id', [0])[0])

        # cleanup saved searches
        if mode is None or mode[0] != 'search':
            self.addon.setSetting('lastsearch1', '')
        if mode is None or mode[0] != 'searchall':
            self.addon.setSetting('lastsearch2', '')
Esempio n. 4
0
	def showSearchAll( self ):
		searchText = self.notifier.GetEnteredText( '', self.language( 30902 ).decode( 'UTF-8' ) )
		if len( searchText ) > 2:
			self.db.SearchFull( searchText, FilmUI( self ) )
		else:
			self.info( 'The following ERROR can be ignored. It is caused by the architecture of the Kodi Plugin Engine' )
			self.endOfDirectory( False, cacheToDisc = True )
Esempio n. 5
0
 def showSearch(self, extendedsearch=False):
     settingid = 'lastsearch2' if extendedsearch is True else 'lastsearch1'
     headingid = 30902 if extendedsearch is True else 30901
     # are we returning from playback ?
     searchText = self.addon.getSetting(settingid)
     if len(searchText) > 0:
         # restore previous search
         self.db.Search(searchText, FilmUI(self), extendedsearch)
     else:
         # enter search term
         searchText = self.notifier.GetEnteredText('', headingid)
         if len(searchText) > 2:
             if self.db.Search(searchText, FilmUI(self),
                               extendedsearch) > 0:
                 self.addon.setSetting(settingid, searchText)
         else:
             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 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 play_movie_with_subs(self, filmid, only_set_resolved_url):
     film = self.database.RetrieveFilmInfo(filmid)
     if film is None:
         self.notifier.ShowError(30990, self.plugin.language(30991))
         return
     ttmname = os.path.join(self.plugin.datapath, 'subtitle.ttml')
     srtname = os.path.join(self.plugin.datapath, 'subtitle.srt')
     subs = []
     if self.download_subtitle(film, ttmname, srtname, 'subtitle'):
         subs.append(srtname)
     (videourl, listitem) = FilmUI(self.plugin).get_list_item(None, film)
     if listitem:
         if subs:
             listitem.setSubtitles(subs)
         if only_set_resolved_url:
             self.plugin.setResolvedUrl(True, listitem)
         else:
             xbmc.Player().play(videourl, listitem)
    def play_movie_with_subs(self, filmid):
        """
        Play the specified film with subtitles. Since the subtitles
        are not available in a playable format, they have to be
        downloaded and converted first.

        Args:
            filmid(id): database id of the film to play
        """
        film = self.database.retrieve_film_info(filmid)
        if film is None:
            self.notifier.show_error(30990, self.plugin.language(30991))
            return
        ttmname = os.path.join(self.plugin.datapath, 'subtitle.ttml')
        srtname = os.path.join(self.plugin.datapath, 'subtitle.srt')
        subs = []
        if self.download_subtitle(film, ttmname, srtname, 'subtitle'):
            subs.append(srtname)
        (_, listitem) = FilmUI(self.plugin).get_list_item(None, film)
        if listitem:
            if subs:
                listitem.setSubtitles(subs)
            self.plugin.set_resolved_url(True, listitem)
    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):
        # 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', '')