Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add StremThru integration #322

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions addon/lib/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ export const PreConfigurations = {

const keysToSplit = [Providers.key, LanguageOptions.key, QualityFilter.key, SizeFilter.key, DebridOptions.key];
const keysToUppercase = [SizeFilter.key];
const keysParser = {
stremthru: (val) => {
const config = { url: '' , auth: '' };
if (val) {
const [auth, url] = decodeURIComponent(val).split('@');
config.url = url;
if (auth.includes(':')) {
const [store, token] = auth.split(':');
config.auth = { store, token };
} else {
config.auth = auth;
}
}
return config;
}
}

export function parseConfiguration(configuration) {
if (!configuration) {
Expand All @@ -48,6 +64,11 @@ export function parseConfiguration(configuration) {
.filter(key => configValues[key])
.forEach(key => configValues[key] = configValues[key].split(',')
.map(value => keysToUppercase.includes(key) ? value.toUpperCase() : value.toLowerCase()))
Object.keys(keysParser).forEach((key) => {
if (configValues[key]) {
configValues[key] = keysParser[key](configValues[key]);
}
})
return configValues;
}

Expand Down
18 changes: 17 additions & 1 deletion addon/lib/landingTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ export default function landingTemplate(manifest, config = {}) {
const putioKey = config[MochOptions.putio.key] || '';
const putioClientId = putioKey.replace(/@.*/, '');
const putioToken = putioKey.replace(/.*@/, '');
const stremthru = config[MochOptions.stremthru.key] || { url: '', auth: '' };

const background = manifest.background || 'https://dl.strem.io/addon-background.jpg';
const logo = manifest.logo || 'https://dl.strem.io/addon-logo.png';
Expand Down Expand Up @@ -341,6 +342,12 @@ export default function landingTemplate(manifest, config = {}) {
<input type="text" id="iPutioClientId" placeholder="ClientId" onchange="generateInstallLink()" class="input">
<input type="text" id="iPutioToken" placeholder="Token" onchange="generateInstallLink()" class="input">
</div>

<div id="dStremThru">
<label class="label" for="iStremThru">StremThru URL and Credential:</label>
<input type="text" id="iStremThruUrl" placeholder="URL: https://" onchange="generateInstallLink()" class="input">
<input type="text" id="iStremThruAuth" placeholder="Credential: 'store_name:store_token' / base64 encoded 'username:password'" onchange="generateInstallLink()" class="input">
</div>

<div id="dDebridOptions">
<label class="label" for="iDebridOptions">Debrid options:</label>
Expand Down Expand Up @@ -405,6 +412,8 @@ export default function landingTemplate(manifest, config = {}) {
$('#iTorbox').val("${torboxApiKey}");
$('#iPutioClientId').val("${putioClientId}");
$('#iPutioToken').val("${putioToken}");
$('#iStremThruUrl').val("${stremthru.url}");
$('#iStremThruAuth').val("${stremthru.auth}");
$('#iSort').val("${sort}");
$('#iLimit').val("${limit}");
$('#iSizeFilter').val("${sizeFilter}");
Expand All @@ -431,6 +440,7 @@ export default function landingTemplate(manifest, config = {}) {
$('#dOffcloud').toggle(provider === '${MochOptions.offcloud.key}');
$('#dTorbox').toggle(provider === '${MochOptions.torbox.key}');
$('#dPutio').toggle(provider === '${MochOptions.putio.key}');
$('#dStremThru').toggle(provider === '${MochOptions.stremthru.key}');
}

function generateInstallLink() {
Expand All @@ -451,6 +461,8 @@ export default function landingTemplate(manifest, config = {}) {
const torboxValue = $('#iTorbox').val() || '';
const putioClientIdValue = $('#iPutioClientId').val() || '';
const putioTokenValue = $('#iPutioToken').val() || '';
const stremthruUrl = $('#iStremThruUrl').val() || '';
const stremthruAuth = $('#iStremThruAuth').val() || '';


const providers = providersList.length && providersList.length < ${Providers.options.length} && providersValue;
Expand All @@ -468,6 +480,9 @@ export default function landingTemplate(manifest, config = {}) {
const offcloud = offcloudValue.length && offcloudValue.trim();
const torbox = torboxValue.length && torboxValue.trim();
const putio = putioClientIdValue.length && putioTokenValue.length && putioClientIdValue.trim() + '@' + putioTokenValue.trim();
let stremthru = stremthruUrl.trim().length
? encodeURIComponent(stremthruAuth.trim() + '@' + stremthruUrl.trim())
: '';

const preConfigurations = {
${preConfigurationObject}
Expand All @@ -486,7 +501,8 @@ export default function landingTemplate(manifest, config = {}) {
['${MochOptions.debridlink.key}', debridLink],
['${MochOptions.offcloud.key}', offcloud],
['${MochOptions.torbox.key}', torbox],
['${MochOptions.putio.key}', putio]
['${MochOptions.putio.key}', putio],
['${MochOptions.stremthru.key}', stremthru]
].filter(([_, value]) => value.length).map(([key, value]) => key + '=' + value).join('|');
configurationValue = Object.entries(preConfigurations)
.filter(([key, value]) => value === configurationValue)
Expand Down
8 changes: 8 additions & 0 deletions addon/moch/moch.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as debridlink from './debridlink.js';
import * as offcloud from './offcloud.js';
import * as torbox from './torbox.js';
import * as putio from './putio.js';
import * as stremthru from './stremthru.js';
import StaticResponse, { isStaticUrl } from './static.js';
import { cacheWrapResolvedUrl } from '../lib/cache.js';
import { timeout } from '../lib/promises.js';
Expand Down Expand Up @@ -64,6 +65,13 @@ export const MochOptions = {
name: 'Put.io',
shortName: 'Putio',
catalogs: ['']
},
stremthru: {
key: 'stremthru',
instance: stremthru,
name: 'StremThru',
shortName: 'ST',
catalogs: ['']
}
};

Expand Down
Loading