Spaces:
Runtime error
Runtime error
const { addonBuilder, serveHTTP, publishToCentral } = require('stremio-addon-sdk') | |
const { firefox } = require('playwright'); | |
const { movieMultiembed, movieMultiembedTimeout, serieMultiembed } = require('./embed'); | |
const builder = new addonBuilder({ | |
id: 'org.torflix', | |
version: '1.0.0', | |
name: 'Torflix Addon', | |
// Properties that determine when Stremio picks this addon | |
// this means your addon will be used for streams of the type movie | |
catalogs: [], | |
resources: ['stream'], | |
types: ['movie', 'series','tv'], | |
idPrefixes: ['tt'] | |
}) | |
// takes function(args) | |
builder.defineStreamHandler(async function (args) { | |
console.log(args); | |
if (args.type === 'movie' | |
// && args.id === 'tt1254207' | |
) { | |
const movieId = args.id; | |
var url = `https://torrentio.strem.fun/sort=seeders%7Clanguage=hindi/stream/movie/${movieId}.json`; | |
var streams = await fetch(url).then(res => res.json()).then(data => data.streams); | |
streams.forEach(stream => { | |
// name: 'Torflix\n1080p', | |
// title: 'Abigail.2024.1080p.DS4K.AMZN.WEBRip.DD .5.1.X265-Ralphy [ProtonMovies]\n' + | |
// 'π€ 6 πΎ 3.13 GB βοΈ 1337x', | |
// fileIdx: 0, | |
// behaviorHints: { | |
// bingeGroup: 'torrentio|1080p|WEBRip|x265', | |
// filename: 'Abigail.2024.1080p.DS4K.AMZN.WEBRip.DD+.5.1.X265-Ralphy.mkv' | |
// }, | |
// url: 'https://seedr.torrentdevbkn.workers.dev/directStream?infoHash=23a536e7b3dff5b57bd20bf70ec43f3ba063ffa1' | |
//drop infoHash from the stream object | |
stream.name = stream.name.replace('Torrentio', 'Torflix'); | |
stream.url = `https://seedr.torrentdev.workers.dev/directStream?infoHash=${stream.infoHash}`; | |
delete stream.infoHash; | |
//allow only if size < 4 GB | |
var size = stream.title.match(/πΎ ([\d.]+) GB/); | |
if (size && parseFloat(size[1]) > 4) { | |
streams = streams.filter(s => s !== stream); | |
} | |
}); | |
try{ | |
var multiembedStreams = await movieMultiembedTimeout(movieId,55000); | |
streams.push({ url: multiembedStreams, name: 'Torflix\nMultiembed', title: 'Multiembed', behaviorHints: { bingeGroup: 'multiembed' } }); | |
}catch(e){ | |
console.error(e); | |
} | |
console.log(streams); | |
return Promise.resolve({ streams: streams }); | |
//fetch the torrentio api | |
// serve one stream to big buck bunny | |
// const stream = { url: 'http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_30fps_normal.mp4' } | |
// return Promise.resolve({ streams: [stream] }) | |
} else { | |
if(args.type === 'series'){ | |
var l = serieMultiembed(args.id); | |
console.log(l); | |
var streams = []; | |
var multiembedStreams = await movieMultiembedTimeout(args.id,55000,l); | |
streams.push({ url: multiembedStreams, name: 'Torflix\nMultiembed', title: 'Multiembed', behaviorHints: { bingeGroup: 'multiembed' } }); | |
console.log(streams); | |
} | |
// otherwise return no streams | |
return Promise.resolve({ streams: [] }) | |
} | |
}) | |
serveHTTP(builder.getInterface(), { port: process.env.PORT || 7860 }) | |
//publishToCentral("https://your-domain/manifest.json") // <- invoke this if you want to publish your addon and it's accessible publically on "your-domain" |