Spaces:
Paused
Paused
Upload 22 files
Browse filesFiles changed (22)
- .dockerignore-1
- .env+21-19
- Dockerfile+1-10
- LICENSEAdded+21
- index.js-2
- package-lock.json+144-77
- package.json+4-5
- public/configure.htmlAdded+171
- public/css/styles.cssAdded+279
- public/js/languages.jsAdded+202
- src/api/fanart.jsAdded+40
- src/api/rpdb.jsAdded+76
- src/api/tmdb.jsAdded+277
- src/helpers/cache.jsAdded+138
- src/helpers/db.jsAdded+72
- src/helpers/logger.jsAdded+65
- src/helpers/manifest.jsAdded+86
- src/helpers/ratelimit.jsAdded+7
- src/routes/catalog.jsAdded+63
- src/routes/configure.jsAdded+17
- src/routes/index.jsAdded+26
- src/routes/manifest.jsAdded+29
2 unmodified lines34567892 unmodified lineslognode_modules.dockerignore.env.gitattributes.gitignoreDockerfile2 unmodified lines3456782 unmodified lineslognode_modules.dockerignore.gitattributes.gitignoreDockerfile
1234567891011121314151617181920212223242526# Change exposition portPORT=3000# URL to access the addonBASE_URL=http://localhost:3000CACHE_CATALOG_CONTENT_DURATION_DAYS=3CACHE_POSTER_CONTENT_DURATION_DAYS=7# Enable public instanceTMDB_BEARER_TOKEN=# Define streaming catalog providers based on region# TMDB_LANGUAGE = iso_639_1 code from doc/languages.json# TMDB_WATCH_REGION= = iso_3166_1 code from doc/regions.jsonTMDB_LANGUAGE=enTMDB_WATCH_REGION=GB# Possible values are: info, debug# Default is 'info' if not specified; 'debug' provides more detailed logsLOG_LEVEL=info# The value can be expressed in days (d), weeks (w), or months (M).# For example, '3d' means that log files will be kept for 3 days before being deleted.# If LOG_INTERVAL_DELETION is not defined in the environment variables, the default value is '3d'.LOG_INTERVAL_DELETION=3d12345678910111213141516171819202122232425262728# BASE_URL is the base URL for accessing the addon without a trailing slash.# Example: https://tmdb-dice.stremio# Ensure this URL is correctly configured for your environment.BASE_URL=http://localhost:3000# Specifies the cache expiration duration for catalog content.# The format is either days or hours, e.g., '3d' for 3 days or '3h' for 3 hours.CATALOG_CONTENT_CACHE_DURATION=3d# Specifies the cache expiration duration for RPDB posters.# The format is either days or hours, e.g., '3d' for 3 days or '3h' for 3 hours.RPDB_POSTER_CACHE_DURATION=3d# The number of days after which application logs will be automatically deleted.# Set this to a suitable duration to manage log file size and retention.LOG_INTERVAL_DELETION=3d# Defines the logging level for the application.# Set to "info" for standard logging or "debug" for more detailed logs.LOG_LEVEL=info# The environment in which the application is running.# Typically set to "production" for live environments or "development" for testing and debugging.NODE_ENV=production# The port on which the addon will listen for incoming connections.# Make sure this port is open and not used by other services.PORT=3000
1234567891011121314151617181920FROM node:18-slim# Create the log and db directories and set permissionsRUN mkdir -p /usr/src/app/log /usr/src/app/db && \chown -R node:node /usr/src/app/log /usr/src/app/db# Set the working directoryWORKDIR /usr/src/app# Copy package.json and package-lock.json firstCOPY package*.json ./# Install dependenciesRUN npm install# Copy the rest of your application filesCOPY . .# Command to run your applicationCMD ["node", "index.js"]1234567891011FROM node:18-slimWORKDIR /usr/src/appCOPY package*.json ./RUN npm installCOPY . .CMD ["node", "index.js"]
123456789101112131415161718192021MIT License
Copyright (c) 2024 redd-ravenn
Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.11 unmodified lines121314151617181911 unmodified linesapp.use(express.static(path.join(__dirname, 'public')));app.use(express.json());app.use('/', routes);app.listen(PORT, () => {11 unmodified lines12131415161711 unmodified linesapp.use(express.static(path.join(__dirname, 'public')));app.use('/', routes);app.listen(PORT, () => {
1234567891011121314151617181920102 unmodified lines1231241251261271281291301311321331341355 unmodified lines14114214314414514614714814975 unmodified lines22522622722822923023123223349 unmodified lines2832842852862872882892902914 unmodified lines2962972982993003013023 unmodified lines306307308309310311312313314315316363 unmodified lines68068168268368468568668768894 unmodified lines78378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881943 unmodified lines8638648658668678681 unmodified line870871872873874875876877878257 unmodified lines11361137113811391140114111421143114411451146114711485 unmodified lines11541155115611571158115911601161116212 unmodified lines11751176117711781179118011811182118311841185118611875 unmodified lines119311941195119611971198119912001201242 unmodified lines1444144514461447144814491450145114521453386 unmodified lines18401841184218431844184518461847184863 unmodified lines191219131914191519161917191819191920143 unmodified lines20642065206620672068206920702071207214 unmodified lines2087208820892090209120921 unmodified line2094209520962097209820992100210121025 unmodified lines210821092110211121122113145 unmodified lines22592260226122622263226422652266226722682269227022715 unmodified lines227722782279228022812282228322842285{"name": "stremio-catalogs-providers","version": "1.0.0","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "stremio-catalogs-providers","version": "1.0.0","license": "ISC","dependencies": {"async": "^3.2.6","axios": "^1.7.5","bottleneck": "^2.19.5","cors": "^2.8.5","dotenv": "^16.4.5","express": "^4.19.2","sqlite3": "^5.1.7","winston": "^3.14.2","winston-daily-rotate-file": "^5.0.0"102 unmodified lines}},"node_modules/agent-base/node_modules/debug": {"version": "4.3.6","resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz","integrity": "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==","license": "MIT","optional": true,"dependencies": {"ms": "2.1.2"},"engines": {"node": ">=6.0"5 unmodified lines}},"node_modules/agent-base/node_modules/ms": {"version": "2.1.2","resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz","integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==","license": "MIT","optional": true},75 unmodified lines"license": "MIT"},"node_modules/axios": {"version": "1.7.5","resolved": "https://registry.npmjs.org/axios/-/axios-1.7.5.tgz","integrity": "sha512-fZu86yCo+svH3uqJ/yTdQ0QHpQu5oL+/QE+QPSv6BZSkDAoky9vytxp7u5qk83OJFS3kEBcesWni9WTZAv3tSw==","license": "MIT","dependencies": {"follow-redirects": "^1.15.6",49 unmodified lines}},"node_modules/body-parser": {"version": "1.20.2","resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz","integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==","license": "MIT","dependencies": {"bytes": "3.1.2",4 unmodified lines"http-errors": "2.0.0","iconv-lite": "0.4.24","on-finished": "2.4.1","qs": "6.11.0","raw-body": "2.5.2","type-is": "~1.6.18","unpipe": "1.0.0"3 unmodified lines"npm": "1.2.8000 || >= 1.4.16"}},"node_modules/bottleneck": {"version": "2.19.5","resolved": "https://registry.npmjs.org/bottleneck/-/bottleneck-2.19.5.tgz","integrity": "sha512-VHiNCbI1lKdl44tGrhNfU3lup0Tj/ZBMJB5/2ZbNXRCPuRCO7ed2mgcK4r17y+KB2EfuYuRaVlwNbAeaWGSpbw==","license": "MIT"},"node_modules/brace-expansion": {"version": "1.1.11",363 unmodified lines"license": "MIT"},"node_modules/encodeurl": {"version": "1.0.2","resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz","integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==","license": "MIT","engines": {"node": ">= 0.8"94 unmodified lines}},"node_modules/express": {"version": "4.19.2","resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz","integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==","license": "MIT","dependencies": {"accepts": "~1.3.8","array-flatten": "1.1.1","body-parser": "1.20.2","content-disposition": "0.5.4","content-type": "~1.0.4","cookie": "0.6.0","cookie-signature": "1.0.6","debug": "2.6.9","depd": "2.0.0","encodeurl": "~1.0.2","escape-html": "~1.0.3","etag": "~1.8.1","finalhandler": "1.2.0","fresh": "0.5.2","http-errors": "2.0.0","merge-descriptors": "1.0.1","methods": "~1.1.2","on-finished": "2.4.1","parseurl": "~1.3.3","path-to-regexp": "0.1.7","proxy-addr": "~2.0.7","qs": "6.11.0","range-parser": "~1.2.1","safe-buffer": "5.2.1","send": "0.18.0","serve-static": "1.15.0","setprototypeof": "1.2.0","statuses": "2.0.1","type-is": "~1.6.18",43 unmodified lines"node": ">= 0.8"}},"node_modules/fn.name": {"version": "1.1.0","resolved": "https://registry.npmjs.org/fn.name/-/fn.name-1.1.0.tgz",1 unmodified line"license": "MIT"},"node_modules/follow-redirects": {"version": "1.15.6","resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz","integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==","funding": [{"type": "individual",257 unmodified lines}},"node_modules/http-proxy-agent/node_modules/debug": {"version": "4.3.6","resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz","integrity": "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==","license": "MIT","optional": true,"dependencies": {"ms": "2.1.2"},"engines": {"node": ">=6.0"5 unmodified lines}},"node_modules/http-proxy-agent/node_modules/ms": {"version": "2.1.2","resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz","integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==","license": "MIT","optional": true},12 unmodified lines}},"node_modules/https-proxy-agent/node_modules/debug": {"version": "4.3.6","resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz","integrity": "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==","license": "MIT","optional": true,"dependencies": {"ms": "2.1.2"},"engines": {"node": ">=6.0"5 unmodified lines}},"node_modules/https-proxy-agent/node_modules/ms": {"version": "2.1.2","resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz","integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==","license": "MIT","optional": true},242 unmodified lines}},"node_modules/merge-descriptors": {"version": "1.0.1","resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz","integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==","license": "MIT"},"node_modules/methods": {"version": "1.1.2",386 unmodified lines}},"node_modules/path-to-regexp": {"version": "0.1.7","resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz","integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==","license": "MIT"},"node_modules/prebuild-install": {63 unmodified lines"license": "MIT"},"node_modules/pump": {"version": "3.0.0","resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz","integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==","license": "MIT","dependencies": {"end-of-stream": "^1.1.0",143 unmodified lines}},"node_modules/send": {"version": "0.18.0","resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz","integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==","license": "MIT","dependencies": {"debug": "2.6.9",14 unmodified lines"node": ">= 0.8.0"}},"node_modules/send/node_modules/ms": {"version": "2.1.3","resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",1 unmodified line"license": "MIT"},"node_modules/serve-static": {"version": "1.15.0","resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz","integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==","license": "MIT","dependencies": {"encodeurl": "~1.0.2",5 unmodified lines"node": ">= 0.8.0"}},"node_modules/set-blocking": {"version": "2.0.0","resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz",145 unmodified lines}},"node_modules/socks-proxy-agent/node_modules/debug": {"version": "4.3.6","resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz","integrity": "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==","license": "MIT","optional": true,"dependencies": {"ms": "2.1.2"},"engines": {"node": ">=6.0"5 unmodified lines}},"node_modules/socks-proxy-agent/node_modules/ms": {"version": "2.1.2","resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz","integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==","license": "MIT","optional": true},123456789101112131415161718102 unmodified lines1211221231241251261271281291301311321335 unmodified lines13914014114214314414514614775 unmodified lines22322422522622722822923023149 unmodified lines2812822832842852862872882894 unmodified lines2942952962972982993003 unmodified lines304305306307308309310311312313314315316317318319320321322323363 unmodified lines68768868969069169269369469594 unmodified lines79079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582643 unmodified lines8708718728738748758768778788798808818828838841 unmodified line886887888889890891892893894257 unmodified lines11521153115411551156115711581159116011611162116311645 unmodified lines11701171117211731174117511761177117812 unmodified lines11911192119311941195119611971198119912001201120212035 unmodified lines120912101211121212131214121512161217242 unmodified lines1460146114621463146414651466146714681469147014711472386 unmodified lines18591860186118621863186418651866186763 unmodified lines193119321933193419351936193719381939143 unmodified lines20832084208520862087208820892090209114 unmodified lines2106210721082109211021112112211321142115211621172118211921201 unmodified line2122212321242125212621272128212921305 unmodified lines213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180145 unmodified lines23262327232823292330233123322333233423352336233723385 unmodified lines234423452346234723482349235023512352{"name": "stremio-tmdb-dice","version": "1.0.0","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "stremio-tmdb-dice","version": "1.0.0","license": "ISC","dependencies": {"axios": "^1.7.7","cors": "^2.8.5","dotenv": "^16.4.5","express": "^4.20.0","sqlite3": "^5.1.7","winston": "^3.14.2","winston-daily-rotate-file": "^5.0.0"102 unmodified lines}},"node_modules/agent-base/node_modules/debug": {"version": "4.3.7","resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz","integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==","license": "MIT","optional": true,"dependencies": {"ms": "^2.1.3"},"engines": {"node": ">=6.0"5 unmodified lines}},"node_modules/agent-base/node_modules/ms": {"version": "2.1.3","resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz","integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==","license": "MIT","optional": true},75 unmodified lines"license": "MIT"},"node_modules/axios": {"version": "1.7.7","resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz","integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==","license": "MIT","dependencies": {"follow-redirects": "^1.15.6",49 unmodified lines}},"node_modules/body-parser": {"version": "1.20.3","resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz","integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==","license": "MIT","dependencies": {"bytes": "3.1.2",4 unmodified lines"http-errors": "2.0.0","iconv-lite": "0.4.24","on-finished": "2.4.1","qs": "6.13.0","raw-body": "2.5.2","type-is": "~1.6.18","unpipe": "1.0.0"3 unmodified lines"npm": "1.2.8000 || >= 1.4.16"}},"node_modules/body-parser/node_modules/qs": {"version": "6.13.0","resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz","integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==","license": "BSD-3-Clause","dependencies": {"side-channel": "^1.0.6"},"engines": {"node": ">=0.6"},"funding": {"url": "https://github.com/sponsors/ljharb"}},"node_modules/brace-expansion": {"version": "1.1.11",363 unmodified lines"license": "MIT"},"node_modules/encodeurl": {"version": "2.0.0","resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz","integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==","license": "MIT","engines": {"node": ">= 0.8"94 unmodified lines}},"node_modules/express": {"version": "4.20.0","resolved": "https://registry.npmjs.org/express/-/express-4.20.0.tgz","integrity": "sha512-pLdae7I6QqShF5PnNTCVn4hI91Dx0Grkn2+IAsMTgMIKuQVte2dN9PeGSSAME2FR8anOhVA62QDIUaWVfEXVLw==","license": "MIT","dependencies": {"accepts": "~1.3.8","array-flatten": "1.1.1","body-parser": "1.20.3","content-disposition": "0.5.4","content-type": "~1.0.4","cookie": "0.6.0","cookie-signature": "1.0.6","debug": "2.6.9","depd": "2.0.0","encodeurl": "~2.0.0","escape-html": "~1.0.3","etag": "~1.8.1","finalhandler": "1.2.0","fresh": "0.5.2","http-errors": "2.0.0","merge-descriptors": "1.0.3","methods": "~1.1.2","on-finished": "2.4.1","parseurl": "~1.3.3","path-to-regexp": "0.1.10","proxy-addr": "~2.0.7","qs": "6.11.0","range-parser": "~1.2.1","safe-buffer": "5.2.1","send": "0.19.0","serve-static": "1.16.0","setprototypeof": "1.2.0","statuses": "2.0.1","type-is": "~1.6.18",43 unmodified lines"node": ">= 0.8"}},"node_modules/finalhandler/node_modules/encodeurl": {"version": "1.0.2","resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz","integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==","license": "MIT","engines": {"node": ">= 0.8"}},"node_modules/fn.name": {"version": "1.1.0","resolved": "https://registry.npmjs.org/fn.name/-/fn.name-1.1.0.tgz",1 unmodified line"license": "MIT"},"node_modules/follow-redirects": {"version": "1.15.9","resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz","integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==","funding": [{"type": "individual",257 unmodified lines}},"node_modules/http-proxy-agent/node_modules/debug": {"version": "4.3.7","resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz","integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==","license": "MIT","optional": true,"dependencies": {"ms": "^2.1.3"},"engines": {"node": ">=6.0"5 unmodified lines}},"node_modules/http-proxy-agent/node_modules/ms": {"version": "2.1.3","resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz","integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==","license": "MIT","optional": true},12 unmodified lines}},"node_modules/https-proxy-agent/node_modules/debug": {"version": "4.3.7","resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz","integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==","license": "MIT","optional": true,"dependencies": {"ms": "^2.1.3"},"engines": {"node": ">=6.0"5 unmodified lines}},"node_modules/https-proxy-agent/node_modules/ms": {"version": "2.1.3","resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz","integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==","license": "MIT","optional": true},242 unmodified lines}},"node_modules/merge-descriptors": {"version": "1.0.3","resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz","integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==","license": "MIT","funding": {"url": "https://github.com/sponsors/sindresorhus"}},"node_modules/methods": {"version": "1.1.2",386 unmodified lines}},"node_modules/path-to-regexp": {"version": "0.1.10","resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.10.tgz","integrity": "sha512-7lf7qcQidTku0Gu3YDPc8DJ1q7OOucfa/BSsIwjuh56VU7katFvuM8hULfkwB3Fns/rsVF7PwPKVw1sl5KQS9w==","license": "MIT"},"node_modules/prebuild-install": {63 unmodified lines"license": "MIT"},"node_modules/pump": {"version": "3.0.1","resolved": "https://registry.npmjs.org/pump/-/pump-3.0.1.tgz","integrity": "sha512-2ynnAmUu45oUSq51AQbeugLkMSKaz8FqVpZ6ykTqzOVkzXe8u/ezkGsYrFJqKZx+D9cVxoDrSbR7CeAwxFa5cQ==","license": "MIT","dependencies": {"end-of-stream": "^1.1.0",143 unmodified lines}},"node_modules/send": {"version": "0.19.0","resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz","integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==","license": "MIT","dependencies": {"debug": "2.6.9",14 unmodified lines"node": ">= 0.8.0"}},"node_modules/send/node_modules/encodeurl": {"version": "1.0.2","resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz","integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==","license": "MIT","engines": {"node": ">= 0.8"}},"node_modules/send/node_modules/ms": {"version": "2.1.3","resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",1 unmodified line"license": "MIT"},"node_modules/serve-static": {"version": "1.16.0","resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.0.tgz","integrity": "sha512-pDLK8zwl2eKaYrs8mrPZBJua4hMplRWJ1tIFksVC3FtBEBnl8dxgeHtsaMS8DhS9i4fLObaon6ABoc4/hQGdPA==","license": "MIT","dependencies": {"encodeurl": "~1.0.2",5 unmodified lines"node": ">= 0.8.0"}},"node_modules/serve-static/node_modules/encodeurl": {"version": "1.0.2","resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz","integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==","license": "MIT","engines": {"node": ">= 0.8"}},"node_modules/serve-static/node_modules/ms": {"version": "2.1.3","resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz","integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==","license": "MIT"},"node_modules/serve-static/node_modules/send": {"version": "0.18.0","resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz","integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==","license": "MIT","dependencies": {"debug": "2.6.9","depd": "2.0.0","destroy": "1.2.0","encodeurl": "~1.0.2","escape-html": "~1.0.3","etag": "~1.8.1","fresh": "0.5.2","http-errors": "2.0.0","mime": "1.6.0","ms": "2.1.3","on-finished": "2.4.1","range-parser": "~1.2.1","statuses": "2.0.1"},"engines": {"node": ">= 0.8.0"}},"node_modules/set-blocking": {"version": "2.0.0","resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz",145 unmodified lines}},"node_modules/socks-proxy-agent/node_modules/debug": {"version": "4.3.7","resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz","integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==","license": "MIT","optional": true,"dependencies": {"ms": "^2.1.3"},"engines": {"node": ">=6.0"5 unmodified lines}},"node_modules/socks-proxy-agent/node_modules/ms": {"version": "2.1.3","resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz","integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==","license": "MIT","optional": true},
123456781 unmodified line101112131415161718192021{"name": "stremio-catalogs-providers","version": "1.0.0","main": "index.js","scripts": {"test": "echo \"Error: no test specified\" && exit 1"},"keywords": [],1 unmodified line"license": "ISC","description": "","dependencies": {"async": "^3.2.6","axios": "^1.7.5","bottleneck": "^2.19.5","cors": "^2.8.5","dotenv": "^16.4.5","express": "^4.19.2","sqlite3": "^5.1.7","winston": "^3.14.2","winston-daily-rotate-file": "^5.0.0"1234567891 unmodified line11121314151617181920{"name": "stremio-tmdb-dice","version": "1.0.0","main": "index.js","scripts": {"start": "node index.js","test": "echo \"Error: no test specified\" && exit 1"},"keywords": [],1 unmodified line"license": "ISC","description": "","dependencies": {"axios": "^1.7.7","cors": "^2.8.5","dotenv": "^16.4.5","express": "^4.20.0","sqlite3": "^5.1.7","winston": "^3.14.2","winston-daily-rotate-file": "^5.0.0"
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171<!DOCTYPE html><html lang="fr"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Configure - Stremio-TMDB-Dic</title> <link rel="stylesheet" href="css/styles.css"></head><body class="dark-mode"> <div class="container"> <div class="dark-mode-toggle" id="dark-mode-toggle">🌞</div> <h1>Stremio TMDB Dice</h1> <div class="form-group"> <label for="language">Language</label> <select id="language"> <option value="">Select your language</option> </select> </div>
<div class="form-group"> <label for="api-key">TMDB API Key (<a href="https://www.themoviedb.org/settings/api" target="_blank" style="color: #007aff;">Get it here</a>)</label> <input type="text" id="tmdb-api-key"> </div>
<div class="form-group"> <label for="rpdb-api-key">RPDB API Key (<a href="https://ratingposterdb.com/api-key" target="_blank" style="color: #007aff;">Get it here</a>)</label> <input type="text" id="rpdb-api-key"> </div>
<div class="form-group"> <label for="fanart-api-key">Fanart API Key (<a href="https://fanart.tv/get-an-api-key" target="_blank" style="color: #007aff;">Get it here</a>)</label> <input type="text" id="fanart-api-key"> </div>
<div class="form-group"> <div class="label-checkbox-group"> <input type="checkbox" id="hide-no-poster"> <label for="hide-no-poster">Hide items without poster</label> </div> <p class="hint">Most of the time it is not quality items that deserve attention that are returned.</p> </div>
<div class="button-group"> <button class="btn install">Install</button> <button class="btn copy-link">Copy link</button> </div> </div>
<div class="modal-overlay" id="modal-overlay"></div> <div class="modal" id="modal"> <div class="modal-header" id="modal-header">Warning</div> <div class="modal-body" id="modal-body">Please fill in all required fields: TMDB API Key and Language.</div> <div class="modal-footer"> <button class="btn btn-error" id="close-modal">OK</button> </div> </div> <div class="notification-success" id="notification-success"> <span>✔</span> <span id="notification-text">Link copied to clipboard!</span> </div>
<script src="js/languages.js"></script> <script> document.addEventListener('DOMContentLoaded', () => { const toggle = document.getElementById('dark-mode-toggle'); toggle.textContent = '🌜';
toggle.addEventListener('click', () => { document.body.classList.toggle('dark-mode'); toggle.textContent = document.body.classList.contains('dark-mode') ? '🌜' : '🌞'; });
function populateLanguageDropdown() { const dropdown = document.getElementById('language'); languages.forEach(lang => { const option = document.createElement('option'); option.value = lang.iso_639_1; option.textContent = lang.english_name + (lang.name ? ` (${lang.name})` : ''); dropdown.appendChild(option); }); } populateLanguageDropdown();
function getConfig() { const tmdbApiKey = document.getElementById('tmdb-api-key').value; const rpdbApiKey = document.getElementById('rpdb-api-key').value; const fanartApiKey = document.getElementById('fanart-api-key').value; const language = document.getElementById('language').value;
if (!tmdbApiKey || !language) { showModal('Warning', 'Please fill in all required fields: TMDB API Key and Language.', 'btn-error'); return null; }
const config = { tmdbApiKey: tmdbApiKey, rpdbApiKey: rpdbApiKey, fanartApiKey: fanartApiKey, language: language, hideNoPoster: document.getElementById('hide-no-poster').checked, }; return config; }
function showModal(headerText, message, buttonClass) { const modal = document.getElementById('modal'); const overlay = document.getElementById('modal-overlay'); const modalHeader = document.getElementById('modal-header'); const modalBody = document.getElementById('modal-body'); const closeModalButton = document.getElementById('close-modal');
modalHeader.textContent = headerText; modalBody.textContent = message; closeModalButton.className = 'btn ' + buttonClass; modal.classList.add('show'); overlay.classList.add('show');
closeModalButton.onclick = () => { modal.classList.remove('show'); overlay.classList.remove('show'); }; }
function showSuccessNotification(message) { const notification = document.getElementById('notification-success'); const notificationText = document.getElementById('notification-text');
notificationText.textContent = message; notification.classList.add('show');
setTimeout(() => { notification.classList.remove('show'); }, 3000); }
function getStremioLink() { const config = getConfig(); if (!config) return; return "stremio://" + window.location.host + "/" + encodeURIComponent(JSON.stringify(config)) + "/manifest.json"; }
function getHttpsLink() { const config = getConfig(); if (!config) return; return "https://" + window.location.host + "/" + encodeURIComponent(JSON.stringify(config)) + "/manifest.json"; }
document.querySelector('.install').addEventListener('click', () => { const installURL = getStremioLink(); if (installURL) { window.location.href = installURL; } });
document.querySelector('.copy-link').addEventListener('click', () => { const copyURL = getHttpsLink(); if (copyURL) { navigator.clipboard.writeText(copyURL).then(() => { showSuccessNotification('Link copied to clipboard!'); }).catch(err => { console.error('Failed to copy the link: ', err); }); } }); }); </script></body></html>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279* { margin: 0; padding: 0; box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;}
body { background-color: #f5f5f7; color: #333; display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: 20px; transition: background-color 0.3s, color 0.3s;}
.container { background-color: #fff; border-radius: 16px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1); padding: 40px; max-width: 400px; width: 100%; transition: background-color 0.3s; position: relative;}
.dark-mode-toggle { position: absolute; top: 10px; right: 10px; cursor: pointer; font-size: 24px; transition: transform 0.3s;}
.dark-mode-toggle:hover { transform: scale(1.1);}
h1 { font-size: 24px; margin-bottom: 20px; text-align: center;}
.toggle-dark-mode { display: flex; align-items: center; margin-bottom: 20px;}
.toggle-dark-mode label { margin-left: 8px;}
.form-group { margin-bottom: 20px;}
.label-checkbox-group { display: flex; align-items: center; margin-bottom: 5px;}
label { font-weight: 600; color: inherit;}
input[type="text"],select { width: 100%; padding: 12px; border-radius: 8px; border: 1px solid #ddd; font-size: 14px; background-color: #f5f5f7; transition: border-color 0.3s, background-color 0.3s; margin-top: 8px;}
input[type="text"]:focus,select:focus { border-color: #007aff; outline: none;}
input[type="checkbox"] { appearance: none; width: 20px; height: 20px; background-color: #f5f5f7; border: 2px solid #ddd; border-radius: 5px; display: inline-block; position: relative; cursor: pointer; transition: background-color 0.3s, border-color 0.3s; margin-right: 10px;}
input[type="checkbox"]:checked { background-color: #007aff; border-color: #007aff;}
input[type="checkbox"]:checked::after { content: ''; position: absolute; left: 50%; top: 50%; width: 6px; height: 12px; border: solid white; border-width: 0 2px 2px 0; transform: translate(-50%, -50%) rotate(45deg);}
.hint { font-size: 12px; color: #888; margin-top: 4px; line-height: 1.4;}
.button-group { display: flex; justify-content: space-between;}
.btn { background-color: #007aff; color: #fff; border: none; padding: 12px 24px; border-radius: 8px; cursor: pointer; font-size: 14px; transition: background-color 0.3s;}
.btn:hover { background-color: #005bb5;}
.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background-color: #fff; border-radius: 16px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1); width: 300px; padding: 20px; text-align: center; z-index: 1000; display: none; transition: opacity 0.3s ease, transform 0.3s ease;}
.modal.show { display: block; opacity: 1;}
.modal-header { font-size: 18px; margin-bottom: 10px; font-weight: bold;}
.modal-body { font-size: 14px; color: #333; margin-bottom: 20px;}
.modal-footer { display: flex; justify-content: center;}
.modal-footer .btn { width: 80px;}
.modal-footer .btn-error { background-color: #d9534f;}
.modal-footer .btn-success { background-color: #28a745;}
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.4); backdrop-filter: blur(5px); z-index: 999; display: none;}
.modal-overlay.show { display: block;}
body.dark-mode .modal { background-color: #2c2c2e; color: #f5f5f7;}
body.dark-mode .modal-body { color: #ddd;}
.notification-success { position: fixed; top: 20px; right: 20px; background-color: #28a745; color: white; padding: 10px 20px; border-radius: 8px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1); display: flex; align-items: center; gap: 8px; opacity: 0; transition: opacity 0.3s ease, transform 0.3s ease; z-index: 1000;}
.notification-success.show { opacity: 1;}
body.dark-mode { background-color: #1c1c1e; color: #f5f5f7;}
body.dark-mode .container { background-color: #2c2c2e; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);}
body.dark-mode input[type="text"],body.dark-mode select { background-color: #3a3a3c; border: 1px solid #505052; color: #f5f5f7;}
body.dark-mode input[type="checkbox"] { background-color: #3a3a3c; border-color: #505052;}
body.dark-mode .hint { color: #aaa;}
body.dark-mode .btn { background-color: #007aff;}
body.dark-mode .btn:hover { background-color: #005bb5;} 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202const languages = [ {iso_639_1: "bi", english_name: "Bislama", name: "" }, {iso_639_1: "cs", english_name: "Czech", name: "Český" }, {iso_639_1: "ba", english_name: "Bashkir", name: "" }, {iso_639_1: "ae", english_name: "Avestan", name: "" }, {iso_639_1: "av", english_name: "Avaric", name: "" }, {iso_639_1: "de", english_name: "German", name: "Deutsch" }, {iso_639_1: "mt", english_name: "Maltese", name: "Malti" }, {iso_639_1: "om", english_name: "Oromo", name: "" }, {iso_639_1: "rm", english_name: "Raeto-Romance", name: "" }, {iso_639_1: "so", english_name: "Somali", name: "Somali" }, {iso_639_1: "ts", english_name: "Tsonga", name: "" }, {iso_639_1: "vi", english_name: "Vietnamese", name: "Tiếng Việt" }, {iso_639_1: "gn", english_name: "Guarani", name: "" }, {iso_639_1: "ig", english_name: "Igbo", name: "" }, {iso_639_1: "it", english_name: "Italian", name: "Italiano" }, {iso_639_1: "ki", english_name: "Kikuyu", name: "" }, {iso_639_1: "ku", english_name: "Kurdish", name: "" }, {iso_639_1: "la", english_name: "Latin", name: "Latin" }, {iso_639_1: "ln", english_name: "Lingala", name: "" }, {iso_639_1: "lb", english_name: "Letzeburgesch", name: "" }, {iso_639_1: "ny", english_name: "Chichewa; Nyanja", name: "" }, {iso_639_1: "pl", english_name: "Polish", name: "Polski" }, {iso_639_1: "si", english_name: "Sinhalese", name: "සිංහල" }, {iso_639_1: "to", english_name: "Tonga", name: "" }, {iso_639_1: "az", english_name: "Azerbaijani", name: "Azərbaycan" }, {iso_639_1: "ce", english_name: "Chechen", name: "" }, {iso_639_1: "cu", english_name: "Slavic", name: "" }, {iso_639_1: "da", english_name: "Danish", name: "Dansk" }, {iso_639_1: "hz", english_name: "Herero", name: "" }, {iso_639_1: "ie", english_name: "Interlingue", name: "" }, {iso_639_1: "rw", english_name: "Kinyarwanda", name: "Kinyarwanda" }, {iso_639_1: "mi", english_name: "Maori", name: "" }, {iso_639_1: "no", english_name: "Norwegian", name: "Norsk" }, {iso_639_1: "pi", english_name: "Pali", name: "" }, {iso_639_1: "sk", english_name: "Slovak", name: "Slovenčina" }, {iso_639_1: "se", english_name: "Northern Sami", name: "" }, {iso_639_1: "sm", english_name: "Samoan", name: "" }, {iso_639_1: "uk", english_name: "Ukrainian", name: "Український" }, {iso_639_1: "en", english_name: "English", name: "English" }, {iso_639_1: "ay", english_name: "Aymara", name: "" }, {iso_639_1: "ca", english_name: "Catalan", name: "Català" }, {iso_639_1: "eo", english_name: "Esperanto", name: "Esperanto" }, {iso_639_1: "ha", english_name: "Hausa", name: "Hausa" }, {iso_639_1: "ho", english_name: "Hiri Motu", name: "" }, {iso_639_1: "hu", english_name: "Hungarian", name: "Magyar" }, {iso_639_1: "io", english_name: "Ido", name: "" }, {iso_639_1: "ii", english_name: "Yi", name: "" }, {iso_639_1: "kn", english_name: "Kannada", name: "?????" }, {iso_639_1: "kv", english_name: "Komi", name: "" }, {iso_639_1: "li", english_name: "Limburgish", name: "" }, {iso_639_1: "oj", english_name: "Ojibwa", name: "" }, {iso_639_1: "ru", english_name: "Russian", name: "Pусский" }, {iso_639_1: "sr", english_name: "Serbian", name: "Srpski" }, {iso_639_1: "sv", english_name: "Swedish", name: "svenska" }, {iso_639_1: "ty", english_name: "Tahitian", name: "" }, {iso_639_1: "zu", english_name: "Zulu", name: "isiZulu" }, {iso_639_1: "ka", english_name: "Georgian", name: "ქართული" }, {iso_639_1: "ch", english_name: "Chamorro", name: "Finu' Chamorro" }, {iso_639_1: "be", english_name: "Belarusian", name: "беларуская мова" }, {iso_639_1: "br", english_name: "Breton", name: "" }, {iso_639_1: "kw", english_name: "Cornish", name: "" }, {iso_639_1: "fi", english_name: "Finnish", name: "suomi" }, {iso_639_1: "sh", english_name: "Serbo-Croatian", name: "" }, {iso_639_1: "nn", english_name: "Norwegian Nynorsk", name: "" }, {iso_639_1: "tt", english_name: "Tatar", name: "" }, {iso_639_1: "tg", english_name: "Tajik", name: "" }, {iso_639_1: "vo", english_name: "Volapük", name: "" }, {iso_639_1: "ps", english_name: "Pushto", name: "پښتو" }, {iso_639_1: "mk", english_name: "Macedonian", name: "" }, {iso_639_1: "fr", english_name: "French", name: "Français" }, {iso_639_1: "bm", english_name: "Bambara", name: "Bamanankan" }, {iso_639_1: "eu", english_name: "Basque", name: "euskera" }, {iso_639_1: "fj", english_name: "Fijian", name: "" }, {iso_639_1: "id", english_name: "Indonesian", name: "Bahasa indonesia" }, {iso_639_1: "mg", english_name: "Malagasy", name: "" }, {iso_639_1: "na", english_name: "Nauru", name: "" }, {iso_639_1: "xx", english_name: "No Language", name: "No Language" }, {iso_639_1: "qu", english_name: "Quechua", name: "" }, {iso_639_1: "sq", english_name: "Albanian", name: "shqip" }, {iso_639_1: "ti", english_name: "Tigrinya", name: "" }, {iso_639_1: "tw", english_name: "Twi", name: "" }, {iso_639_1: "wa", english_name: "Walloon", name: "" }, {iso_639_1: "ab", english_name: "Abkhazian", name: "" }, {iso_639_1: "bs", english_name: "Bosnian", name: "Bosanski" }, {iso_639_1: "af", english_name: "Afrikaans", name: "Afrikaans" }, {iso_639_1: "an", english_name: "Aragonese", name: "" }, {iso_639_1: "fy", english_name: "Frisian", name: "" }, {iso_639_1: "gu", english_name: "Gujarati", name: "" }, {iso_639_1: "ik", english_name: "Inupiaq", name: "" }, {iso_639_1: "ja", english_name: "Japanese", name: "日本語" }, {iso_639_1: "ko", english_name: "Korean", name: "한국어/조선말" }, {iso_639_1: "lg", english_name: "Ganda", name: "" }, {iso_639_1: "nl", english_name: "Dutch", name: "Nederlands" }, {iso_639_1: "os", english_name: "Ossetian; Ossetic", name: "" }, {iso_639_1: "el", english_name: "Greek", name: "ελληνικά" }, {iso_639_1: "bn", english_name: "Bengali", name: "বাংলা" }, {iso_639_1: "cr", english_name: "Cree", name: "" }, {iso_639_1: "km", english_name: "Khmer", name: "" }, {iso_639_1: "lo", english_name: "Lao", name: "" }, {iso_639_1: "nd", english_name: "Ndebele", name: "" }, {iso_639_1: "ne", english_name: "Nepali", name: "" }, {iso_639_1: "sc", english_name: "Sardinian", name: "" }, {iso_639_1: "sw", english_name: "Swahili", name: "Kiswahili" }, {iso_639_1: "tl", english_name: "Tagalog", name: "" }, {iso_639_1: "ur", english_name: "Urdu", name: "اردو" }, {iso_639_1: "ee", english_name: "Ewe", name: "Èʋegbe" }, {iso_639_1: "aa", english_name: "Afar", name: "" }, {iso_639_1: "co", english_name: "Corsican", name: "" }, {iso_639_1: "et", english_name: "Estonian", name: "Eesti" }, {iso_639_1: "is", english_name: "Icelandic", name: "Íslenska" }, {iso_639_1: "ks", english_name: "Kashmiri", name: "" }, {iso_639_1: "kr", english_name: "Kanuri", name: "" }, {iso_639_1: "ky", english_name: "Kirghiz", name: "??????" }, {iso_639_1: "kj", english_name: "Kuanyama", name: "" }, {iso_639_1: "nr", english_name: "Ndebele", name: "" }, {iso_639_1: "or", english_name: "Oriya", name: "" }, {iso_639_1: "wo", english_name: "Wolof", name: "Wolof" }, {iso_639_1: "za", english_name: "Zhuang", name: "" }, {iso_639_1: "ar", english_name: "Arabic", name: "العربية" }, {iso_639_1: "cv", english_name: "Chuvash", name: "" }, {iso_639_1: "fo", english_name: "Faroese", name: "" }, {iso_639_1: "hr", english_name: "Croatian", name: "Hrvatski" }, {iso_639_1: "ms", english_name: "Malay", name: "Bahasa melayu" }, {iso_639_1: "nb", english_name: "Norwegian Bokmål", name: "Bokmål" }, {iso_639_1: "rn", english_name: "Rundi", name: "Kirundi" }, {iso_639_1: "sn", english_name: "Shona", name: "" }, {iso_639_1: "st", english_name: "Sotho", name: "" }, {iso_639_1: "tr", english_name: "Turkish", name: "Türkçe" }, {iso_639_1: "am", english_name: "Amharic", name: "" }, {iso_639_1: "fa", english_name: "Persian", name: "فارسی" }, {iso_639_1: "hy", english_name: "Armenian", name: "" }, {iso_639_1: "pa", english_name: "Punjabi", name: "ਪੰਜਾਬੀ" }, {iso_639_1: "as", english_name: "Assamese", name: "" }, {iso_639_1: "ia", english_name: "Interlingua", name: "" }, {iso_639_1: "lv", english_name: "Latvian", name: "Latviešu" }, {iso_639_1: "lu", english_name: "Luba-Katanga", name: "" }, {iso_639_1: "mr", english_name: "Marathi", name: "" }, {iso_639_1: "mn", english_name: "Mongolian", name: "" }, {iso_639_1: "pt", english_name: "Portuguese", name: "Português" }, {iso_639_1: "th", english_name: "Thai", name: "ภาษาไทย" }, {iso_639_1: "tk", english_name: "Turkmen", name: "" }, {iso_639_1: "ve", english_name: "Venda", name: "" }, {iso_639_1: "dv", english_name: "Divehi", name: "" }, {iso_639_1: "gv", english_name: "Manx", name: "" }, {iso_639_1: "kl", english_name: "Kalaallisut", name: "" }, {iso_639_1: "kk", english_name: "Kazakh", name: "қазақ" }, {iso_639_1: "lt", english_name: "Lithuanian", name: "Lietuvių" }, {iso_639_1: "my", english_name: "Burmese", name: "" }, {iso_639_1: "sl", english_name: "Slovenian", name: "Slovenščina" }, {iso_639_1: "sd", english_name: "Sindhi", name: "" }, {iso_639_1: "cn", english_name: "Cantonese", name: "广州话 / 廣州話" }, {iso_639_1: "hi", english_name: "Hindi", name: "हिन्दी" }, {iso_639_1: "cy", english_name: "Welsh", name: "Cymraeg" }, {iso_639_1: "ht", english_name: "Haitian; Haitian Creole", name: "" }, {iso_639_1: "iu", english_name: "Inuktitut", name: "" }, {iso_639_1: "jv", english_name: "Javanese", name: "" }, {iso_639_1: "mh", english_name: "Marshall", name: "" }, {iso_639_1: "sa", english_name: "Sanskrit", name: "" }, {iso_639_1: "ss", english_name: "Swati", name: "" }, {iso_639_1: "te", english_name: "Telugu", name: "తెలుగు" }, {iso_639_1: "kg", english_name: "Kongo", name: "" }, {iso_639_1: "ml", english_name: "Malayalam", name: "" }, {iso_639_1: "uz", english_name: "Uzbek", name: "ozbek" }, {iso_639_1: "sg", english_name: "Sango", name: "" }, {iso_639_1: "xh", english_name: "Xhosa", name: "" }, {iso_639_1: "es", english_name: "Spanish", name: "Español" }, {iso_639_1: "su", english_name: "Sundanese", name: "" }, {iso_639_1: "ug", english_name: "Uighur", name: "" }, {iso_639_1: "yi", english_name: "Yiddish", name: "" }, {iso_639_1: "yo", english_name: "Yoruba", name: "Èdè Yorùbá" }, {iso_639_1: "zh", english_name: "Mandarin", name: "普通话" }, {iso_639_1: "he", english_name: "Hebrew", name: "עִבְרִית" }, {iso_639_1: "bo", english_name: "Tibetan", name: "" }, {iso_639_1: "ak", english_name: "Akan", name: "" }, {iso_639_1: "mo", english_name: "Moldavian", name: "" }, {iso_639_1: "ng", english_name: "Ndonga", name: "" }, {iso_639_1: "dz", english_name: "Dzongkha", name: "" }, {iso_639_1: "ff", english_name: "Fulah", name: "Fulfulde" }, {iso_639_1: "gd", english_name: "Gaelic", name: "" }, {iso_639_1: "ga", english_name: "Irish", name: "Gaeilge" }, {iso_639_1: "gl", english_name: "Galician", name: "Galego" }, {iso_639_1: "nv", english_name: "Navajo", name: "" }, {iso_639_1: "oc", english_name: "Occitan", name: "" }, {iso_639_1: "ro", english_name: "Romanian", name: "Română" }, {iso_639_1: "ta", english_name: "Tamil", name: "தமிழ்" }, {iso_639_1: "tn", english_name: "Tswana", name: "" }, {iso_639_1: "bg", english_name: "Bulgarian", name: "български език" }];
languages.sort((a, b) => { const nameA = a.english_name.toUpperCase(); const nameB = b.english_name.toUpperCase(); if (nameA < nameB) { return -1; } if (nameA > nameB) { return 1; } return 0; });12345678910111213141516171819202122232425262728293031323334353637383940const axios = require('axios');const log = require('../helpers/logger');
const getFanartPoster = async (tmdbId, preferredLang, fanartApiKey) => { try { const url = `https://webservice.fanart.tv/v3/movies/${tmdbId}/?api_key=${fanartApiKey}`; log.debug(`Fetching Fanart logos from: ${url}`);
const response = await axios.get(url); const logos = response.data.hdmovielogo || []; log.debug(`Logos fetched: ${JSON.stringify(logos)}`);
const preferredLangLogos = logos.filter(logo => logo.lang === preferredLang); log.debug(`Logos in preferred language (${preferredLang}): ${JSON.stringify(preferredLangLogos)}`);
const bestLogoInPreferredLang = preferredLangLogos.sort((a, b) => b.likes - a.likes)[0]; log.debug(`Best logo in preferred language: ${JSON.stringify(bestLogoInPreferredLang)}`);
if (!bestLogoInPreferredLang) { const englishLogos = logos.filter(logo => logo.lang === 'en'); log.debug(`Logos in English: ${JSON.stringify(englishLogos)}`);
const bestLogoInEnglish = englishLogos.sort((a, b) => b.likes - a.likes)[0]; log.debug(`Best logo in English: ${JSON.stringify(bestLogoInEnglish)}`);
return bestLogoInEnglish ? bestLogoInEnglish.url.replace('http://', 'https://') : ''; }
const bestLogoUrl = bestLogoInPreferredLang.url.replace('http://', 'https://'); log.debug(`Best logo URL: ${bestLogoUrl}`); return bestLogoUrl; } catch (error) { log.error(`Error fetching logos from Fanart.tv for TMDB ID ${tmdbId}:`, error.message); return ''; }};
module.exports = { getFanartPoster };12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576const axios = require('axios');const log = require('../helpers/logger');const { setCachedPoster, getCachedPoster } = require('../helpers/cache');
const getRpdbPoster = (type, id, language, rpdbkey) => { const tier = rpdbkey.split("-")[0]; const lang = language.split("-")[0]; const baseUrl = `https://api.ratingposterdb.com/${rpdbkey}/tmdb/poster-default/${type}-${id}.jpg`;
return (tier === "t0" || tier === "t1") ? baseUrl : `${baseUrl}&lang=${lang}`;};
const posterCacheQueue = new Set();const cachedPosters = new Set();
const getPosterUrl = async (content, rpdbApiKey) => { const posterId = `poster:${content.id}`; if (rpdbApiKey) { const cachedPoster = await getCachedPoster(posterId); if (cachedPoster) { log.debug(`Using cached poster URL for id ${posterId}`); return cachedPoster.poster_url; } }
let posterUrl; if (rpdbApiKey) { const rpdbImage = getRpdbPoster('movie', content.id, 'fr', rpdbApiKey); log.debug(`Fetching RPDB poster from URL: ${rpdbImage}`); try { const response = await axios.head(rpdbImage); if (response.status === 200) { log.debug(`RPDB poster found for id ${posterId}`); posterUrl = rpdbImage;
if (!cachedPosters.has(posterId)) { posterCacheQueue.add({ id: posterId, url: posterUrl }); cachedPosters.add(posterId); } } else { throw new Error('Not found'); } } catch (error) { log.warn(`Error fetching RPDB poster: ${error.message}. Falling back to TMDB poster.`); posterUrl = `https://image.tmdb.org/t/p/w500${content.poster_path}`; } } else { posterUrl = `https://image.tmdb.org/t/p/w500${content.poster_path}`; } return posterUrl;};
const cachePosters = async () => { for (const { id, url } of posterCacheQueue) { try { await setCachedPoster(id, url); } catch (error) { log.error(`Failed to cache poster id ${id}: ${error.message}`); } } posterCacheQueue.clear(); cachedPosters.clear();};
module.exports = { getRpdbPoster, getPosterUrl, cachePosters};123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277const axios = require('axios');const log = require('../helpers/logger');const { genresDb, cacheDb } = require('../helpers/db');const { getCatalogCache, setCatalogCache } = require('../helpers/cache');const queue = require('../helpers/ratelimit');const { getFanartPoster } = require('./fanart');const { getPosterUrl, cachePosters } = require('./rpdb');
const TMDB_BASE_URL = 'https://api.themoviedb.org/3';
const getGenreId = (mediaType, genreName) => new Promise((resolve, reject) => { const query = `SELECT genre_id FROM genres WHERE media_type = ? AND genre_name = ?`; genresDb.get(query, [mediaType, genreName], (err, row) => { if (err) return reject(err); resolve(row ? row.genre_id : null); }); });
const buildQueryParams = (params, mediaType) => { const queryParams = [];
if (params.year) { const [startYear, endYear] = params.year.split('-'); if (startYear && endYear) { if (mediaType === 'movie') { queryParams.push(`primary_release_date.gte=${startYear}-01-01`); queryParams.push(`primary_release_date.lte=${endYear}-12-31`); } else if (mediaType === 'tv') { queryParams.push(`first_air_date.gte=${startYear}-01-01`); queryParams.push(`first_air_date.lte=${endYear}-12-31`); } } }
if (params.rating) { const [minRating, maxRating] = params.rating.split('-'); if (minRating && maxRating) { queryParams.push(`vote_average.gte=${minRating}`); queryParams.push(`vote_average.lte=${maxRating}`); } }
Object.entries(params).forEach(([key, value]) => { if (value !== undefined && value !== null && !['year', 'rating', 'hideNoPoster', 'skip', 'genre'].includes(key)) { queryParams.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`); } });
return queryParams.join('&');};
const fetchData = async (type, id, extra, cacheDuration = '3d', tmdbApiKey, rpdbApiKey, fanartApiKey) => { try { const mediaType = type === 'series' ? 'tv' : type; const language = extra.language || 'default'; const genre = extra.genre || null; const year = extra.year || null; const rating = extra.rating || null; const skip = extra.skip || 0;
const cacheKey = `catalog_${mediaType}_${id}_${JSON.stringify(extra)}_lang_${language}_genre_${genre}_year_${year}_rating_${rating}`; log.debug(`Cache key generated: ${cacheKey}`);
const cachedData = await getCatalogCache(cacheKey, cacheDuration); if (cachedData) { log.info(`Using cached data for key: ${cacheKey}`); return cachedData.value; }
log.debug(`Skip value: ${skip}`);
const initialQueryParams = buildQueryParams({ ...extra, page: 1 }, mediaType); const initialUrl = `${TMDB_BASE_URL}/discover/${mediaType}?api_key=${tmdbApiKey}&${initialQueryParams}`; log.debug(`Fetching initial data from TMDB to get total_pages: ${initialUrl}`);
const initialResponse = await axios.get(initialUrl); let total_pages = initialResponse.data.total_pages; log.info(`Total pages available: ${total_pages}`);
if (total_pages > 500) { total_pages = 500; log.warn(`Capping total pages at 500 (TMDB limitation)`); }
const fetchedPages = await getFetchedPages(genre, year, rating, mediaType, cacheDb); log.debug(`Fetched pages: ${fetchedPages}`);
let availablePages = Array.from({ length: total_pages }, (_, i) => i + 1).filter(page => !fetchedPages.includes(page));
if (availablePages.length === 0) { log.warn(`All pages have been fetched for the current filters.`); return []; }
const randomPage = availablePages[Math.floor(Math.random() * availablePages.length)]; log.debug(`Random page selected: ${randomPage}`);
const queryParams = buildQueryParams({ ...extra, page: randomPage }, mediaType); const url = `${TMDB_BASE_URL}/discover/${mediaType}?api_key=${tmdbApiKey}&${queryParams}`; log.debug(`Fetching from TMDB: ${url}`);
return new Promise((resolve, reject) => { queue.push({ fn: async () => { try { const response = await axios.get(url); const results = response.data.results; log.info(`Fetched ${results.length} results from TMDB on page ${randomPage}`);
const metas = await Promise.all(results.map(async item => { const genreNames = item.genre_ids && item.genre_ids.length > 0 ? await getGenreNames(item.genre_ids, mediaType, language) : []; if (item.genre_ids && item.genre_ids.length === 0) { log.warn(`No genre IDs for item ${item.id}`); } let logo = null; if (fanartApiKey) { logo = await getFanartPoster(item.id, language, fanartApiKey); } const posterUrl = await getPosterUrl(item, rpdbApiKey); log.debug(`Poster URL for item ${item.id}: ${posterUrl}`); return { id: item.id.toString(), name: item.title || item.name, poster: posterUrl, banner: item.backdrop_path ? `https://image.tmdb.org/t/p/original${item.backdrop_path}` : null, logo: logo || null, type: mediaType, description: item.overview, releaseInfo: item.release_date || item.first_air_date, imdbRating: item.vote_average ? item.vote_average.toFixed(1) : null, genres: genreNames }; }));
setCatalogCache(cacheKey, metas, cacheDuration, randomPage, skip, genre, year, rating, mediaType); await cachePosters(); resolve(metas); } catch (error) { log.error(`TMDB fetch error: ${error.message}`); reject(new Error('Failed to fetch data from TMDB')); } } }); }); } catch (error) { log.error(`Error in fetchData: ${error.message}`); throw error; }};
const getFetchedPages = (genre, year, rating, mediaType, cacheDb) => { return new Promise((resolve, reject) => { const decodedGenre = decodeURIComponent(genre || 'undefined'); const decodedYear = decodeURIComponent(year || 'undefined'); const decodedRating = decodeURIComponent(rating || 'undefined');
cacheDb.all( `SELECT page FROM cache WHERE genre = ? AND year = ? AND rating = ? AND mediaType = ?`, [decodedGenre, decodedYear, decodedRating, mediaType], (err, rows) => { if (err) { log.error(`Error querying cache for fetched pages: ${err.message}`); reject(err); } else { const fetchedPages = rows.map(row => row.page); resolve(fetchedPages); } } ); });}; const getGenreNames = (genreIds, mediaType, language) => new Promise((resolve, reject) => { if (!genreIds || genreIds.length === 0) { log.warn(`No genre IDs provided for ${mediaType}`); return resolve([]); }
const placeholders = genreIds.map(() => '?').join(','); const sql = `SELECT genre_name FROM genres WHERE genre_id IN (${placeholders}) AND media_type = ? AND language = ?`;
genresDb.all(sql, [...genreIds, mediaType, language], (err, rows) => { if (err) { log.error(`Error fetching genre names from database: ${err.message}`); resolve([]); } else { resolve(rows.map(row => row.genre_name)); } }); });
const fetchGenres = async (type, language, tmdbApiKey = TMDB_API_KEY) => { const mediaType = type === 'series' ? 'tv' : 'movie'; const endpoint = `/genre/${mediaType}/list`;
try { const response = await axios.get(`${TMDB_BASE_URL}${endpoint}`, { params: { api_key: tmdbApiKey, language } }); log.debug(`Genres retrieved for ${type} (${language})`); return response.data.genres; } catch (error) { log.error(`Error fetching genres from TMDB: ${error.message}`); throw error; }};
const storeGenresInDb = (genres, mediaType, language) => new Promise((resolve, reject) => { genresDb.serialize(() => { genresDb.run('BEGIN TRANSACTION'); const insertGenre = genresDb.prepare(` INSERT INTO genres (genre_id, genre_name, media_type, language) VALUES (?, ?, ?, ?) ON CONFLICT DO NOTHING; `);
genres.forEach((genre, index) => { insertGenre.run(genre.id, genre.name, mediaType, language, (err) => { if (err) { log.error(`Error inserting genre: ${err.message}`); genresDb.run('ROLLBACK'); reject(err); return; }
if (index === genres.length - 1) { insertGenre.finalize(); genresDb.run('COMMIT'); log.info(`Genres stored for ${mediaType} (${language})`); resolve(); } }); }); }); });
const checkGenresExistForLanguage = async (language) => new Promise((resolve, reject) => { log.debug(`Checking genres for ${language}`); genresDb.get( `SELECT 1 FROM genres WHERE language = ? LIMIT 1`, [language], (err, row) => err ? reject(err) : resolve(!!row) ); });
const fetchAndStoreGenres = async (language, tmdbApiKey = TMDB_API_KEY) => { try { const movieGenres = await fetchGenres('movie', language, tmdbApiKey); const tvGenres = await fetchGenres('series', language, tmdbApiKey);
await storeGenresInDb(movieGenres, 'movie', language); await storeGenresInDb(tvGenres, 'tv', language);
log.info(`Genres fetched and stored for ${language}`); } catch (error) { log.error(`Error fetching/storing genres: ${error.message}`); }};
module.exports = { fetchData, getGenreId, checkGenresExistForLanguage, fetchAndStoreGenres };123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138const fs = require('fs');const path = require('path');const axios = require('axios');const { cacheDb } = require('./db');const log = require('./logger');const baseUrl = process.env.BASE_URL || 'http://localhost:7000';
const DEFAULT_CATALOG_CACHE_DURATION = process.env.CATALOG_CONTENT_CACHE_DURATION || '3d';const DEFAULT_RPDB_POSTER_CACHE_DURATION = process.env.RPDB_POSTER_CACHE_DURATION || '3d';
const posterDirectory = path.join(__dirname, '../../db/rpdbPosters');
if (!fs.existsSync(posterDirectory)) { fs.mkdirSync(posterDirectory, { recursive: true });}
const formatFileName = (posterId) => { return posterId.replace(/[^a-zA-Z0-9-_]/g, '_');};
const cacheDurationToSeconds = (duration) => { const match = duration.match(/^(\d+)([dh])$/); if (!match) throw new Error('Invalid cache duration format');
const [ , value, unit ] = match; const number = parseInt(value, 10);
switch (unit) { case 'd': return number * 86400; case 'h': return number * 3600; default: throw new Error('Invalid cache duration unit'); }};
const setCatalogCache = (key, value, duration = DEFAULT_CATALOG_CACHE_DURATION, page = 1, skip = 0, genre = null, year = null, rating = null, mediaType = null) => { try { genre = genre === null ? "undefined" : genre; year = year === null ? "undefined" : year; rating = rating === null ? "undefined" : rating;
const durationInSeconds = cacheDurationToSeconds(duration); const expireTime = Math.floor(Date.now() / 1000) + durationInSeconds;
const query = `INSERT OR REPLACE INTO cache (key, value, timestamp, page, skip, genre, year, rating, mediaType) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`; cacheDb.run(query, [key, JSON.stringify(value), expireTime, page, skip, genre, year, rating, mediaType], (err) => { if (err) { log.error(`Failed to set cache for key ${key}: ${err.message}`); } else { log.debug(`Cache set for key ${key} with duration ${duration}`); } }); } catch (error) { log.error(`Error in setting cache: ${error.message}`); }};
const getCatalogCache = (key, cacheDuration = DEFAULT_CATALOG_CACHE_DURATION) => { const cacheDurationInSeconds = cacheDurationToSeconds(cacheDuration);
return new Promise((resolve, reject) => { cacheDb.get( `SELECT value, timestamp, page, skip, genre, year, rating, mediaType FROM cache WHERE key = ?`, [key], (err, row) => { if (err) { log.error(`Error retrieving cache for key ${key}: ${err.message}`); return reject(err); } if (!row) { log.debug(`Cache miss for key ${key}`); return resolve(null); }
const isCacheValid = (Date.now() / 1000 - row.timestamp) < cacheDurationInSeconds; if (isCacheValid) { log.debug(`Cache hit for key ${key}`); resolve({ value: JSON.parse(row.value), page: row.page, skip: row.skip, genre: row.genre, year: row.year, rating: row.rating, mediaType: row.mediaType }); } else { log.debug(`Cache expired for key ${key}`); resolve(null); } } ); });};
const getCachedPoster = async (posterId) => { const formattedPosterId = formatFileName(posterId); const filePath = path.join(posterDirectory, `${formattedPosterId}.jpg`); const cacheDurationInSeconds = cacheDurationToSeconds(DEFAULT_RPDB_POSTER_CACHE_DURATION);
if (fs.existsSync(filePath)) { const stats = fs.statSync(filePath); const fileAgeInSeconds = (Date.now() - stats.mtimeMs) / 1000;
if (fileAgeInSeconds < cacheDurationInSeconds) { const posterUrl = `${baseUrl}/poster/${formattedPosterId}.jpg`; log.debug(`Cache hit for poster id ${posterId}, serving from ${posterUrl}`); return { poster_url: posterUrl }; } else { log.debug(`Cache expired for poster id ${posterId}`); fs.unlinkSync(filePath); // Supprimer le fichier expiré } } else { log.debug(`Cache miss for poster id ${posterId}`); }
return null;};
const setCachedPoster = async (posterId, posterUrl) => { const formattedPosterId = formatFileName(posterId); const filePath = path.join(posterDirectory, `${formattedPosterId}.jpg`);
try { const response = await axios.get(posterUrl, { responseType: 'arraybuffer' }); fs.writeFileSync(filePath, response.data); log.debug(`Poster id ${posterId} cached at ${filePath}`); } catch (error) { log.error(`Error caching poster id ${posterId} from URL ${posterUrl}: ${error.message}`); throw error; }};
module.exports = { setCatalogCache, getCatalogCache, setCachedPoster, getCachedPoster};123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172const fs = require('fs');const sqlite3 = require('sqlite3').verbose();const log = require('./logger');const path = require('path');
const dbDir = path.join(__dirname, '../../db');
if (!fs.existsSync(dbDir)) { fs.mkdirSync(dbDir, { recursive: true }); log.debug('Database directory created');}
const createDatabase = (dbPath, dbName) => { return new sqlite3.Database(dbPath, (err) => { if (err) { log.error(`Failed to connect to ${dbName}: ${err.message}`); } else { log.debug(`Connected to ${dbName}`); } });};
const genresDb = createDatabase(path.join(dbDir, 'genres.db'), 'genres.db');const cacheDb = createDatabase(path.join(dbDir, 'cache.db'), 'cache.db');
const createTable = (db, query, tableName) => { db.run(query, (err) => { if (err) { log.error(`Error creating ${tableName} table: ${err.message}`); } else { log.debug(`${tableName} table is ready`); } });};
genresDb.serialize(() => { createTable( genresDb, `CREATE TABLE IF NOT EXISTS genres ( genre_id INTEGER, genre_name TEXT, media_type TEXT, language TEXT, PRIMARY KEY (genre_id, media_type, language), UNIQUE (genre_id, media_type, language) )`, 'genres' );});
cacheDb.serialize(() => { createTable( cacheDb, `CREATE TABLE IF NOT EXISTS cache ( key TEXT PRIMARY KEY, value TEXT, timestamp INTEGER, page INTEGER, skip INTEGER, genre TEXT, year TEXT, rating TEXT, mediaType TEXT )`, 'cache' );});
module.exports = { genresDb, cacheDb};1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465const winston = require('winston');const DailyRotateFile = require('winston-daily-rotate-file');const path = require('path');
winston.addColors({ error: 'red', warn: 'yellow', info: 'blue', debug: 'green'});
const uppercaseLevelFormat = winston.format((info) => { info.level = info.level.toUpperCase(); return info;})();
const LOG_LEVEL = process.env.LOG_LEVEL || 'info';const LOG_FILE_PATH = path.join(__dirname, '../../log/application-%DATE%.log');const MAX_FILES = process.env.LOG_INTERVAL_DELETION || '3d';
const log = winston.createLogger({ level: LOG_LEVEL, format: winston.format.combine( uppercaseLevelFormat, winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }), winston.format.printf(({ level, message, timestamp }) => { return `[${timestamp}] [${level}]: ${message}`; }) ), transports: [ new winston.transports.Console({ format: winston.format.combine( winston.format.colorize(), winston.format.printf(({ level, message, timestamp }) => { return `[${timestamp}] [${level}]: ${message}`; }) ) }), new DailyRotateFile({ filename: LOG_FILE_PATH, datePattern: 'YYYY-MM-DD', maxSize: '20m', maxFiles: MAX_FILES }) ]});
log.exceptions.handle( new DailyRotateFile({ filename: path.join(__dirname, '../../log/exceptions-%DATE%.log'), datePattern: 'YYYY-MM-DD', maxSize: '20m', maxFiles: '30d' }));
process.on('unhandledRejection', (reason, promise) => { log.error(`Unhandled Rejection at: ${promise}, reason: ${reason}`);});
log.on('error', function (err) { console.error('Erreur dans le logger:', err);});
module.exports = log;1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586const { genresDb } = require('./db');
const getCurrentYear = () => new Date().getFullYear();
const generateYearIntervals = (startYear = 1880, endYear = getCurrentYear(), interval = 4) => { const intervals = []; endYear = Math.max(endYear, startYear);
for (let year = endYear; year >= startYear; year -= interval) { const nextYear = Math.max(year - interval + 1, startYear); intervals.push(`${nextYear}-${year}`); }
const [firstStart, firstEnd] = intervals.length ? intervals[intervals.length - 1].split('-').map(Number) : [startYear, endYear];
if (firstStart > startYear) { intervals[intervals.length - 1] = `${startYear}-${firstEnd}`; }
return intervals.length ? intervals : [`${startYear}-${endYear}`];};
const getGenres = (type, language) => new Promise((resolve, reject) => { const query = `SELECT genre_name FROM genres WHERE media_type = ? AND language = ?`; genresDb.all(query, [type, language], (err, rows) => { if (err) return reject(err); resolve(rows.map(row => row.genre_name)); }); });
const generateManifest = async (language) => { try { const [movieGenres, seriesGenres] = await Promise.all([ getGenres('movie', language), getGenres('tv', language) ]);
const yearIntervals = generateYearIntervals();
return { id: 'community.stremiotmdbdice', version: '1.0.0', logo: "https://www.themoviedb.org/assets/2/v4/logos/v2/blue_square_2-d537fb228cf3ded904ef09b136fe3fec72548ebc1fea3fbbd1ad9e36364db38b.svg", name: 'Stremio TMDB Dice', description: 'A catalog featuring content from TMDB with filters that allow for generating random content recommendations.', types: ['movie', 'series'], idPrefixes: ['tt'], resources: ['catalog'], catalogs: [ { type: "movie", id: "random_movies", name: "Random Movies", extra: [ { name: "genre", options: movieGenres.length ? movieGenres : ["No genres available"], isRequired: false }, { name: "rating", options: ["8-10", "6-8", "4-6", "2-4", "0-2"], isRequired: false }, { name: "year", options: yearIntervals, isRequired: false }, { name: 'skip', isRequired: false }, ] }, { type: "series", id: "random_series", name: "Random Series", extra: [ { name: "genre", options: seriesGenres.length ? seriesGenres : ["No genres available"], isRequired: false }, { name: "rating", options: ["8-10", "6-8", "4-6", "2-4", "0-2"], isRequired: false }, { name: "year", options: yearIntervals, isRequired: false }, { name: 'skip', isRequired: false }, ] } ], behaviorHints: { configurable: true, configurationRequired: false, } }; } catch (error) { console.error('Error generating manifest:', error); }};
module.exports = generateManifest;1234567const async = require('async');
const queue = async.queue((task, callback) => { task.fn().then(callback).catch(callback);}, 45);
module.exports = queue;123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263const express = require('express');const log = require('../helpers/logger');const { fetchData, getGenreId } = require('../api/tmdb');
const router = express.Router();
router.get("/:configParameters?/catalog/:type/:id/:extra?.json", async (req, res) => { const { configParameters, type, id, extra } = req.params; const { cacheDuration = '3d', ...query } = req.query; const config = configParameters ? JSON.parse(decodeURIComponent(configParameters)) : {}; const { language, hideNoPoster, tmdbApiKey, fanartApiKey, rpdbApiKey } = config;
log.info(`Catalog request: type=${type}, id=${id}, language=${language}`); log.debug(`Extra parameters: ${JSON.stringify(query)}`);
const mediaType = type === 'series' ? 'tv' : type; if (!['movie', 'tv'].includes(mediaType)) { log.error(`Invalid catalog type: ${mediaType}`); return res.status(400).json({ metas: [] }); }
try { let extraParams = { ...query };
if (extra) { const decodedExtra = decodeURIComponent(extra); extraParams = { ...extraParams, ...Object.fromEntries( decodedExtra.split(/(?<!\s)&(?!\s)/).map(param => { const [key, value] = param.split('=').map(decodeURIComponent); return [key.trim(), value.trim()]; }) ) }; }
if (language) extraParams.language = language; if (hideNoPoster !== undefined) extraParams.hideNoPoster = String(hideNoPoster);
if (extraParams.genre) { const genreId = await getGenreId(mediaType, extraParams.genre); if (genreId) { extraParams.with_genres = genreId; } else { log.warn(`Genre ${extraParams.genre} not found for ${mediaType}`); } }
log.debug(`Extra parameters after processing: ${JSON.stringify(extraParams)}`);
const metas = await fetchData(mediaType, id, extraParams, cacheDuration, tmdbApiKey, rpdbApiKey, fanartApiKey);
res.json({ metas: extraParams.hideNoPoster === 'true' ? metas.filter(meta => meta.poster) : metas }); } catch (error) { log.error(`Error fetching catalog data: ${error.message}`); res.status(500).json({ metas: [] }); }});
module.exports = router;1234567891011121314151617const express = require('express');const path = require('path');const log = require('../helpers/logger');
const router = express.Router();
router.get("/", (req, res) => { log.info('Redirecting to /configure'); res.redirect("/configure");});
router.get("/:configParameters?/configure", (req, res) => { log.info(`Sending public/configure.html`); res.sendFile(path.join(__dirname, `../../public/configure.html`));});
module.exports = router;1234567891011121314151617181920212223242526const express = require('express');const configureRoutes = require('./configure');const manifestRoutes = require('./manifest');const catalogRoutes = require('./catalog');const log = require('../helpers/logger');
const router = express.Router();
router.use((req, res, next) => { log.info(`--- Request received ---`); log.info(`${req.method} ${req.originalUrl}`); next();});
router.use(configureRoutes);router.use(manifestRoutes);router.use(catalogRoutes);
router.use((err, req, res, next) => { const errorTime = new Date().toISOString(); log.error(`${errorTime} - Error: ${err.stack}`);
res.status(500).send(`Something broke! If you need help, please provide this timestamp to the developer : ${errorTime}`);});
module.exports = router;1234567891011121314151617181920212223242526272829const express = require('express');const log = require('../helpers/logger');const { checkGenresExistForLanguage, fetchAndStoreGenres } = require('../api/tmdb');const generateManifest = require('../helpers/manifest');
const router = express.Router();
router.get("/:configParameters?/manifest.json", async (req, res) => { const { configParameters } = req.params; const config = configParameters ? JSON.parse(decodeURIComponent(configParameters)) : {}; const { language, tmdbApiKey } = config;
log.debug(`Manifest request for language: ${language}`);
try { if (language && !(await checkGenresExistForLanguage(language))) { log.debug(`Fetching genres for language: ${language}`); await fetchAndStoreGenres(language, tmdbApiKey); }
const manifest = await generateManifest(language); res.json(manifest); } catch (error) { log.error(`Error generating manifest: ${error.message}`); res.status(500).json({ error: 'Error generating manifest' }); }});
module.exports = router;.dockerignore-1
.env+21-19
Dockerfile+1-10
LICENSEAdded+21
index.js-2
package-lock.json+144-77
package.json+4-5
public/configure.htmlAdded+171
public/css/styles.cssAdded+279
public/js/languages.jsAdded+202
src/api/fanart.jsAdded+40
src/api/rpdb.jsAdded+76
src/api/tmdb.jsAdded+277
src/helpers/cache.jsAdded+138
src/helpers/db.jsAdded+72
src/helpers/logger.jsAdded+65
src/helpers/manifest.jsAdded+86
src/helpers/ratelimit.jsAdded+7
src/routes/catalog.jsAdded+63
src/routes/configure.jsAdded+17
src/routes/index.jsAdded+26
src/routes/manifest.jsAdded+29