Added correct deemix lib version + check deezer availability
This commit is contained in:
parent
9b157c42bc
commit
6183f9b7a6
@ -54,7 +54,7 @@
|
|||||||
"electron-window-state-manager": "^0.3.2",
|
"electron-window-state-manager": "^0.3.2",
|
||||||
"cookie-parser": "1.4.5",
|
"cookie-parser": "1.4.5",
|
||||||
"debug": "2.6.9",
|
"debug": "2.6.9",
|
||||||
"deemix": "0.2.5",
|
"deemix": "3.0.0",
|
||||||
"deezer-js": "1.0.0",
|
"deezer-js": "1.0.0",
|
||||||
"dotenv": "8.2.0",
|
"dotenv": "8.2.0",
|
||||||
"express": "4.17.1",
|
"express": "4.17.1",
|
||||||
|
@ -4,6 +4,7 @@ import { v4 as uuidv4 } from 'uuid'
|
|||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import deemix from 'deemix'
|
import deemix from 'deemix'
|
||||||
import WebSocket from 'ws'
|
import WebSocket from 'ws'
|
||||||
|
import got from 'got'
|
||||||
import { wss } from './app'
|
import { wss } from './app'
|
||||||
import { Settings } from './types'
|
import { Settings } from './types'
|
||||||
import { NotLoggedIn } from './helpers/errors'
|
import { NotLoggedIn } from './helpers/errors'
|
||||||
@ -18,6 +19,21 @@ let settings: any = deemix.settings.load(configFolder)
|
|||||||
export const getAccessToken = deemix.utils.deezer.getAccessToken
|
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 let deezerAvailable: boolean | null = null
|
||||||
|
|
||||||
|
export async function isDeezerAvailable(): Promise<undefined>{
|
||||||
|
let response
|
||||||
|
try {
|
||||||
|
response = await got.get('https://www.deezer.com/', {headers: {'Cookie': 'dz_lang=en; Domain=deezer.com; Path=/; Secure; hostOnly=false;'}})
|
||||||
|
} catch {
|
||||||
|
deezerAvailable = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const title = (response.body.match(/<title[^>]*>([^<]+)<\/title>/)![1] || "").trim()
|
||||||
|
deezerAvailable = title !== "Deezer will soon be available in your country."
|
||||||
|
}
|
||||||
|
|
||||||
export const plugins: any = {
|
export const plugins: any = {
|
||||||
// eslint-disable-next-line new-cap
|
// eslint-disable-next-line new-cap
|
||||||
spotify: new deemix.plugins.spotify()
|
spotify: new deemix.plugins.spotify()
|
||||||
|
@ -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 } from '../../../main'
|
import { sessionDZ, startQueue, deezerAvailable, isDeezerAvailable } from '../../../main'
|
||||||
import { ApiHandler } from '../../../types'
|
import { ApiHandler } from '../../../types'
|
||||||
|
|
||||||
export interface RawLoginArlQuery {
|
export interface RawLoginArlQuery {
|
||||||
@ -22,6 +22,7 @@ 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()
|
||||||
@ -52,6 +53,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
|
||||||
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,9 +1,10 @@
|
|||||||
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 } from '../main'
|
import { sessionDZ, getQueue, deemixVersion, isDeezerAvailable, deezerAvailable } from '../main'
|
||||||
|
|
||||||
const router = express.Router()
|
const router = express.Router()
|
||||||
|
let update: any = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GET home page
|
* GET home page
|
||||||
@ -14,20 +15,25 @@ router.get('/', (_, res) => {
|
|||||||
res.render('index', { title: 'deemix' })
|
res.render('index', { title: 'deemix' })
|
||||||
})
|
})
|
||||||
|
|
||||||
router.get('/connect', (req, res) => {
|
router.get('/connect', 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]
|
||||||
|
|
||||||
const result: any = {
|
if (!update) {
|
||||||
update: {
|
update = {
|
||||||
currentCommit: 'testing',
|
currentCommit: 'testing',
|
||||||
latestCommit: 'testing',
|
latestCommit: 'testing',
|
||||||
updateAvailable: false,
|
updateAvailable: false,
|
||||||
deemixVersion: '3.0_beta'
|
deemixVersion
|
||||||
},
|
}
|
||||||
|
}
|
||||||
|
if (deezerAvailable === null) await isDeezerAvailable()
|
||||||
|
|
||||||
|
const result: any = {
|
||||||
|
update,
|
||||||
autologin: !dz.logged_in,
|
autologin: !dz.logged_in,
|
||||||
currentUser: dz.current_user,
|
currentUser: dz.current_user,
|
||||||
deezerNotAvailable: false
|
deezerAvailable
|
||||||
}
|
}
|
||||||
|
|
||||||
const queue = getQueue()
|
const queue = getQueue()
|
||||||
|
2
webui
2
webui
@ -1 +1 @@
|
|||||||
Subproject commit 03da7e24df57fa2d508ad4bb87a5bda1a0bbd130
|
Subproject commit b677f422a2faafc83b9c5142b63a17803a9f7d8a
|
@ -2269,10 +2269,10 @@ decompress-response@^6.0.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
mimic-response "^3.1.0"
|
mimic-response "^3.1.0"
|
||||||
|
|
||||||
deemix@0.2.5:
|
deemix@3.0.0:
|
||||||
version "0.2.5"
|
version "3.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/deemix/-/deemix-0.2.5.tgz#d7e8c97de087d32b0030f3c0062a7e8ea6268ca6"
|
resolved "https://registry.yarnpkg.com/deemix/-/deemix-3.0.0.tgz#4a0ae0d5ebb75331b8909f60bbe444a0557ae201"
|
||||||
integrity sha512-BsxtCoXJ2wCxqiWEZYC6n+4wqr0Z6cpqqY6DgE4DGQGG6u+5shwew9/IGGtq47jAx1ysrJwz03FhdSnQTAXUTQ==
|
integrity sha512-tRtx6brWVm2ZMh79E61gXQGs2tD7h12TL9jmrRtucK9fZxZl59mH4S0QIZeLLovjF4/13MCWwtx/QvFLauM96g==
|
||||||
dependencies:
|
dependencies:
|
||||||
async "^3.2.0"
|
async "^3.2.0"
|
||||||
crypto "^1.0.1"
|
crypto "^1.0.1"
|
||||||
|
Loading…
Reference in New Issue
Block a user