From 44815f942a2adfc568efddbdb1d379bc4fb24f3c Mon Sep 17 00:00:00 2001 From: Sleeyax Date: Mon, 26 Feb 2024 12:27:01 +0100 Subject: [PATCH] Add stremio login (#5) --- src/components/Authentication.vue | 100 ++++++++++++++++++++++++++++++ src/components/Configuration.vue | 49 ++++++++------- src/components/FAQ.vue | 11 ++++ src/components/Summary.vue | 48 +++++++++----- 4 files changed, 169 insertions(+), 39 deletions(-) create mode 100644 src/components/Authentication.vue diff --git a/src/components/Authentication.vue b/src/components/Authentication.vue new file mode 100644 index 0000000..e347fbc --- /dev/null +++ b/src/components/Authentication.vue @@ -0,0 +1,100 @@ + + + + + diff --git a/src/components/Configuration.vue b/src/components/Configuration.vue index 10ad23c..ab3b761 100644 --- a/src/components/Configuration.vue +++ b/src/components/Configuration.vue @@ -2,21 +2,17 @@ import { ref } from 'vue' import draggable from 'vuedraggable' import AddonItem from './AddonItem.vue' +import Authentication from './Authentication.vue' const stremioAPIBase = "https://api.strem.io/api/" - -const stremioAuthKey = ref('') +const dragging = false +let stremioAuthKey = ref(''); let addons = ref([]) let loadAddonsButtonText = ref('Load Addons') -const dragging = false - -function getCleansedStremioAuthKey() { - return stremioAuthKey.value.replaceAll('"', '').trim(); -} function loadUserAddons() { - const cleansedAuthKey = getCleansedStremioAuthKey() - if (!cleansedAuthKey) { + const key = stremioAuthKey.value + if (!key) { console.error('No auth key provided') return } @@ -29,7 +25,7 @@ function loadUserAddons() { method: 'POST', body: JSON.stringify({ type: 'AddonCollectionGet', - authKey: cleansedAuthKey, + authKey: key, update: true, }) }).then((resp) => { @@ -50,8 +46,8 @@ function loadUserAddons() { } function syncUserAddons() { - const cleansedAuthKey = getCleansedStremioAuthKey() - if (!cleansedAuthKey) { + const key = stremioAuthKey.value + if (!key) { console.error('No auth key provided') return } @@ -62,7 +58,7 @@ function syncUserAddons() { method: 'POST', body: JSON.stringify({ type: 'AddonCollectionSet', - authKey: cleansedAuthKey, + authKey: key, addons: addons.value, }) }).then((resp) => { @@ -88,7 +84,6 @@ function removeAddon(idx) { addons.value.splice(idx, 1) } - function getNestedObjectProperty(obj, path, defaultValue = null) { try { return path.split('.').reduce((acc, part) => acc && acc[part], obj) @@ -97,6 +92,12 @@ function getNestedObjectProperty(obj, path, defaultValue = null) { } } +function setAuthKey(authKey) { + stremioAuthKey.value = authKey + console.log('AuthKey set to: ', stremioAuthKey.value) +} + +