diff --git a/addon/addon.js b/addon/addon.js index 9b24977..4e136ae 100644 --- a/addon/addon.js +++ b/addon/addon.js @@ -1,5 +1,6 @@ const { addonBuilder } = require('stremio-addon-sdk'); const titleParser = require('parse-torrent-title'); +const { manifest } = require('./lib/manifest'); const { toStreamInfo } = require('./lib/streamInfo'); const { cacheWrapStream } = require('./lib/cache'); const repository = require('./lib/repository'); @@ -9,19 +10,7 @@ const CACHE_MAX_AGE_EMPTY = 30 * 60; // 30 minutes const STALE_REVALIDATE_AGE = 4 * 60 * 60; // 4 hours const STALE_ERROR_AGE = 7 * 24 * 60 * 60; // 7 days -const builder = new addonBuilder({ - id: 'com.stremio.torrentio.addon', - version: '1.0.0', - name: 'Torrentio', - description: 'Provides torrent stream from scraped torrent providers. ' - + 'Currently supports ThePirateBay, 1337x, RARBG, KickassTorrents, HorribleSubs.', - catalogs: [], - resources: ['stream'], - types: ['movie', 'series'], - idPrefixes: ['tt', 'kitsu'], - background: `https://i.imgur.com/t8wVwcg.jpg`, - logo: `https://i.imgur.com/GwxAcDV.png`, -}); +const builder = new addonBuilder(manifest()); builder.defineStreamHandler((args) => { if (!args.id.match(/tt\d+/i) && !args.id.match(/kitsu:\d+/i)) { diff --git a/addon/lib/configuration.js b/addon/lib/configuration.js new file mode 100644 index 0000000..79f77cd --- /dev/null +++ b/addon/lib/configuration.js @@ -0,0 +1,16 @@ +function parseConfiguration(configuration) { + const configValues = configuration.split('|') + .reduce((map, next) => { + const parameterParts = next.split('='); + if (parameterParts.length === 2) { + map[parameterParts[0].toLowerCase()] = parameterParts[1]; + } + return map; + }, {}); + if (configValues.providers) { + configValues.providers = configValues.providers.split(',').map(provider => provider.toLowerCase()); + } + return configValues; +} + +module.exports = parseConfiguration; \ No newline at end of file diff --git a/addon/lib/landingTemplate.js b/addon/lib/landingTemplate.js new file mode 100644 index 0000000..5e044fb --- /dev/null +++ b/addon/lib/landingTemplate.js @@ -0,0 +1,268 @@ +const STYLESHEET = ` +* { + box-sizing: border-box; +} + +body, +html { + margin: 0; + padding: 0; + width: 100%; + height: 100% +} + +html { + background-size: auto 100%; + background-size: cover; + background-position: center center; + background-repeat: no-repeat +} + +body { + display: flex; + background: rgba(0, 0, 0, 0.60); + font-family: 'Open Sans', Arial, sans-serif; + color: white; +} + +h1 { + font-size: 4.5vh; + font-weight: 700; +} + +h2 { + font-size: 2.2vh; + font-weight: normal; + font-style: italic; + opacity: 0.8; +} + +h3 { + font-size: 2.2vh; +} + +h1, +h2, +h3, +p, +label { + margin: 0; + text-shadow: 0 0 1vh rgba(0, 0, 0, 0.15); +} + +p { + font-size: 1.75vh; +} + +ul { + font-size: 1.75vh; + margin: 0; + margin-top: 1vh; + padding-left: 3vh; +} + +a { + color: white +} + +a.install-link { + text-decoration: none +} + +button { + border: 0; + outline: 0; + color: white; + background: #8A5AAB; + padding: 1.2vh 3.5vh; + margin: auto; + text-align: center; + font-family: 'Open Sans', Arial, sans-serif; + font-size: 2.2vh; + font-weight: 600; + cursor: pointer; + display: block; + box-shadow: 0 0.5vh 1vh rgba(0, 0, 0, 0.2); + transition: box-shadow 0.1s ease-in-out; +} + +button:hover { + box-shadow: none; +} + +button:active { + box-shadow: 0 0 0 0.5vh white inset; +} + +#addon { + width: 40vh; + margin: auto; +} + +.logo { + height: 14vh; + width: 14vh; + margin: auto; + margin-bottom: 3vh; +} + +.logo img { + width: 100%; +} + +.name, .version { + display: inline-block; + vertical-align: top; +} + +.name { + line-height: 5vh; +} + +.version { + position: absolute; + line-height: 5vh; + margin-left: 1vh; + opacity: 0.8; +} + +.contact { + position: absolute; + left: 0; + bottom: 4vh; + width: 100%; + text-align: center; +} + +.contact a { + font-size: 1.4vh; + font-style: italic; +} + +.separator { + margin-bottom: 4vh; +} + +.label { + font-size: 2.2vh; + font-weight: 600; + padding: 0; + line-height: inherit; +} + +.btn-group, .multiselect-container { + width: 100%; +} + +.multiselect-container { + border: 0; + border-radius: 0; +} + +.input, .btn { + height: 3.5vh; + width: 100%; + margin: auto; + padding: 6px 12px; + border: 0; + border-radius: 0; + outline: 0; + color: #333; + box-shadow: 0 0.5vh 1vh rgba(0, 0, 0, 0.2); +} +`; +const { Providers } = require('./manifest'); + +function landingTemplate(manifest, providers = [], realDebridApiKey = '') { + console.log(providers); + console.log(realDebridApiKey); + const background = manifest.background || 'https://dl.strem.io/addon-background.jpg'; + const logo = manifest.logo || 'https://dl.strem.io/addon-logo.png'; + const contactHTML = manifest.contactEmail ? + `
Contact ${manifest.name} creator:
+ ${manifest.contactEmail} +