mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 21:27:05 +00:00
deepLinking withMetaResource func added
This commit is contained in:
parent
5340957254
commit
43ef01d04b
1 changed files with 22 additions and 0 deletions
|
|
@ -21,6 +21,27 @@ const withMetaItem = ({ metaItem }) => {
|
|||
};
|
||||
};
|
||||
|
||||
const withMetaResource = ({ metaResource, type, id }) => {
|
||||
const queryParams = new URLSearchParams([['metaTransportUrl', metaResource.request.base]]);
|
||||
const videoId = metaResource.content.type === 'Ready' ?
|
||||
typeof metaResource.content.content.behaviorHints.videoId === 'string' ?
|
||||
metaResource.content.content.behaviorHints.videoId
|
||||
:
|
||||
metaResource.content.content.videos.length === 1 ?
|
||||
metaResource.content.content.videos[0].id
|
||||
:
|
||||
metaResource.content.content.videos.find((video) => video.id === id) || null
|
||||
:
|
||||
null;
|
||||
return {
|
||||
meta_details_videos: `#/metadetails/${encodeURIComponent(type)}/${encodeURIComponent(id)}?${queryParams.toString()}`,
|
||||
meta_details_streams: typeof videoId === 'string' ?
|
||||
`#/metadetails/${encodeURIComponent(type)}/${encodeURIComponent(id)}/${encodeURIComponent(videoId)}?${queryParams.toString()}`
|
||||
:
|
||||
null
|
||||
};
|
||||
};
|
||||
|
||||
const withLibItem = ({ libItem, streams = {} }) => {
|
||||
const [stream, streamTransportUrl, metaTransportUrl] = typeof libItem.state.video_id === 'string' && typeof streams[`${encodeURIComponent(libItem._id)}/${encodeURIComponent(libItem.state.video_id)}`] === 'object' ?
|
||||
streams[`${encodeURIComponent(libItem._id)}/${encodeURIComponent(libItem.state.video_id)}`]
|
||||
|
|
@ -82,6 +103,7 @@ const withCatalog = ({ request }) => {
|
|||
module.exports = {
|
||||
withCatalog,
|
||||
withMetaItem,
|
||||
withMetaResource,
|
||||
withLibItem,
|
||||
withVideo,
|
||||
withStream,
|
||||
|
|
|
|||
Loading…
Reference in a new issue