stremio-addon-sdk
stremio-addon-sdk copied to clipboard
Pass custom properties from catalogHandler to streamHandler
Is there a way to pass more properties for each catalog meta item to the streamHandler?
For example when I create my catalog meta items I already know the stream url, selecting one item from the catalog will go to the streamHandler but I can only parse the id of the selected item. This will result on refetching the stream url although I already know it.
So far I add the stream url to the meta id but this pollutes the id and does not fetch the poster and other info when I select a single item.
So to conclude is there a way to pass additional properties from the CatalogHandler to the StreamHandler ?
For example:
builder.defineCatalogHandler(async args => {
const metas = [
{
id: 'tt123456',
type: 'movie',
name: 'A movie',
poster: METAHUB_URL + '/poster/medium/' + imdbId + '/img',
extra:{
streamUrl : 'amagnetlinkurl',
seeders: 10,
size: `100mb`,
...
}
}
]
return Promise.resolve({metas});
});
so when someone clicks that catalog item on the defineStreamHandler I could parse these extra info.
builder.defineStreamHandler(async args => {
// args.extra should contain all these info from catalog.
});
Thank you.
Unfortunately not, passing data as base64 encoded in the meta ID is actually (although a hack) the best way to do this.
I don't think Stremio should proxy data between different types of resource requests, the architecture presumes that an addon can have any number of resources (meta / catalog / stream) or just one. As many different addons can respond with streams to the same meta id, we shouldn't presume that who served the catalog also serves the streams (or even the meta), so passing data from catalogs to streams internally does not make much sense.
I think ur situation might be easier to fix with a feature that goes straight from the catalog to the player. (avoiding the meta page completely)
This has been requested before, as there have been other cases in which addons have the stream URLs on hand, and is a valid request imo.
Thank you for you fast response Jaruba, could you point me how to go straight to the player? I was thinking of allowing other plugins to potentially serve content but it might make more sense to go straight to the player from the catalog.
Is there any documentation on how to achieve that?
This is not possible yet though, as I mentioned before it is a requested feature. I only mentioned it because I believe it applies to your case too.