new working
This commit is contained in:
parent
e97e8d4462
commit
185b357010
304
lib/checker.js
304
lib/checker.js
@ -1,5 +1,5 @@
|
|||||||
const { getStreamsNew } = require('../routes/getStreams')
|
const { getStreamsNew } = require('../routes/getStreams')
|
||||||
const { updateStreamData } = require('./updateStreams')
|
const { updateStreamData, updateOtherURLs } = require('./updateStreams')
|
||||||
const { decryptPassword } = require('./password')
|
const { decryptPassword } = require('./password')
|
||||||
const { getUserAccountsCheck, getAllUniqueAccounts, getAllUserAccounts, getUserUniqueAccounts } = require('./getUser')
|
const { getUserAccountsCheck, getAllUniqueAccounts, getAllUserAccounts, getUserUniqueAccounts } = require('./getUser')
|
||||||
const { storeAccountToDB } = require('../lib/Accounts')
|
const { storeAccountToDB } = require('../lib/Accounts')
|
||||||
@ -54,20 +54,19 @@ async function splitURL(url) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function updateAccounts(userAccounts, data, url) {
|
async function updateAccounts(userAccounts, data, url) {
|
||||||
try {
|
let urlData = await splitURL(url)
|
||||||
let URL = await splitURL(url)
|
|
||||||
|
|
||||||
let account = userAccounts.filter(account => account.username == URL.username && account.passwordDecryped == URL.password)[0]
|
let account = userAccounts.filter(account => account.username == urlData.username && account.passwordDecryped == urlData.password)[0]
|
||||||
|
|
||||||
await updateStreamData({
|
await updateStreamData({
|
||||||
"username": account.username,
|
"username": account.username,
|
||||||
"password": account.password,
|
"password": account.password,
|
||||||
"userId": account.userId
|
"userId": account.userId
|
||||||
}, URL.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' })
|
var date = new Date(data.user_info.exp_date * 1000).toLocaleDateString(undefined, { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })
|
||||||
console.log(`${userAccount.username} - - ${URL.extractedUrl} - Expires ${date}.`)
|
console.log(`${urlData.extractedUrl}.`)
|
||||||
} catch (error) {
|
|
||||||
}
|
await updateOtherURLs(account.stream, urlData.extractedUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -90,191 +89,103 @@ async function addNewAccount(userAccount, data, url) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function urlChecker(userAccounts, urlList) {
|
// 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')
|
let ip = await inst.get('http://api.ipify.org')
|
||||||
console.log(ip.data);
|
console.log(ip.data);
|
||||||
|
|
||||||
// for (let index = 0; index < userAccounts.length; index++) {
|
let updateCount = 0
|
||||||
// const userAccount = userAccounts[index];
|
|
||||||
// console.log('account ' + index+1 + ' of ' + userAccounts.length)
|
|
||||||
// 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(url)
|
|
||||||
// try {
|
|
||||||
// let response = await inst.get(url, axiosOptions)
|
|
||||||
// if (response.data.user_info.auth) {
|
|
||||||
// updateAccounts(userAccounts, response.data, url)
|
|
||||||
// console.log(url)
|
|
||||||
// console.log('New Account Added')
|
|
||||||
// // syncApache()
|
|
||||||
// // return true
|
|
||||||
// continue
|
|
||||||
// }
|
|
||||||
// } 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)
|
|
||||||
// console.log('URL updated')
|
|
||||||
// continue
|
|
||||||
// } catch (error) {
|
|
||||||
// continue
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } catch (error) {
|
|
||||||
// continue
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
for (let index = 0; index < urlList.length; index++) {
|
for (let index = 0; index < userAccounts.length; index++) {
|
||||||
const url = urlList[index];
|
const userAccount = userAccounts[index];
|
||||||
console.log(index + 1 + ' of ' + urlList.length + ' urls checked')
|
let count = index + 1
|
||||||
try {
|
console.log(count + ' of ' + userAccounts.length + ' ' + userAccount.username)
|
||||||
let response = await inst.get(url, axiosOptions)
|
for (let index2 = 0; index2 < userAccount.urls.length; index2++) {
|
||||||
if (response.data.user_info.auth) {
|
const url = userAccount.urls[index2];
|
||||||
updateAccounts(userAccounts, response.data, url)
|
// console.log('url ' + index2 + 1 + ' of ' + userAccount.urls.length)
|
||||||
console.log('URL updated')
|
console.log('.')
|
||||||
// syncApache()
|
|
||||||
// return true
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
try {
|
try {
|
||||||
if (error.response.status == 403) {
|
let response = await inst.get(url, axiosOptions)
|
||||||
let response2 = await axios.get(url, axiosOptions)
|
if (response.data.user_info.auth) {
|
||||||
if (response2.data.user_info.auth) {
|
await updateAccounts(userAccounts, response.data, url)
|
||||||
try {
|
updateCount++
|
||||||
await updateAccounts(userAccounts, response2.data, url)
|
break
|
||||||
console.log('URL updated')
|
|
||||||
continue
|
|
||||||
} catch (error) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
continue
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
syncApache()
|
||||||
|
return {
|
||||||
|
"updatedCount": updateCount,
|
||||||
|
"totalAccounts": userAccounts.length
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// await Promise.all(urlList.map(async (url) => {
|
|
||||||
// try {
|
|
||||||
// let response
|
|
||||||
// url
|
|
||||||
// response = await inst.get(url, axiosOptions)
|
|
||||||
// if (response.status == 200 && response.data !== "") {
|
|
||||||
// try {
|
|
||||||
// let data = response.data
|
|
||||||
// if (data.user_info.auth) {
|
|
||||||
// console.log('.')
|
|
||||||
// updateAccounts(userAccounts, data, url)
|
|
||||||
// return true
|
|
||||||
// }
|
|
||||||
// } catch {
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } catch {
|
|
||||||
// }
|
|
||||||
// })).then((values) => {
|
|
||||||
// endresponse = values
|
|
||||||
// });
|
|
||||||
// return endresponse
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
// async function allUserCheck() {
|
|
||||||
// let start = Date.now()
|
|
||||||
// console.log(start)
|
|
||||||
// streamURLS = await getStreamsNew()
|
|
||||||
// let userAccounts = await getAllUserAccounts()
|
|
||||||
|
|
||||||
// userAccounts = userAccounts.map(user => {
|
|
||||||
// // user.userId = accountData.userId
|
|
||||||
// user.passwordDecryped = decryptPassword(user.password)
|
|
||||||
// return user
|
|
||||||
// })
|
|
||||||
// urlList = []
|
|
||||||
|
|
||||||
// for (let index = 0; index < userAccounts.length; index++) {
|
|
||||||
// let userAccount = userAccounts[index];
|
|
||||||
// userAccount.urls = []
|
|
||||||
// for (let index = 0; index < streamURLS.length; index++) {
|
|
||||||
// const streamURL = streamURLS[index];
|
|
||||||
// userAccount.urls.push(await buildURL(streamURL, userAccount.username, userAccount.passwordDecryped))
|
|
||||||
// urlList.push(await buildURL(streamURL, userAccount.username, userAccount.passwordDecryped))
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
// values = await urlCheckerNew(userAccounts[3], urlList)
|
|
||||||
// if (values.includes(true)) {
|
|
||||||
// let updatedCount = values.filter(function (value) {
|
|
||||||
// return value === true;
|
|
||||||
// }).length
|
|
||||||
// console.log('true ' + updatedCount)
|
|
||||||
// console.log((Date.now() - start) / 1000)
|
|
||||||
// return endresponse = {
|
|
||||||
// "update": true,
|
|
||||||
// "count": updatedCount
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// return endresponse = false
|
|
||||||
// }
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
// async function allUserCheck() {
|
|
||||||
// let start = Date.now()
|
|
||||||
// console.log(start)
|
|
||||||
// streamURLS = await getStreamsNew()
|
|
||||||
// let userAccounts = await getAllUserAccounts()
|
|
||||||
|
|
||||||
// userAccounts = userAccounts.map(user => {
|
|
||||||
// // user.userId = accountData.userId
|
|
||||||
// user.passwordDecryped = decryptPassword(user.password)
|
|
||||||
// return user
|
|
||||||
// })
|
|
||||||
// urlList = []
|
|
||||||
|
|
||||||
// for (let index = 0; index < userAccounts.length; index++) {
|
|
||||||
// let userAccount = userAccounts[index];
|
|
||||||
// userAccount.urls = []
|
|
||||||
// for (let index = 0; index < streamURLS.length; index++) {
|
|
||||||
// const streamURL = streamURLS[index];
|
|
||||||
// userAccount.urls.push(await buildURL(streamURL, userAccount.username, userAccount.passwordDecryped))
|
|
||||||
// urlList.push(await buildURL(streamURL, userAccount.username, userAccount.passwordDecryped))
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
// values = await urlChecker(userAccounts, urlList)
|
|
||||||
// if (values.includes(true)) {
|
|
||||||
// let updatedCount = values.filter(function (value) {
|
|
||||||
// return value === true;
|
|
||||||
// }).length
|
|
||||||
// console.log('true ' + updatedCount)
|
|
||||||
// console.log((Date.now() - start) / 1000)
|
|
||||||
// return endresponse = {
|
|
||||||
// "update": true,
|
|
||||||
// "count": updatedCount
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// return endresponse = false
|
|
||||||
// }
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
async function userCheck(accountData) {
|
async function userCheck(accountData) {
|
||||||
let start = Date.now()
|
let start = Date.now()
|
||||||
console.log(start)
|
console.log(start)
|
||||||
@ -296,25 +207,19 @@ async function userCheck(accountData) {
|
|||||||
userAccount.urls.push(await buildURL(streamURL, userAccount.username, userAccount.passwordDecryped))
|
userAccount.urls.push(await buildURL(streamURL, userAccount.username, userAccount.passwordDecryped))
|
||||||
urlList.push(await buildURL(streamURL, userAccount.username, userAccount.passwordDecryped))
|
urlList.push(await buildURL(streamURL, userAccount.username, userAccount.passwordDecryped))
|
||||||
}
|
}
|
||||||
|
userAccount.urls = userAccount.urls.filter(function (e) { return !e.includes('stormtv') && !e.includes('megaott') })
|
||||||
}
|
}
|
||||||
urlList = urlList.filter(function (e) { return !e.includes('stormtv') && !e.includes('megaott') })
|
|
||||||
|
|
||||||
|
values = await urlChecker(userAccounts)
|
||||||
values = await urlChecker(userAccounts, urlList)
|
if (values.updatedCount > 0) {
|
||||||
if (values.includes(true)) {
|
return {
|
||||||
let updatedCount = values.filter(function (value) {
|
|
||||||
return value === true;
|
|
||||||
}).length
|
|
||||||
console.log('true ' + updatedCount)
|
|
||||||
console.log((Date.now() - start) / 1000)
|
|
||||||
return endresponse = {
|
|
||||||
"update": true,
|
"update": true,
|
||||||
"count": updatedCount
|
"count": values.updatedCount
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return endresponse = false
|
return endresponse = false
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function accountChecker(accountData, urlList) {
|
async function accountChecker(accountData, urlList) {
|
||||||
@ -373,7 +278,6 @@ async function singleAccountCheck(accountData) {
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
userCheck,
|
userCheck,
|
||||||
singleAccountCheck,
|
singleAccountCheck,
|
||||||
// allUserCheck
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// singleAccountCheck({ "username": "Karl0ss01", "password": "YqQjYH9Nzw", "userId": 1, "stream": "Badger" })
|
// singleAccountCheck({ "username": "Karl0ss01", "password": "YqQjYH9Nzw", "userId": 1, "stream": "Badger" })
|
@ -10,7 +10,21 @@ async function updateStreamData(userAccount, streamURL, expiaryDate) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
async function updateOtherURLs(streamName, newUrl) {
|
||||||
updateStreamData
|
// let result
|
||||||
|
try {
|
||||||
|
let result = sql.query(`update userAccounts
|
||||||
|
set userAccounts.streamURL = '${newUrl}'
|
||||||
|
WHERE userAccounts.stream ='${streamName}'`);
|
||||||
|
return result
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
updateStreamData,
|
||||||
|
updateOtherURLs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user