mirror of
https://gitlab.com/RemixDev/deemix-js.git
synced 2025-02-16 10:20:06 +00:00
Fixed download progress display
This commit is contained in:
parent
9584e8501f
commit
e97dad3873
deemix
|
@ -63,9 +63,7 @@ async function streamTrack(outputStream, track, start=0, downloadObject, listene
|
||||||
}else {
|
}else {
|
||||||
console.log(`${itemName} downloading ${complete} bytes`)
|
console.log(`${itemName} downloading ${complete} bytes`)
|
||||||
}
|
}
|
||||||
}).on("readable", ()=>{
|
}).on('data', function(chunk){
|
||||||
let chunk;
|
|
||||||
while ((chunk = response.read(2048 * 3))){
|
|
||||||
chunkLength += chunk.length
|
chunkLength += chunk.length
|
||||||
|
|
||||||
if (downloadObject){
|
if (downloadObject){
|
||||||
|
@ -79,7 +77,6 @@ async function streamTrack(outputStream, track, start=0, downloadObject, listene
|
||||||
}
|
}
|
||||||
downloadObject.updateProgress(listener)
|
downloadObject.updateProgress(listener)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -152,7 +152,7 @@ class Downloader {
|
||||||
await q.drain()
|
await q.drain()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.listener) this.listener.send("finishedDownload", this.downloadObject.uuid)
|
if (this.listener) this.listener.send("finishDownload", this.downloadObject.uuid)
|
||||||
}
|
}
|
||||||
|
|
||||||
async download(extraData, track){
|
async download(extraData, track){
|
||||||
|
@ -265,6 +265,15 @@ class Downloader {
|
||||||
} else if (extension == '.flac'){
|
} else if (extension == '.flac'){
|
||||||
tagFLAC(writepath, track, this.settings.tags)
|
tagFLAC(writepath, track, this.settings.tags)
|
||||||
}
|
}
|
||||||
|
this.downloadObject.downloadObject += 1
|
||||||
|
this.downloadObject.files.push(String(writepath))
|
||||||
|
if (this.listener)
|
||||||
|
this.listener.send('updateQueue', {
|
||||||
|
uuid: this.downloadObject.uuid,
|
||||||
|
downloaded: true,
|
||||||
|
downloadPath: String(writepath),
|
||||||
|
extrasPath: String(this.extrasPath)
|
||||||
|
})
|
||||||
|
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ class IDownloadObject{
|
||||||
updateProgress(listener){
|
updateProgress(listener){
|
||||||
if (Math.round(this.progressNext) != this.progress && Math.round(this.progressNext) % 2 == 0){
|
if (Math.round(this.progressNext) != this.progress && Math.round(this.progressNext) % 2 == 0){
|
||||||
this.progress = Math.round(this.progressNext)
|
this.progress = Math.round(this.progressNext)
|
||||||
if (listener) listener.emit('updateQueue', {uuid: this.uuid, progress: this.progress})
|
if (listener) listener.send('updateQueue', {uuid: this.uuid, progress: this.progress})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue