mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using VideoLinkDownloader.Core;
|
|
|
|
namespace VideoLinkDownloader
|
|
{
|
|
class VideoTask : NotificationObject
|
|
{
|
|
public VideoTask(Video video)
|
|
{
|
|
Downloader = new VideoDownloader(video);
|
|
Downloader.ProgressUpdate.Add(progress =>
|
|
{
|
|
Progress = progress;
|
|
});
|
|
}
|
|
public VideoDownloader Downloader { get; private set; }
|
|
|
|
private double progress = 0;
|
|
public double Progress
|
|
{
|
|
get => progress;
|
|
set
|
|
{
|
|
progress = value;
|
|
OnPropertyChanged(nameof(Progress));
|
|
OnPropertyChanged(nameof(SizeProgress));
|
|
}
|
|
}
|
|
public string Title => Downloader.Video.Title;
|
|
public string PercentProgress => $"{Math.Floor(Progress * 1000) / 10}%";
|
|
public string SizeProgress => $"{Downloader.DownloadedBytes.ToFileSize()} / {Downloader.Video.TotalSize.ToFileSize()}";
|
|
public async Task Download()
|
|
{
|
|
await Downloader.Download();
|
|
}
|
|
}
|
|
}
|