Builded server with latest changes
This commit is contained in:
parent
6183f9b7a6
commit
00e2d0724b
25
server/dist/main.js
vendored
25
server/dist/main.js
vendored
@ -12,13 +12,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.restoreQueueFromDisk = exports.clearCompletedDownloads = exports.cancelAllDownloads = exports.cancelDownload = exports.startQueue = exports.addToQueue = exports.getQueue = exports.saveSettings = exports.getSettings = exports.listener = exports.plugins = exports.getArlFromAccessToken = exports.getAccessToken = exports.sessionDZ = exports.configFolder = exports.defaultSettings = void 0;
|
exports.restoreQueueFromDisk = exports.clearCompletedDownloads = exports.cancelAllDownloads = exports.cancelDownload = exports.startQueue = exports.addToQueue = exports.getQueue = exports.saveSettings = exports.getSettings = exports.listener = exports.plugins = exports.isDeezerAvailable = exports.deemixVersion = exports.getArlFromAccessToken = exports.getAccessToken = exports.sessionDZ = exports.configFolder = exports.defaultSettings = void 0;
|
||||||
const fs_1 = __importDefault(require("fs"));
|
const fs_1 = __importDefault(require("fs"));
|
||||||
const path_1 = require("path");
|
const path_1 = require("path");
|
||||||
const uuid_1 = require("uuid");
|
const uuid_1 = require("uuid");
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
const deemix_1 = __importDefault(require("deemix"));
|
const deemix_1 = __importDefault(require("deemix"));
|
||||||
const ws_1 = __importDefault(require("ws"));
|
const ws_1 = __importDefault(require("ws"));
|
||||||
|
const got_1 = __importDefault(require("got"));
|
||||||
const app_1 = require("./app");
|
const app_1 = require("./app");
|
||||||
const errors_1 = require("./helpers/errors");
|
const errors_1 = require("./helpers/errors");
|
||||||
const Downloader = deemix_1.default.downloader.Downloader;
|
const Downloader = deemix_1.default.downloader.Downloader;
|
||||||
@ -29,6 +30,28 @@ exports.sessionDZ = {};
|
|||||||
let settings = deemix_1.default.settings.load(exports.configFolder);
|
let settings = deemix_1.default.settings.load(exports.configFolder);
|
||||||
exports.getAccessToken = deemix_1.default.utils.deezer.getAccessToken;
|
exports.getAccessToken = deemix_1.default.utils.deezer.getAccessToken;
|
||||||
exports.getArlFromAccessToken = deemix_1.default.utils.deezer.getArlFromAccessToken;
|
exports.getArlFromAccessToken = deemix_1.default.utils.deezer.getArlFromAccessToken;
|
||||||
|
exports.deemixVersion = require('../../node_modules/deemix/package.json').version;
|
||||||
|
let deezerAvailable = null;
|
||||||
|
function isDeezerAvailable() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
if (deezerAvailable === null) {
|
||||||
|
let response;
|
||||||
|
try {
|
||||||
|
response = yield got_1.default.get('https://www.deezer.com/', {
|
||||||
|
headers: { Cookie: 'dz_lang=en; Domain=deezer.com; Path=/; Secure; hostOnly=false;' }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (_a) {
|
||||||
|
deezerAvailable = false;
|
||||||
|
return deezerAvailable;
|
||||||
|
}
|
||||||
|
const title = (response.body.match(/<title[^>]*>([^<]+)<\/title>/)[1] || '').trim();
|
||||||
|
deezerAvailable = title !== 'Deezer will soon be available in your country.';
|
||||||
|
}
|
||||||
|
return deezerAvailable;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.isDeezerAvailable = isDeezerAvailable;
|
||||||
exports.plugins = {
|
exports.plugins = {
|
||||||
// eslint-disable-next-line new-cap
|
// eslint-disable-next-line new-cap
|
||||||
spotify: new deemix_1.default.plugins.spotify()
|
spotify: new deemix_1.default.plugins.spotify()
|
||||||
|
2
server/dist/routes/api/post/login-arl.js
vendored
2
server/dist/routes/api/post/login-arl.js
vendored
@ -50,6 +50,8 @@ const handler = (req, res, _) => __awaiter(void 0, void 0, void 0, function* ()
|
|||||||
const testDz = new deezer_js_1.Deezer();
|
const testDz = new deezer_js_1.Deezer();
|
||||||
response = yield testDz.login_via_arl(...loginParams);
|
response = yield testDz.login_via_arl(...loginParams);
|
||||||
}
|
}
|
||||||
|
if (!(yield main_1.isDeezerAvailable()))
|
||||||
|
response = LoginStatus.NOT_AVAILABLE;
|
||||||
const returnValue = { status: response, arl: req.query.arl, user: dz.current_user };
|
const returnValue = { status: response, arl: req.query.arl, user: dz.current_user };
|
||||||
main_1.startQueue(dz);
|
main_1.startQueue(dz);
|
||||||
return res.status(200).send(returnValue);
|
return res.status(200).send(returnValue);
|
||||||
|
27
server/dist/routes/index.js
vendored
27
server/dist/routes/index.js
vendored
@ -1,4 +1,13 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
@ -8,6 +17,7 @@ const express_1 = __importDefault(require("express"));
|
|||||||
const deezer_js_1 = require("deezer-js");
|
const deezer_js_1 = require("deezer-js");
|
||||||
const main_1 = require("../main");
|
const main_1 = require("../main");
|
||||||
const router = express_1.default.Router();
|
const router = express_1.default.Router();
|
||||||
|
let update = null;
|
||||||
/**
|
/**
|
||||||
* GET home page
|
* GET home page
|
||||||
*
|
*
|
||||||
@ -16,25 +26,28 @@ const router = express_1.default.Router();
|
|||||||
router.get('/', (_, res) => {
|
router.get('/', (_, res) => {
|
||||||
res.render('index', { title: 'deemix' });
|
res.render('index', { title: 'deemix' });
|
||||||
});
|
});
|
||||||
router.get('/connect', (req, res) => {
|
router.get('/connect', (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
if (!main_1.sessionDZ[req.session.id])
|
if (!main_1.sessionDZ[req.session.id])
|
||||||
main_1.sessionDZ[req.session.id] = new deezer_js_1.Deezer();
|
main_1.sessionDZ[req.session.id] = new deezer_js_1.Deezer();
|
||||||
const dz = main_1.sessionDZ[req.session.id];
|
const dz = main_1.sessionDZ[req.session.id];
|
||||||
const result = {
|
if (!update) {
|
||||||
update: {
|
update = {
|
||||||
currentCommit: 'testing',
|
currentCommit: 'testing',
|
||||||
latestCommit: 'testing',
|
latestCommit: 'testing',
|
||||||
updateAvailable: false,
|
updateAvailable: false,
|
||||||
deemixVersion: '3.0_beta'
|
deemixVersion: main_1.deemixVersion
|
||||||
},
|
};
|
||||||
|
}
|
||||||
|
const result = {
|
||||||
|
update,
|
||||||
autologin: !dz.logged_in,
|
autologin: !dz.logged_in,
|
||||||
currentUser: dz.current_user,
|
currentUser: dz.current_user,
|
||||||
deezerNotAvailable: false
|
deezerAvailable: yield main_1.isDeezerAvailable()
|
||||||
};
|
};
|
||||||
const queue = main_1.getQueue();
|
const queue = main_1.getQueue();
|
||||||
if (Object.keys(queue.queue).length > 0) {
|
if (Object.keys(queue.queue).length > 0) {
|
||||||
result.queue = queue;
|
result.queue = queue;
|
||||||
}
|
}
|
||||||
res.send(result);
|
res.send(result);
|
||||||
});
|
}));
|
||||||
exports.default = router;
|
exports.default = router;
|
||||||
|
@ -20,18 +20,23 @@ export const getAccessToken = deemix.utils.deezer.getAccessToken
|
|||||||
export const getArlFromAccessToken = deemix.utils.deezer.getArlFromAccessToken
|
export const getArlFromAccessToken = deemix.utils.deezer.getArlFromAccessToken
|
||||||
|
|
||||||
export const deemixVersion = require('../../node_modules/deemix/package.json').version
|
export const deemixVersion = require('../../node_modules/deemix/package.json').version
|
||||||
export let deezerAvailable: boolean | null = null
|
let deezerAvailable: boolean | null = null
|
||||||
|
|
||||||
export async function isDeezerAvailable(): Promise<undefined>{
|
export async function isDeezerAvailable(): Promise<boolean> {
|
||||||
let response
|
if (deezerAvailable === null) {
|
||||||
try {
|
let response
|
||||||
response = await got.get('https://www.deezer.com/', {headers: {'Cookie': 'dz_lang=en; Domain=deezer.com; Path=/; Secure; hostOnly=false;'}})
|
try {
|
||||||
} catch {
|
response = await got.get('https://www.deezer.com/', {
|
||||||
deezerAvailable = false
|
headers: { Cookie: 'dz_lang=en; Domain=deezer.com; Path=/; Secure; hostOnly=false;' }
|
||||||
return
|
})
|
||||||
|
} catch {
|
||||||
|
deezerAvailable = false
|
||||||
|
return deezerAvailable
|
||||||
|
}
|
||||||
|
const title = (response.body.match(/<title[^>]*>([^<]+)<\/title>/)![1] || '').trim()
|
||||||
|
deezerAvailable = title !== 'Deezer will soon be available in your country.'
|
||||||
}
|
}
|
||||||
const title = (response.body.match(/<title[^>]*>([^<]+)<\/title>/)![1] || "").trim()
|
return deezerAvailable
|
||||||
deezerAvailable = title !== "Deezer will soon be available in your country."
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const plugins: any = {
|
export const plugins: any = {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { RequestHandler } from 'express'
|
import { RequestHandler } from 'express'
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import { Deezer } from 'deezer-js'
|
import { Deezer } from 'deezer-js'
|
||||||
import { sessionDZ, startQueue, deezerAvailable, isDeezerAvailable } from '../../../main'
|
import { sessionDZ, startQueue, isDeezerAvailable } from '../../../main'
|
||||||
import { ApiHandler } from '../../../types'
|
import { ApiHandler } from '../../../types'
|
||||||
|
|
||||||
export interface RawLoginArlQuery {
|
export interface RawLoginArlQuery {
|
||||||
@ -22,7 +22,6 @@ const path: ApiHandler['path'] = '/login-arl'
|
|||||||
const handler: RequestHandler<{}, {}, {}, RawLoginArlQuery> = async (req, res, _) => {
|
const handler: RequestHandler<{}, {}, {}, RawLoginArlQuery> = async (req, res, _) => {
|
||||||
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
||||||
const dz = sessionDZ[req.session.id]
|
const dz = sessionDZ[req.session.id]
|
||||||
if (deezerAvailable === null) await isDeezerAvailable()
|
|
||||||
|
|
||||||
if (!req.query) {
|
if (!req.query) {
|
||||||
return res.status(400).send()
|
return res.status(400).send()
|
||||||
@ -53,7 +52,7 @@ const handler: RequestHandler<{}, {}, {}, RawLoginArlQuery> = async (req, res, _
|
|||||||
const testDz = new Deezer()
|
const testDz = new Deezer()
|
||||||
response = await testDz.login_via_arl(...loginParams)
|
response = await testDz.login_via_arl(...loginParams)
|
||||||
}
|
}
|
||||||
if (!deezerAvailable) response = LoginStatus.NOT_AVAILABLE
|
if (!(await isDeezerAvailable())) response = LoginStatus.NOT_AVAILABLE
|
||||||
const returnValue = { status: response, arl: req.query.arl, user: dz.current_user }
|
const returnValue = { status: response, arl: req.query.arl, user: dz.current_user }
|
||||||
|
|
||||||
startQueue(dz)
|
startQueue(dz)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import express from 'express'
|
import express from 'express'
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import { Deezer } from 'deezer-js'
|
import { Deezer } from 'deezer-js'
|
||||||
import { sessionDZ, getQueue, deemixVersion, isDeezerAvailable, deezerAvailable } from '../main'
|
import { sessionDZ, getQueue, deemixVersion, isDeezerAvailable } from '../main'
|
||||||
|
|
||||||
const router = express.Router()
|
const router = express.Router()
|
||||||
let update: any = null
|
let update: any = null
|
||||||
@ -27,13 +27,12 @@ router.get('/connect', async (req, res) => {
|
|||||||
deemixVersion
|
deemixVersion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (deezerAvailable === null) await isDeezerAvailable()
|
|
||||||
|
|
||||||
const result: any = {
|
const result: any = {
|
||||||
update,
|
update,
|
||||||
autologin: !dz.logged_in,
|
autologin: !dz.logged_in,
|
||||||
currentUser: dz.current_user,
|
currentUser: dz.current_user,
|
||||||
deezerAvailable
|
deezerAvailable: await isDeezerAvailable()
|
||||||
}
|
}
|
||||||
|
|
||||||
const queue = getQueue()
|
const queue = getQueue()
|
||||||
|
Loading…
Reference in New Issue
Block a user