Files
youtube-dl-gui/modules/types/ProgressBar.js

35 lines
1.1 KiB
JavaScript

class ProgressBar {
constructor(manager, video) {
this.manager = manager;
this.video = video;
}
updatePlaylist(done, total) {
let percent = ((done / total) * 100).toFixed(2) + "%";
this.manager.updateProgress(this.video, {percentage: percent, done: done, total: total, isPlaylist: this.isUnifiedPlaylist()});
}
updateDownload(percentage, eta, speed, isAudio) {
this.manager.updateProgress(this.video, {percentage: percentage, eta: eta, speed: speed, isAudio: this.video.formats.length === 0 ? null : isAudio});
}
reset() {
this.manager.updateProgress(this.video, {reset: true})
}
done(isAudio) {
let audio = isAudio;
if(!this.isUnifiedPlaylist()) audio = this.video.formats.length === 0 ? null : isAudio;
this.manager.updateProgress(this.video, {finished: true, isAudio: audio, isPlaylist: this.isUnifiedPlaylist()})
}
isUnifiedPlaylist() {
if(typeof this.video === "string") {
return true;
} else {
return this.video.videos != null;
}
}
}
module.exports = ProgressBar;