diff --git a/func/stremio.js b/func/stremio.js deleted file mode 100644 index 2dec35a..0000000 --- a/func/stremio.js +++ /dev/null @@ -1,96 +0,0 @@ -const { addonBuilder } = require("stremio-addon-sdk"); -const fs = require("fs"); -const path = require("path"); -const os = require("os"); - -const tempdir = os.tmpdir(); -const saveDirectory = path.join(tempdir, "downloads"); - -const VIDEO_EXTENSIONS = [".mp4", ".mkv", ".avi", ".mov", ".flv", ".wmv"]; - -// Helper to get video files from a directory -function getVideoFiles(dir) { - let videoFiles = []; - const files = fs.readdirSync(dir); - - for (const file of files) { - const fullPath = path.join(dir, file); - const stats = fs.statSync(fullPath); - - if (stats.isDirectory()) { - // Recursively get video files from subdirectories - videoFiles = videoFiles.concat(getVideoFiles(fullPath)); - } else if (VIDEO_EXTENSIONS.includes(path.extname(file).toLowerCase())) { - // Add video files with their details - videoFiles.push({ - id: encodeURIComponent(fullPath), // Unique ID for the file - name: path.basename(file), - fullPath, - }); - } - } - - return videoFiles; -} - -// Stremio Addon Definition -const manifest = { - id: "com.besoeasy.telearia", - version: "1.0.0", - name: "Local Video Files", - description: "Showcases local video files as collections in Stremio", - resources: ["catalog", "stream"], - types: ["movie", "series"], - catalogs: [ - { - type: "movie", - id: "local-videos", - name: "Local Videos", - }, - ], -}; - -// Function to create and return the Stremio Addon -function createStremioAddon() { - const builder = new addonBuilder(manifest); - - // Provide catalog of video files - builder.defineCatalogHandler((args) => { - if (args.type === "movie" && args.id === "local-videos") { - const videoFiles = getVideoFiles(saveDirectory); - const metas = videoFiles.map((file) => ({ - id: file.id, - name: file.name, - type: "movie", - poster: "https://via.placeholder.com/300x450?text=Telearia", // Placeholder image - })); - - return Promise.resolve({ metas }); - } - - return Promise.resolve({ metas: [] }); - }); - - // Provide stream for a specific video - builder.defineStreamHandler((args) => { - const decodedId = decodeURIComponent(args.id); - const filePath = path.resolve(decodedId); - - if (fs.existsSync(filePath)) { - return Promise.resolve({ - streams: [ - { - title: "Play Video", - url: `file://${filePath}`, // Local file URL - }, - ], - }); - } - - return Promise.resolve({ streams: [] }); - }); - - return builder; -} - -module.exports = createStremioAddon; diff --git a/index.js b/index.js index 2f14745..5dd5241 100755 --- a/index.js +++ b/index.js @@ -15,23 +15,6 @@ const { getIpData } = require("./func/ip.js"); const { bytesToSize, deleteOldFiles } = require("./func/utils.js"); -const createStremioAddon = require("./func/stremio.js"); - -const http = require("http"); - -const builder = createStremioAddon(); - -const addonInterface = builder.getInterface(); - -// Run the add-on server -http - .createServer((req, res) => { - addonInterface(req, res); - }) - .listen(6798, () => { - console.log(`Stremio Addon running at: http://pi.local:6798/manifest.json`); - }); - const { Telegraf } = require("telegraf"); if (!process.env.TELEGRAMBOT) { diff --git a/package.json b/package.json index 1f5d105..d0c617e 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,6 @@ "crypto-js": "^4.2.0", "dotenv": "^16.4.5", "serve-handler": "^6.1.5", - "telegraf": "^4.16.3", - "stremio-addon-sdk": "latest" + "telegraf": "^4.16.3" } }