Plugin.video.themoviedb.helper: [Request] Allow for more complex player files

Created on 13 Dec 2019  路  16Comments  路  Source: jurialmunkey/plugin.video.themoviedb.helper

Considering that some add-ons don't provide URI access to all parts of the add-on, it can often be useful to have the ability to "manually" step through the add-on via a defined set of rules in a player file. Take this player file, from an add-on with similar functionality, for the Netflix add-on:

{
  "name": "[COLOR red]Netflix[/COLOR]",
  "plugin": "plugin.video.netflix",
  "priority": 300,
  "id": "search.netflix",
  "movies": [
    [
      {
        "link": "plugin://plugin.video.netflix/directory/search/search/{title_+}/",
        "steps": [
          "{title}"
        ]
      }
    ]
  ],
  "tvshows": [
    [
      {
        "link": "plugin://plugin.video.netflix/directory/search/search/{clearname_+}/",
        "steps": [
          "{clearname}",
          ".* {season}",
          "{episode}"
        ]
      },
      {
        "link": "plugin://plugin.video.netflix/directory/search/search/{clearname_+}/",
        "steps": [
          "{clearname}",
          "{episode}"
        ]
      },
      {
        "link": "plugin://plugin.video.netflix/directory/search/search/{clearname_+}/",
        "steps": [
          "{clearname}",
          "{clearname}",
          "{episode}"
        ]
      }
    ]
  ]
}

In essence, the add-on would iterate through each "link", applying each "step" along the way, until a playable file w as found. For the first "link"/"steps" set, this would look something like:

  1. Search Netflix for {clearname_+}
  2. Choose the entry that matches {clearname}
  3. Choose the entry that matches {season}
  4. Choose the entry that matches {episode}

Would a similar layout/process be possible to implement?

All 16 comments

It's very much a maybe.

The "steps" feels very much like a hack (and I'm not sure it would fly in the official repo). IMHO, plugins like Netflix should expose a playable url - I'm hoping that by having TMDbHelper in the official repo, that more video plugins will look to provide compatibility with it.

Also, I'm not really looking to recreate Meta (or its fork OpenMeta). Meta isn't a banned addon - and the only issue with OpenMeta is that it provides a direct link to download players for banned addons (OpenInfo is a different matter since it hijacks extendedinfo's addon id).

Plus, it looks like it should be pretty simple to have a player link to OpenMeta. I haven't tested but based off its context menu code this should work:

{
    "name"              : "OpenMeta",
    "plugin"            : "plugin.video.openmeta",
    "play_movie"        : "plugin://plugin.video.openmeta/movies/play_choose_player/imdb/{imdb}/False",
    "play_episode"      : "plugin://plugin.video.openmeta/tv/play_by_name_choose_player/{showname}/{season}/{episode}/en/False"
}

@drinfernoo - Can you test latest version? I've added a "steps" implementation for players:

See default Netflix player for implementation:

{
    "name"              : "Netflix",
    "plugin"            : "plugin.video.netflix",
    "play_movie"        : [
                            "plugin://plugin.video.netflix/directory/search/search/{title}/",
                            {"title": "{title}", "year": "{year}"}
                          ],
    "play_episode"      : [
                            "plugin://plugin.video.netflix/directory/search/search/{showname}/",
                            {"title": "{showname}"},
                            {"position": "{season}"},
                            {"season": "{season}", "episode": "{episode}"}
                          ],
    "search_movie"      : "plugin://plugin.video.netflix/directory/search/search/{title}/",
    "search_episode"    : "plugin://plugin.video.netflix/directory/search/search/{showname}/"
}

The square brackets [] in play_movie and play_episode indicate a list of steps. The first step should be the base url. In the additional steps, curly braces {} are dictionary pairs with an infolabel name that must match the value given.

For the above Netflix play_movie player, the steps are:

  1. Open the plugin search url
  2. In that folder, look for an item where ListItem.Title matches our {title} key and ListItem.Year matches our {year} key.

For the above Netflix play_episode player, the steps are:

  1. Open the plugin search url
  2. In that folder, look for an item where ListItem.Title matches {showname} and open it.
  3. In that folder, open the item at the position that matches the {season} number.
  4. In that folder, look for an item where ListItem.Season matches {season} and ListItem.Episode matches {episode}.

The advantage with this implementation is that it allow checking against multiple infolabels at each step. For instance, in the above I check movies against both title and year -- so if I was looking for a movie that also has a reboot (e.g. Robocop, Total Recall, Ghostbusters), then I can be sure that I'll get the correct version.

If nothing is found, we get a pop-up OK dialog notifying us that nothing was found.

Infolabels that can be checked against:
"title", "year", "originaltitle", "imdbnumber", "premiered", "firstaired", "season", "episode", "showtitle", "label", "position"

If nothing is found, we get a pop-up OK dialog notifying us that nothing was found.

Is this the case for all players now or just ones with steps?

Just ones with steps. Basically, if there's steps, I walk through them looking for a playable file that matches the criteria. The path for that item is then sent to the player function - if there are no steps then the path in the player file is sent directly to the player function.

Also, if you're using a plugin that returns a folder of sources with stream quality in the label, then you can do some tricks to autoplay sources of a particular quality. For instance, you could play the first 1080p item by having a step at the end with {"label": "1080"}

You can also force selection of the first position source with a step {"position": "1"}

I've also added priority sorting.
"priority": 500,

Value is an integer. Lower values mean the item will be shown closer to the top of the list. "Play" functions are always grouped together above "Search" functions.

Base priority is 1000 - so values less than 1000 will be shown above players with no priority set and values higher than 1000 will show below players with no priority.

Still looking for a better method than position for seasons level in Netflix plugin as that feels too hacky and was the approach in OpenMeta that I didn't like.

@jurialmunkey Is there not a "season" InfoLabel?

Not in the Netflix plugin at the season level for some reason.

I've opened a bug report:
https://github.com/CastagnaIT/plugin.video.netflix/issues/400

But until it is available the only solution I can see is to select position, particularly as Netflix sometimes names seasons other things than "Season X" (e.g. Stranger Things seasons are called "Stranger Things" "Stranger Things 2" "Stranger Things 3")

I figured that would be the hold up. I'll look at a few add-ons in the next couple days and confirm this is working. Two I know of for sure, that require this type of traversal, are EmbyCon and PlexKodiConnect, but there are certainly others.

I've found another one! The Disney+ add-on doesn't give URI access to... basically anything 馃槄 It's "main" parameter is a UUID, that I'm not sure where it comes from.

So, you can't pass various IDs to it, and while there are "A-Z" sections, they are paginated, leaving no way to have a player navigate to titles later in the alphabet.

It also has a "Search" section (which searches Movies _and_ TV, it seems), but we currently have no way to interact with the keyboard 馃

After doing a bit more research, that UUID appears to be a "transaction ID" that is used along with an API layer (official or custom, I'm not sure) to interface with Disney+.

This being said, I really have no idea how a player could be made for it, unless we had the ability to send input to the keyboard and then run steps in the subsequent directory.

I would think this would look something like having a wait for the keyboard dialog, and then sending input via JSON-RPC.

@drinfernoo - I feel like this one is worth contacting SlyGuy (or maybe via Matt Huisman if you can't contact him directly) and asking for a path that will accept a query param.

I don't really feel comfortable simulating actual keypresses - lots of potential for bugs and misuse. Plus I'm not even sure if it would work with JSON-RPC Files.GetDirectory method.

Actually, looking at JSON-RPC docs I might be able to use Input.SendText:
https://kodi.wiki/view/JSON-RPC_API/v8#Input.SendText

Depends on whether it works in tandem with Files.GetDirectory (e.g. that method prompts the keyboard and then will accept the input and still return directory result via GetDirectory).

@jurialmunkey I presume that it will, as even directories retrieved via Files.GetDirectory still run the full code at that path, including external API calls, log statements, etc...

@drinfernoo - Doesn't appear to work. I just did a test with a dummy player calling TMDbHelper search function and a log output of results from JSON-RPC. The keyboard comes up and accepts input. It even appears to pass to the query through, but no results get returned.

EDIT: Actually, might've been related to some update container things I do with TMDbHelper. I've just tested with a couple of other plugins and I got some promising results -- big issue is that JSON-RPC call doesn't finish until after keyboard input, so the script doesn't actually move past that point. I might have to call a threaded loop to deal with the keyboard.

@drinfernoo - I've opened a separate issue here: https://github.com/jurialmunkey/plugin.video.themoviedb.helper/issues/247

I think I may have found a solution.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Blurayx picture Blurayx  路  3Comments

Blurayx picture Blurayx  路  9Comments

SerpentDrago picture SerpentDrago  路  4Comments

starman2908 picture starman2908  路  9Comments

dairefagan picture dairefagan  路  5Comments