I-A-C / plugin.video.exodusredux

GNU General Public License v3.0
20 stars 13 forks source link

Widget Items use Window to list results and not directory as set #13

Closed SerpentDrago closed 5 years ago

SerpentDrago commented 5 years ago

When using Widget items that link to Redux . It will show link results in a window and not directory . This only happens on Widget items .

Kodi 18 Beta5 / Windows 10 / Latest released Redux and dependency's

Tikipeter commented 5 years ago

This is by design. The 'Directory' setting is ignored if a search is not initiated from within the plugin (well, technically, from within any plugin) because 'Container.Update' is used to display results when in Directory mode, and you cannot do that from the Kodi home screen.

Relevant code is line 65 in sources.py:

if select == '1' and 'plugin' in control.infoLabel('Container.PluginName'):

doko-desuka commented 5 years ago

This annoyed me for everrrrr.... the same happens in the Favourites screen.
I always want it to be a directory since some hosts might try to load but end up timing-out, so I want to be able to choose another host quickly.

In order for it to work from homescreen or favourites etc you need to change some files, like modules/sources.py (removing that 'plugin' in control.infoLabel(...) condition as well as some other changes) and indexers/movies.py and indexers/episodes.py

The (small) disadvantage is that --after these changes-- when you choose the Dialog playback mode, after you're done you need to hit back because it goes into an empty directory. It's just an additional action you need to do.
But otherwise it works fine.

doko-desuka commented 5 years ago

Hmm actually I just care that the results are shown quickly again, so replacing the play() function inside modules/sources.py with the following seems to do that:

    def play(self, title, year, imdb, tvdb, season, episode, tvshowtitle, premiered, meta, select):
        try:

            url = None

            items = [ ]

            lastSourcesID = control.window.getProperty('exodusredux.lastSourcesID')
            if lastSourcesID and lastSourcesID == (imdb + title):
                jsonItems = control.window.getProperty(self.itemProperty)
                if jsonItems:
                    items = json.loads(jsonItems)

            if not items:
                items = self.getSources(title, year, imdb, tvdb, season, episode, tvshowtitle, premiered)
                if len(items):
                    control.window.setProperty('exodusredux.lastSourcesID', imdb + title)
                else:
                    control.window.clearProperty('exodusredux.lastSourcesID')

            select = control.setting('hosts.mode') if select == None else select

            title = tvshowtitle if not tvshowtitle == None else title

            if control.window.getProperty('PseudoTVRunning') == 'True':
                return control.resolve(int(sys.argv[1]), True, control.item(path=str(self.sourcesDirect(items))))

            if len(items) > 0:
                control.window.setProperty(self.itemProperty, json.dumps(items))                    
                control.window.setProperty(self.metaProperty, meta)                
                if select == '1' and 'plugin' in control.infoLabel('Container.PluginName'):
                    control.sleep(200)
                    return control.execute('Container.Update(%s?action=addItem&title=%s)' % (sys.argv[0], urllib.quote_plus(title)))

                elif select == '0' or select == '1':
                    url = self.sourcesDialog(items)

                else:
                    url = self.sourcesDirect(items)

            if url == None:
                return self.errorForSources()

            try: meta = json.loads(meta)
            except: pass

            from resources.lib.modules.player import player
            player().run(title, year, season, episode, imdb, tvdb, url, meta)
        except:
            pass

This skips the source getting part if you're playing the last episode or movie you tried to play.
It still shows a dialog instead of a directory when playing from the home / favourites screen, but at least the results are loaded almost immediately.

SerpentDrago commented 5 years ago

when will it do a fresh scrape ? this could cause other issues if it never wants to do a fresh scrape again . is it based on cache ? does it have a timeout ?

I would LOVE this fix , but not if its going to screw up stuff

doko-desuka commented 5 years ago

This modification just checks if the item being played now is the the same as the last item played, and so reuses the results of the search. If you play another item (another movie or episode) it will scrape fresh again, as well as if you quit Kodi and restart it.
This is really overkill though, I just want maximum speed.

If you don't do anything and use the addon as it is, it already caches results for 1 hour -- playing the same item again and again will reuse results for that 1 hour -- it just looks like it's scraping fresh each time because it shows that progress dialog going through all scrapers, but on each scraper it sees that there's cached results and uses them. It already does this.
What I don't like about it is that it incurs in file-reads from the database file. This modification skips that.

SerpentDrago commented 5 years ago

agree , i like the change . will need testing , i say make the PR , and i'll grab it and test

SerpentDrago commented 5 years ago

doko - , i sent you a message on reddit , you never responded , check ya messages

doko-desuka commented 5 years ago

We're on different timezones bruh, relax x)

I'm looking at my inbox, there's nothing there. You sure you sent one?
I would've gotten an email notification

Tikipeter commented 5 years ago

Really all you need to do to get a directory listing from the home screen is open another window before you display the results. You could simply do:

if not 'plugin' in control.infoLabel('Container.PluginName') and select == '1':
    control.execute('ActivateWindow(videos, return)')

Put this after items and select have been defined in sources().play() and I think you will have the behavior you want (it should also work from Favorites).

Then remove the extra condition from

if select == '1' and 'plugin' in control.infoLabel('Container.PluginName'):

So just:

if select == '1':

This would need testing as I did see that it works, but only briefly. Plus there may need to be a small delay added after opening the Videos window if slower hardware does not execute the code as intended.

You will still need an extra 'back' when exiting back to homescreen, but this is unavoidable I think if you want a directory listing, as it needs to be built from within a window.

doko-desuka commented 5 years ago

Thanks for sharing that Tikipeter (and nice to see you around here).
I'm curious if it'd be better to use ActivateWindow with the addon ID, instead of videos.

Anyway that "last item played" test from before is enough for me, showing the results very quickly.

Tikipeter commented 5 years ago

I'm curious if it'd be better to use ActivateWindow with the addon ID, instead of videos.

You certainly could use something like...

control.execute('ActivateWindow(10025, plugin://plugin.video.exodusredux)')

Although, if you wanted to open the add-on first, you'd probably be best to use something like...

control.execute('RunAddon(%s)' % 'plugin.video.exodusredux')

I don't know if it would be better or not though. ¯\(ツ)

:) :) :)