working latest bits

This commit is contained in:
Karl 2021-11-19 15:45:10 +00:00
parent bbe88b1d94
commit e8a5a1b17e
2 changed files with 6 additions and 53 deletions

View File

@ -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) { async function buildURL(streamURL, username, password) {
@ -63,7 +63,6 @@ async function updateAccounts(userAccounts, data, url) {
"password": account.password, "password": account.password,
"userId": account.userId "userId": account.userId
}, urlData.extractedUrl, data.user_info.exp_date) }, 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}.`) console.log(`${urlData.extractedUrl}.`)
await updateOtherURLs(account.stream, 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) { async function urlChecker(userAccounts) {
let ip = await inst.get('http://api.ipify.org') 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++) { for (let index2 = 0; index2 < userAccount.urls.length; index2++) {
const url = userAccount.urls[index2]; const url = userAccount.urls[index2];
// console.log('url ' + index2 + 1 + ' of ' + userAccount.urls.length) // console.log('url ' + index2 + 1 + ' of ' + userAccount.urls.length)
console.log('.') // console.log('.')
try { try {
let response = await inst.get(url, axiosOptions) let response = await inst.get(url, axiosOptions)
if (response.data.user_info.auth) { if (response.data.user_info.auth) {
@ -233,7 +184,9 @@ async function accountChecker(accountData, urlList) {
let response = await inst.get(url, axiosOptions) let response = await inst.get(url, axiosOptions)
if (response.data.user_info.auth) { if (response.data.user_info.auth) {
addNewAccount(accountData, data, url) addNewAccount(accountData, data, url)
break console.log('New Account Added')
syncApache()
return true
} }
} catch (error) { } catch (error) {
try { try {

View File

@ -68,7 +68,7 @@ function getAllUniqueAccounts() {
} }
function getUserUniqueAccounts(userid) { 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 WHERE userAccounts.expiaryDate != '0' AND
userAccounts.userId = ${userid} userAccounts.userId = ${userid}
GROUP BY userAccounts.stream GROUP BY userAccounts.stream