Compare commits

..

14 Commits

Author SHA1 Message Date
7faec524da router/video.js aktualisiert
All checks were successful
continuous-integration/drone Build is passing
fix wrong var name
2024-08-18 22:15:47 +02:00
cd7e2e7a0f server.js aktualisiert
All checks were successful
continuous-integration/drone/push Build is passing
2024-02-21 21:59:12 +01:00
c07984c506 server.js aktualisiert
All checks were successful
continuous-integration/drone/push Build is passing
2024-02-21 21:57:21 +01:00
2235372c64 Merge pull request 'fancy-banner. fix #18' (#21) from fancy-banner into main
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #21
2023-09-27 21:46:39 +02:00
Artem Anufrij
94a6893444 code style
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-09-27 21:44:58 +02:00
Artem Anufrij
cd0b9a7f55 code design
All checks were successful
continuous-integration/drone/push Build is passing
2023-09-27 21:43:52 +02:00
Artem Anufrij
97fcdcce5d add get api for random album covers
All checks were successful
continuous-integration/drone/push Build is passing
2023-09-27 16:52:37 +02:00
Artem Anufrij
e6614d0805 add get api for random album covers
All checks were successful
continuous-integration/drone/push Build is passing
2023-09-27 16:52:28 +02:00
Artem Anufrij
988afab81c fix most listened tracks. fix #19
All checks were successful
continuous-integration/drone/push Build is passing
2023-09-27 15:20:19 +02:00
94007dc7da Merge pull request 'set empty covers for radios in the db funktion' (#17) from dev into main
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Reviewed-on: #17
2023-09-22 14:46:08 +02:00
Artem Anufrij
7145a0b1cd set empty covers for radios in the db funktion
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-09-22 14:22:55 +02:00
77948e93b6 Merge pull request 'change cover structure in radio fix #15' (#16) from dev into main
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #16
2023-09-22 13:09:34 +02:00
Artem Anufrij
07cc31ede3 change cover structure in radio fix #15
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2023-09-21 11:13:47 +02:00
Artem Anufrij
1051f05cce fix settings
All checks were successful
continuous-integration/drone/push Build is passing
2023-09-19 16:42:00 +02:00
8 changed files with 66 additions and 23 deletions

View File

@@ -10,12 +10,12 @@
"http://localhost"
],
"database": {
"host": "localhost",
"host": "database",
"port": 27017,
"name": "webplay"
},
"redis": {
"host": "127.0.0.1",
"host": "redis",
"port": 6379
},
"album_cover_files": [

View File

@@ -51,6 +51,12 @@ router.route("/filter/:term")
res.json(result).status(200).end();
});
})
router.route("/random/:count")
.get(passport.authenticate("jwt", { session: false }), (req, res) => {
database.albums.randomCovers(req.params.count, 64, (result) => {
res.json(result).status(200).end();
});
})
router.route("/:id")
.get(checkGuest, (req, res) => {

View File

@@ -56,9 +56,9 @@ router
if (radio) {
if (req.files.file) {
resize_image_for_radio(req.files.file.data, (result) => {
radio.cover32 = result.cover32;
radio.cover64 = result.cover64;
radio.cover128 = result.cover128;
radio.covers.cover32 = result.cover32;
radio.covers.cover64 = result.cover64;
radio.covers.cover128 = result.cover128;
database.radios.update(radio);
res.json(radio).end();
});

View File

@@ -96,7 +96,7 @@ router.route("/:id/stream")
router.route("/:id/stream/:rate/:audioIndex")
.get((req, res) => {
if (!server.lists.video_quality.includes(req.params.rate)) {
req.end();
res.end();
}
let video = getFileName(req);

View File

@@ -101,7 +101,7 @@ app.use(fileUpload({
}));
const corsOptions = {
origin: (origin, callback) => {
if (!origin || config.allowed_domains.indexOf(origin.replace(/:\d*$/g, "")) !== -1) {
if (!origin || config.domain == origin.replace(/:\d*$/g, "") || config.allowed_domains.indexOf(origin.replace(/:\d*$/g, "")) !== -1) {
callback(null, true);
} else {
database.system.domains((domains) => {

View File

@@ -311,3 +311,26 @@ exports.empty = function (callback) {
callback(result.filter(f => !f.tracks || f.tracks.length == 0));
});
};
exports.randomCovers = function (count, size, callback) {
dbo
.collection("albums")
.find({ "covers.cover64": { $exists: true } })
.project({ "covers.cover64": true })
.toArray((err, result) => {
if (result.length > count) {
let res = [];
while (count-- > 0) {
let rnd = randomNumber(0, result.length);
res.push(result[rnd]);
}
callback(res);
} else {
callback(result);
}
})
}
function randomNumber(min, max) {
return Math.floor(Math.random() * (max - min) + min);
}

View File

@@ -13,6 +13,9 @@ exports.collection = function (callback) {
.toArray((err, result) => {
result.forEach(item => {
item.type = "radio";
if (!item.covers) {
item.covers = {};
}
});
callback(result);
});
@@ -23,6 +26,9 @@ exports.byId = function (id, callback) {
.collection("radios")
.findOne({ _id: ObjectId(id) }, (err, result) => {
if (err) throw err;
if (!result.covers) {
result.covers = {};
}
callback(result);
});
};
@@ -63,9 +69,7 @@ exports.update = function (radio, callback) {
$set: {
name: radio.name,
url: radio.url,
cover32: radio.cover32,
cover64: radio.cover64,
cover128: radio.cover128
covers: radio.covers
}
},
{ upsert: false },

View File

@@ -97,17 +97,27 @@ exports.mostListened = function (filter, callback) {
}
}, { $match: { "album.visibility": { $in: filter } } });
} else {
aggregate.unshift({ $match: { type: 'track' } });
}
aggregate.push({ $sort: { counter: -1, _id: -1 } }, { $limit: 6 })
dbo.collection("history")
.find()
.project({ _id: true })
.sort({ _id: -1 })
.limit(1000)
.toArray((err, ids) => {
let arr = ids.map(h => h._id);
aggregate.unshift({ $match: { type: 'track', _id: { $in: arr } } });
aggregate.push({ $sort: { counter: -1 } }, { $limit: 6 })
dbo
.collection("history")
.aggregate(aggregate, {
allowDiskUse: true
})
.toArray((err, result) => {
if (err) throw err;
callback(result);
});
});
}
dbo
.collection("history")
.aggregate(aggregate, {
allowDiskUse: true
})
.toArray((err, result) => {
if (err) throw err;
callback(result);
});
};