ktvmanager_old_backend/lib/getStreamNames.js

36 lines
841 B
JavaScript
Raw Permalink Normal View History

2021-02-26 20:50:08 +00:00
const sql = require('./mysql')
function getStreamNames() {
2025-07-13 16:06:27 +01:00
let data = sql.query(`SELECT stream FROM BBLB_DNS.userAccounts`)
2021-02-26 20:50:08 +00:00
// console.log(data)
if (data.length == 0) {
return 'StreamsFailed'
} else {
2025-07-13 16:06:27 +01:00
const cleanedNames = data.map(item => {
if (item.stream) {
return item.stream.split('(')[0].trim();
}
return '';
}).filter(name => name !== '');
const uniqueNames = [...new Set(cleanedNames)];
return uniqueNames;
2021-02-26 20:50:08 +00:00
}
}
2021-11-19 11:52:28 +00:00
function getURLandStreams() {
let data = sql.query(`SELECT DISTINCT stream, streamURL FROM BBLB_DNS.userAccounts`)
// console.log(data)
if (data.length == 0) {
return 'StreamsFailed'
} else {
return data
}
}
2021-02-26 20:50:08 +00:00
module.exports = {
2021-11-19 11:52:28 +00:00
getStreamNames,
getURLandStreams
2021-02-26 20:50:08 +00:00
}