add comment cleanup and add globals

This commit is contained in:
Alf Hammerseth
2019-11-16 21:13:45 +01:00
parent 54b745ec68
commit 33e6220e43
31 changed files with 4480 additions and 2552 deletions

View File

@@ -73,7 +73,6 @@ var toShowChannel = {
_id: 0,
tags: 1,
now_playing: 1,
type: 1,
source: 1,
thumbnail: 1
};

View File

@@ -1,3 +1,7 @@
import {
pathThumbnails
} from "../settings/globals";
var Functions = require(pathThumbnails + "/handlers/functions.js");
var crypto = require("crypto");
var db = require(pathThumbnails + "/handlers/db.js");

View File

@@ -1,17 +1,20 @@
var path = require("path");
import { join } from "path";
import {
mongojs
} from 'mongojs';
try {
var mongo_config = require(path.join(
path.join(__dirname, "../config/"),
var mongo_config = require(
join(__dirname, "../config/mongo_config.js"),
"mongo_config.js"
));
);
} catch (e) {
console.log(
"(!) Missing file - /config/mongo_config.js. Have a look at /config/mongo_config.example.js. The server won't run without this existing."
);
process.exit(1);
}
var mongojs = require("mongojs");
var db = mongojs("mongodb://" + mongo_config.host + "/" + mongo_config.config);
const db = mongojs("mongodb://" + mongo_config.host + "/" + mongo_config.config);
db.collection("chat_logs").createIndex({
createdAt: 1
@@ -20,6 +23,7 @@ db.collection("chat_logs").createIndex({
},
function () {}
);
db.collection("timeout_api").createIndex({
createdAt: 1
}, {
@@ -27,6 +31,7 @@ db.collection("timeout_api").createIndex({
},
function () {}
);
db.collection("api_links").createIndex({
createdAt: 1
}, {
@@ -34,6 +39,7 @@ db.collection("api_links").createIndex({
},
function () {}
);
db.on("connected", function (err) {
console.log("connected");
});
@@ -59,6 +65,7 @@ db.collection("unique_ids").update({
},
function (err, docs) {}
);
db.collection("user_names").remove({
guid: {
$exists: true
@@ -69,6 +76,7 @@ db.collection("user_names").remove({
},
function (err, docs) {}
);
db.collection("user_names").update({
_id: "all_names"
}, {
@@ -81,6 +89,7 @@ db.collection("user_names").update({
},
function (err, docs) {}
);
db.collection("connected_users").update({
users: {
$exists: true
@@ -95,6 +104,7 @@ db.collection("connected_users").update({
},
function (err, docs) {}
);
db.collection("connected_users").update({
_id: "total_users"
}, {
@@ -107,6 +117,7 @@ db.collection("connected_users").update({
},
function (err, docs) {}
);
db.collection("frontpage_lists").update({
viewers: {
$ne: 0
@@ -122,4 +133,4 @@ db.collection("frontpage_lists").update({
function (err, docs) {}
);
module.exports = db;
export default db;

View File

@@ -1,3 +1,8 @@
import {
pathThumbnails,
VERSION
} from "../settings/globals";
var Functions = require(pathThumbnails + "/handlers/functions.js");
var db = require(pathThumbnails + "/handlers/db.js");

View File

@@ -1,3 +1,7 @@
import {
pathThumbnails
} from "../settings/globals";
var path = require("path");
try {
var mongo_config = require(path.join(

View File

@@ -1,3 +1,7 @@
import {
pathThumbnails
} from "../settings/globals";
var cookie = require("cookie");
var Functions = require(pathThumbnails + "/handlers/functions.js");

View File

@@ -1,3 +1,8 @@
import {
pathThumbnails,
VERSION
} from "../settings/globals";
var ColorThief = require("color-thief-jimp");
var Jimp = require("jimp");
var Functions = require(pathThumbnails + "/handlers/functions.js");
@@ -99,9 +104,8 @@ function list(msg, guid, coll, offline, socket) {
socket.emit("update_required", result);
return;
}
coll = msg.channel.toLowerCase(); //.replace(/ /g,'');
coll = msg.channel.toLowerCase();
coll = Functions.removeEmojis(coll).toLowerCase();
//coll = filter.clean(coll);
var pass = msg.pass;
db.collection("frontpage_lists").find({
_id: coll
@@ -1280,7 +1284,6 @@ function sendColor(coll, socket, url, ajax, res) {
}
function getNextSong(coll, socket, callback) {
//coll = coll.replace(/ /g,'');
db.collection(coll).aggregate(
[{
$match: {

View File

@@ -1,3 +1,7 @@
import {
pathThumbnails
} from "../settings/globals";
var Functions = require(pathThumbnails + "/handlers/functions.js");
var List = require(pathThumbnails + "/handlers/list.js");
var Frontpage = require(pathThumbnails + "/handlers/frontpage.js");

View File

@@ -1,3 +1,8 @@
import {
pathThumbnails
} from "../settings/globals";
var Functions = require(pathThumbnails + "/handlers/functions.js");
var crypto = require("crypto");
var projects = require(pathThumbnails + "/handlers/aggregates.js");

View File

@@ -1,3 +1,7 @@
import {
pathThumbnails
} from "../settings/globals";
var path = require("path");
var time_regex = /P((([0-9]*\.?[0-9]*)Y)?(([0-9]*\.?[0-9]*)M)?(([0-9]*\.?[0-9]*)W)?(([0-9]*\.?[0-9]*)D)?)?(T(([0-9]*\.?[0-9]*)H)?(([0-9]*\.?[0-9]*)M)?(([0-9]*\.?[0-9]*)S)?)?/;
try {
@@ -377,7 +381,6 @@ function get_genres_youtube(ids, channel) {
}
function get_correct_info(song_generated, channel, broadcast, callback) {
//channel = channel.replace(/ /g,'');
request({
type: "GET",
url: "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id,topicDetails&key=" +
@@ -404,7 +407,6 @@ function get_correct_info(song_generated, channel, broadcast, callback) {
.toLowerCase()
.split(",");
genre = genre.filter(filterFunction);
//console.log(genre + " - ", song_generated.id);
if (
title != song_generated.title ||
duration < parseInt(song_generated.duration)
@@ -431,7 +433,6 @@ function get_correct_info(song_generated, channel, broadcast, callback) {
function (err, docs) {
if (broadcast && docs.nModified == 1) {
song_generated.new_id = song_generated.id;
//if(song_generated.type == "video")
if (typeof callback == "function") {
callback(song_generated, true);
} else {
@@ -494,7 +495,6 @@ function check_error_video(msg, channel) {
return;
}
if (msg.source == "soundcloud") return;
//channel = channel.replace(/ /g,'');
request({
type: "GET",
url: "https://www.googleapis.com/youtube/v3/videos?part=id&key=" +
@@ -516,7 +516,6 @@ function check_error_video(msg, channel) {
}
function findSimilar(msg, channel, broadcast, callback) {
//channel = channel.replace(/ /g,'');
var yt_url =
"https://www.googleapis.com/youtube/v3/search?key=" +
key +
@@ -626,7 +625,7 @@ function editDistance(s1, s2) {
s1 = s1.toLowerCase();
s2 = s2.toLowerCase();
var costs = new Array();
var costs = new [];
for (var i = 0; i <= s1.length; i++) {
var lastValue = i;
for (var j = 0; j <= s2.length; j++) {

View File

@@ -1,3 +1,7 @@
import {
pathThumbnails
} from "../settings/globals";
var Functions = require(pathThumbnails + "/handlers/functions.js");
var Notifications = require(pathThumbnails + "/handlers/notifications.js");
var crypto = require("crypto");