Added support for ; separated urls
This commit is contained in:
parent
6fa5057697
commit
b9720ef781
@ -22,6 +22,7 @@
|
|||||||
"express-session": "^1.17.1",
|
"express-session": "^1.17.1",
|
||||||
"morgan": "1.10.0",
|
"morgan": "1.10.0",
|
||||||
"ramda": "0.27.1",
|
"ramda": "0.27.1",
|
||||||
|
"uuid": "8.3.2",
|
||||||
"ws": "7.4.5"
|
"ws": "7.4.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -35,6 +36,7 @@
|
|||||||
"@types/node": "14.14.37",
|
"@types/node": "14.14.37",
|
||||||
"@types/ramda": "0.27.40",
|
"@types/ramda": "0.27.40",
|
||||||
"@types/supertest": "2.0.11",
|
"@types/supertest": "2.0.11",
|
||||||
|
"@types/uuid": "8.3.0",
|
||||||
"@types/ws": "7.4.1",
|
"@types/ws": "7.4.1",
|
||||||
"@typescript-eslint/eslint-plugin": "4.21.0",
|
"@typescript-eslint/eslint-plugin": "4.21.0",
|
||||||
"@typescript-eslint/parser": "4.21.0",
|
"@typescript-eslint/parser": "4.21.0",
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import { sep } from 'path'
|
import { sep } from 'path'
|
||||||
|
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'
|
||||||
@ -38,16 +39,33 @@ export let currentJob: any = null
|
|||||||
|
|
||||||
restoreQueueFromDisk()
|
restoreQueueFromDisk()
|
||||||
|
|
||||||
export async function addToQueue(dz: any, url: string, bitrate: number) {
|
export async function addToQueue(dz: any, url: string[], bitrate: number) {
|
||||||
if (!dz.logged_in) throw new NotLoggedIn()
|
if (!dz.logged_in) throw new NotLoggedIn()
|
||||||
console.log(`Adding ${url} to queue`)
|
|
||||||
let downloadObjs = await deemix.generateDownloadObject(dz, url, bitrate, deemixPlugins, listener)
|
|
||||||
console.log({ downloadObjs })
|
|
||||||
const isSingleObject = !Array.isArray(downloadObjs)
|
|
||||||
console.log(downloadObjs)
|
|
||||||
|
|
||||||
if (isSingleObject) downloadObjs = [downloadObjs]
|
let downloadObjs: any[] = []
|
||||||
|
let link: string = ""
|
||||||
|
const requestUUID = uuidv4()
|
||||||
|
|
||||||
|
if (url.length > 1){
|
||||||
|
listener.send("startGeneratingItems", {uuid: requestUUID, total: url.length})
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = 0; i < url.length; i++){
|
||||||
|
link = url[i]
|
||||||
|
console.log(`Adding ${link} to queue`)
|
||||||
|
let downloadObj = await deemix.generateDownloadObject(dz, link, bitrate, deemixPlugins, listener)
|
||||||
|
if (Array.isArray(downloadObj)){
|
||||||
|
downloadObjs.concat(downloadObj)
|
||||||
|
} else {
|
||||||
|
downloadObjs.push(downloadObj)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (url.length > 1){
|
||||||
|
listener.send("finishGeneratingItems", {uuid: requestUUID, total: downloadObjs.length})
|
||||||
|
}
|
||||||
|
|
||||||
|
const isSingleObject = downloadObjs.length == 1
|
||||||
const slimmedObjects: any[] = []
|
const slimmedObjects: any[] = []
|
||||||
|
|
||||||
downloadObjs.forEach((downloadObj: any) => {
|
downloadObjs.forEach((downloadObj: any) => {
|
||||||
|
@ -9,7 +9,7 @@ const handler: ApiHandler['handler'] = 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 url = req.query.url
|
const url = req.query.url.split(';')
|
||||||
let bitrate = req.query.bitrate
|
let bitrate = req.query.bitrate
|
||||||
if (bitrate === 'null') bitrate = settings.maxBitrate
|
if (bitrate === 'null') bitrate = settings.maxBitrate
|
||||||
let obj: any
|
let obj: any
|
||||||
|
@ -837,6 +837,11 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@types/superagent" "*"
|
"@types/superagent" "*"
|
||||||
|
|
||||||
|
"@types/uuid@8.3.0":
|
||||||
|
version "8.3.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-8.3.0.tgz#215c231dff736d5ba92410e6d602050cce7e273f"
|
||||||
|
integrity sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==
|
||||||
|
|
||||||
"@types/ws@7.4.1":
|
"@types/ws@7.4.1":
|
||||||
version "7.4.1"
|
version "7.4.1"
|
||||||
resolved "https://registry.yarnpkg.com/@types/ws/-/ws-7.4.1.tgz#49eacb15a0534663d53a36fbf5b4d98f5ae9a73a"
|
resolved "https://registry.yarnpkg.com/@types/ws/-/ws-7.4.1.tgz#49eacb15a0534663d53a36fbf5b4d98f5ae9a73a"
|
||||||
@ -6185,16 +6190,16 @@ utils-merge@1.0.1:
|
|||||||
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
|
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
|
||||||
integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=
|
integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=
|
||||||
|
|
||||||
|
uuid@8.3.2, uuid@^8.3.0:
|
||||||
|
version "8.3.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
|
||||||
|
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
|
||||||
|
|
||||||
uuid@^3.3.2:
|
uuid@^3.3.2:
|
||||||
version "3.4.0"
|
version "3.4.0"
|
||||||
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
|
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
|
||||||
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==
|
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==
|
||||||
|
|
||||||
uuid@^8.3.0:
|
|
||||||
version "8.3.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
|
|
||||||
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
|
|
||||||
|
|
||||||
v8-compile-cache@^2.0.3:
|
v8-compile-cache@^2.0.3:
|
||||||
version "2.3.0"
|
version "2.3.0"
|
||||||
resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee"
|
resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee"
|
||||||
|
Loading…
Reference in New Issue
Block a user