2021-02-10 01:01:50 +04:00
|
|
|
const moment = require("moment-timezone");
|
|
|
|
|
|
|
|
const formats = Object.freeze({
|
|
|
|
post_date: "Do MMMM YYYY HH:mm:ss z",
|
|
|
|
file_date: "YYYY-MM-DD HH:mm:ss z",
|
|
|
|
id_date: "YYYYMMDD-HHmm" });
|
|
|
|
|
|
|
|
function datetime(date, format=formats.post_date, timezone="UTC") {
|
|
|
|
return moment.utc(date).tz(timezone).format(format);
|
|
|
|
}
|
|
|
|
|
2021-02-11 02:57:18 +04:00
|
|
|
exports.getServiceByHost = (host, service="") => {
|
|
|
|
if (host.endsWith("onion"))
|
|
|
|
switch (service) {
|
|
|
|
case "radio": return "http://wsmkgnmhmzqm7kyzv7jnzzafvgm7xlmlfvzhgorpapd5or2arnhuktqd.onion";
|
|
|
|
case "files": return "http://qf5e43nlhvnrutmikuvbdfj3cmtthokpbaxtkm6mjlslttzvtgm4fxid.onion";
|
|
|
|
default: return "http://moq7aejnf4xk5k2bkaltli3ftkhusy2mbrd3pj23nrca343ku2mgk4yd.onion";
|
|
|
|
}
|
|
|
|
else if (host.endsWith("i2p"))
|
|
|
|
switch (service) {
|
|
|
|
case "radio": return "http://plkybcgxt4cdanot75cy3pbnqlbqcsrib2fmrpsnug4bqphqvfda.b32.i2p";
|
|
|
|
case "files": return "http://gajftpr47ze6ao7e3q2tb5xmcqneyaczu4edzvwwg2qzmnernpka.b32.i2p";
|
|
|
|
default: return "http://t42fkp6zp5dfqywantq3zp427ig3q2onrmfv246tyaztpg4ckb5a.b32.i2p";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
switch (service) {
|
|
|
|
case "radio": return "https://radio.arav.top";
|
|
|
|
case "files": return "https://files.arav.top";
|
|
|
|
default: return "https://arav.top";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-17 03:28:23 +04:00
|
|
|
exports.getTimezone = ctx => {
|
|
|
|
if (ctx.header['x-client-timezone'] !== undefined)
|
|
|
|
return ctx.header['x-client-timezone'];
|
|
|
|
};
|
2021-02-10 01:01:50 +04:00
|
|
|
exports.formats = formats;
|
|
|
|
exports.datetime = datetime;
|
|
|
|
|
|
|
|
exports.rssLink = (proto, host, date, category, timezone="UTC") =>
|
|
|
|
`${proto}://${host}/mindflow#${category}-${datetime(date, formats.id_date, timezone)}`;
|
|
|
|
|