From e8a5a1b17e8d00d4f4b2d67277a7c6975d283686 Mon Sep 17 00:00:00 2001 From: Karl Date: Fri, 19 Nov 2021 15:45:10 +0000 Subject: [PATCH] working latest bits --- lib/checker.js | 57 +++++--------------------------------------------- lib/getUser.js | 2 +- 2 files changed, 6 insertions(+), 53 deletions(-) diff --git a/lib/checker.js b/lib/checker.js index 8dcfed2..95feb4a 100644 --- a/lib/checker.js +++ b/lib/checker.js @@ -30,7 +30,7 @@ let axiosOptions = { } -const delay = ms => new Promise(res => setTimeout(res, ms)); +// const delay = ms => new Promise(res => setTimeout(res, ms)); async function buildURL(streamURL, username, password) { @@ -63,7 +63,6 @@ async function updateAccounts(userAccounts, data, url) { "password": account.password, "userId": account.userId }, urlData.extractedUrl, data.user_info.exp_date) - var date = new Date(data.user_info.exp_date * 1000).toLocaleDateString(undefined, { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }) console.log(`${urlData.extractedUrl}.`) await updateOtherURLs(account.stream, urlData.extractedUrl) @@ -89,54 +88,6 @@ async function addNewAccount(userAccount, data, url) { } } -// async function urlChecker(userAccounts) { -// let ip = await inst.get('http://api.ipify.org') -// console.log(ip.data); - -// let updateCount = 0 - -// for (let index = 0; index < userAccounts.length; index++) { -// const userAccount = userAccounts[index]; -// let count = index + 1 -// console.log(count + ' of ' + userAccounts.length + ' ' + userAccount.username) -// for (let index2 = 0; index2 < userAccount.urls.length; index2++) { -// const url = userAccount.urls[index2]; -// // console.log('url ' + index2 + 1 + ' of ' + userAccount.urls.length) -// console.log('.') -// try { -// let response = await inst.get(url, axiosOptions) -// if (response.data.user_info.auth) { -// await updateAccounts(userAccounts, response.data, url) -// updateCount++ -// break -// } -// } catch (error) { -// try { -// if (error.response.status == 403) { -// let response2 = await axios.get(url, axiosOptions) -// if (response2.data.user_info.auth) { -// try { -// await updateAccounts(userAccounts, response2.data, url) -// updateCount++ -// break -// } catch (error) { -// continue -// } -// } -// } -// } catch (error) { -// continue -// } -// } -// } -// } -// syncApache() -// return { -// "updatedCount": updateCount, -// "totalAccounts": userAccounts.length -// } -// } - async function urlChecker(userAccounts) { let ip = await inst.get('http://api.ipify.org') @@ -151,7 +102,7 @@ async function urlChecker(userAccounts) { for (let index2 = 0; index2 < userAccount.urls.length; index2++) { const url = userAccount.urls[index2]; // console.log('url ' + index2 + 1 + ' of ' + userAccount.urls.length) - console.log('.') + // console.log('.') try { let response = await inst.get(url, axiosOptions) if (response.data.user_info.auth) { @@ -233,7 +184,9 @@ async function accountChecker(accountData, urlList) { let response = await inst.get(url, axiosOptions) if (response.data.user_info.auth) { addNewAccount(accountData, data, url) - break + console.log('New Account Added') + syncApache() + return true } } catch (error) { try { diff --git a/lib/getUser.js b/lib/getUser.js index a07edab..ab04203 100644 --- a/lib/getUser.js +++ b/lib/getUser.js @@ -68,7 +68,7 @@ function getAllUniqueAccounts() { } function getUserUniqueAccounts(userid) { - let data = sql.query(`SELECT DISTINCT(userAccounts.stream), userAccounts.username, userAccounts.password, userAccounts.stream , userAccounts.streamURL FROM userAccounts + let data = sql.query(`SELECT DISTINCT(userAccounts.streamURL), userAccounts.username, userAccounts.password, userAccounts.stream , userAccounts.streamURL FROM userAccounts WHERE userAccounts.expiaryDate != '0' AND userAccounts.userId = ${userid} GROUP BY userAccounts.stream