Add - Added "Remove Finished" to download queue
Fix - Fixed a crash when muxing title wasn't set
This commit is contained in:
parent
29aac7ed8f
commit
89c7b1021f
|
@ -44,7 +44,6 @@ public class Crunchyroll{
|
||||||
public RefreshableObservableCollection<CrunchyEpMeta> Queue = new RefreshableObservableCollection<CrunchyEpMeta>();
|
public RefreshableObservableCollection<CrunchyEpMeta> Queue = new RefreshableObservableCollection<CrunchyEpMeta>();
|
||||||
public ObservableCollection<DownloadItemModel> DownloadItemModels = new ObservableCollection<DownloadItemModel>();
|
public ObservableCollection<DownloadItemModel> DownloadItemModels = new ObservableCollection<DownloadItemModel>();
|
||||||
public int ActiveDownloads;
|
public int ActiveDownloads;
|
||||||
public bool AutoDownload = false;
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -103,6 +102,10 @@ public class Crunchyroll{
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public Crunchyroll(){
|
||||||
|
CrunOptions = new CrDownloadOptions();
|
||||||
|
}
|
||||||
|
|
||||||
public async Task Init(){
|
public async Task Init(){
|
||||||
_widevine = Widevine.Instance;
|
_widevine = Widevine.Instance;
|
||||||
|
|
||||||
|
@ -129,8 +132,8 @@ public class Crunchyroll{
|
||||||
|
|
||||||
Console.WriteLine($"Can Decrypt: {_widevine.canDecrypt}");
|
Console.WriteLine($"Can Decrypt: {_widevine.canDecrypt}");
|
||||||
|
|
||||||
CrunOptions = new CrDownloadOptions();
|
CrunOptions.AutoDownload = false;
|
||||||
|
CrunOptions.RemoveFinishedDownload = false;
|
||||||
CrunOptions.Chapters = true;
|
CrunOptions.Chapters = true;
|
||||||
CrunOptions.Hslang = "none";
|
CrunOptions.Hslang = "none";
|
||||||
CrunOptions.Force = "Y";
|
CrunOptions.Force = "Y";
|
||||||
|
@ -441,6 +444,10 @@ public class Crunchyroll{
|
||||||
Doing = "Done"
|
Doing = "Done"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (CrunOptions.RemoveFinishedDownload){
|
||||||
|
Queue.Remove(data);
|
||||||
|
}
|
||||||
|
|
||||||
Queue.Refresh();
|
Queue.Refresh();
|
||||||
} else{
|
} else{
|
||||||
Console.WriteLine("Skipping mux");
|
Console.WriteLine("Skipping mux");
|
||||||
|
@ -1384,7 +1391,7 @@ public class Crunchyroll{
|
||||||
Error = dlFailed,
|
Error = dlFailed,
|
||||||
FileName = fileName.Length > 0 ? (Path.IsPathRooted(fileName) ? fileName : Path.Combine(fileDir, fileName)) : "./unknown",
|
FileName = fileName.Length > 0 ? (Path.IsPathRooted(fileName) ? fileName : Path.Combine(fileDir, fileName)) : "./unknown",
|
||||||
ErrorText = "",
|
ErrorText = "",
|
||||||
VideoTitle = FileNameManager.ParseFileName(options.VideoTitle, variables, options.Numbers, options.Override).Last()
|
VideoTitle = FileNameManager.ParseFileName(options.VideoTitle ?? "", variables, options.Numbers, options.Override).Last()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,15 @@ using YamlDotNet.Serialization;
|
||||||
namespace CRD.Utils.Structs;
|
namespace CRD.Utils.Structs;
|
||||||
|
|
||||||
public class CrDownloadOptions{
|
public class CrDownloadOptions{
|
||||||
|
|
||||||
|
[YamlIgnore]
|
||||||
|
public bool AutoDownload{ get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
[YamlIgnore]
|
||||||
|
public bool RemoveFinishedDownload{ get; set; }
|
||||||
|
|
||||||
|
|
||||||
[YamlMember(Alias = "hard_sub_lang", ApplyNamingConventions = false)]
|
[YamlMember(Alias = "hard_sub_lang", ApplyNamingConventions = false)]
|
||||||
public string Hslang{ get; set; }
|
public string Hslang{ get; set; }
|
||||||
|
|
||||||
|
|
|
@ -18,18 +18,19 @@ using CRD.Utils.Structs;
|
||||||
namespace CRD.ViewModels;
|
namespace CRD.ViewModels;
|
||||||
|
|
||||||
public partial class DownloadsPageViewModel : ViewModelBase{
|
public partial class DownloadsPageViewModel : ViewModelBase{
|
||||||
|
|
||||||
|
|
||||||
public ObservableCollection<DownloadItemModel> Items{ get; }
|
public ObservableCollection<DownloadItemModel> Items{ get; }
|
||||||
|
|
||||||
[ObservableProperty] public bool _autoDownload;
|
[ObservableProperty]
|
||||||
|
public bool _autoDownload;
|
||||||
|
|
||||||
private SemaphoreSlim semaphore = new SemaphoreSlim(1, 1);
|
[ObservableProperty]
|
||||||
|
public bool _removeFinished;
|
||||||
|
|
||||||
public DownloadsPageViewModel(){
|
public DownloadsPageViewModel(){
|
||||||
UpdateListItems();
|
UpdateListItems();
|
||||||
Items = Crunchyroll.Instance.DownloadItemModels;
|
Items = Crunchyroll.Instance.DownloadItemModels;
|
||||||
AutoDownload = Crunchyroll.Instance.AutoDownload;
|
AutoDownload = Crunchyroll.Instance.CrunOptions.AutoDownload;
|
||||||
|
RemoveFinished = Crunchyroll.Instance.CrunOptions.RemoveFinishedDownload;
|
||||||
Crunchyroll.Instance.Queue.CollectionChanged += UpdateItemListOnRemove;
|
Crunchyroll.Instance.Queue.CollectionChanged += UpdateItemListOnRemove;
|
||||||
// Items.Add(new DownloadItemModel{Title = "Test - S1E1"});
|
// Items.Add(new DownloadItemModel{Title = "Test - S1E1"});
|
||||||
}
|
}
|
||||||
|
@ -64,19 +65,23 @@ public partial class DownloadsPageViewModel : ViewModelBase{
|
||||||
Crunchyroll.Instance.DownloadItemModels.Add(downloadItem);
|
Crunchyroll.Instance.DownloadItemModels.Add(downloadItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (downloadItem is{ isDownloading: false, Error: false } && Crunchyroll.Instance.AutoDownload && Crunchyroll.Instance.ActiveDownloads < Crunchyroll.Instance.CrunOptions.SimultaneousDownloads){
|
if (downloadItem is{ isDownloading: false, Error: false } && Crunchyroll.Instance.CrunOptions.AutoDownload && Crunchyroll.Instance.ActiveDownloads < Crunchyroll.Instance.CrunOptions.SimultaneousDownloads){
|
||||||
downloadItem.StartDownload();
|
downloadItem.StartDownload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
partial void OnAutoDownloadChanged(bool value){
|
partial void OnAutoDownloadChanged(bool value){
|
||||||
Crunchyroll.Instance.AutoDownload = value;
|
Crunchyroll.Instance.CrunOptions.AutoDownload = value;
|
||||||
if (value){
|
if (value){
|
||||||
UpdateListItems();
|
UpdateListItems();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
partial void OnRemoveFinishedChanged(bool value){
|
||||||
|
Crunchyroll.Instance.CrunOptions.RemoveFinishedDownload = value;
|
||||||
|
}
|
||||||
|
|
||||||
public void Cleanup(){
|
public void Cleanup(){
|
||||||
Crunchyroll.Instance.Queue.CollectionChanged -= UpdateItemListOnRemove;
|
Crunchyroll.Instance.Queue.CollectionChanged -= UpdateItemListOnRemove;
|
||||||
}
|
}
|
||||||
|
@ -190,20 +195,16 @@ public partial class DownloadItemModel : INotifyPropertyChanged{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public event PropertyChangedEventHandler? PropertyChanged;
|
public event PropertyChangedEventHandler? PropertyChanged;
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
public void ToggleIsDownloading(){
|
public void ToggleIsDownloading(){
|
||||||
|
|
||||||
if (isDownloading){
|
if (isDownloading){
|
||||||
//StopDownload();
|
//StopDownload();
|
||||||
epMeta.Paused = !epMeta.Paused;
|
epMeta.Paused = !epMeta.Paused;
|
||||||
|
|
||||||
Paused = epMeta.Paused || !isDownloading && !epMeta.Paused;
|
Paused = epMeta.Paused || !isDownloading && !epMeta.Paused;
|
||||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Paused)));
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Paused)));
|
||||||
|
|
||||||
} else{
|
} else{
|
||||||
if (epMeta.Paused){
|
if (epMeta.Paused){
|
||||||
epMeta.Paused = false;
|
epMeta.Paused = false;
|
||||||
|
@ -218,7 +219,6 @@ public partial class DownloadItemModel : INotifyPropertyChanged{
|
||||||
if (PropertyChanged != null){
|
if (PropertyChanged != null){
|
||||||
PropertyChanged.Invoke(this, new PropertyChangedEventArgs("isDownloading"));
|
PropertyChanged.Invoke(this, new PropertyChangedEventArgs("isDownloading"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void StartDownload(){
|
public async void StartDownload(){
|
||||||
|
@ -229,7 +229,6 @@ public partial class DownloadItemModel : INotifyPropertyChanged{
|
||||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Paused)));
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Paused)));
|
||||||
await Crunchyroll.Instance.DownloadEpisode(epMeta, Crunchyroll.Instance.CrunOptions);
|
await Crunchyroll.Instance.DownloadEpisode(epMeta, Crunchyroll.Instance.CrunOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
|
|
|
@ -21,8 +21,9 @@
|
||||||
<RowDefinition Height="*" /> <!-- For the ListBox to take remaining space -->
|
<RowDefinition Height="*" /> <!-- For the ListBox to take remaining space -->
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<StackPanel Grid.Row="0">
|
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||||
<!-- <Button Click="Button_OnClick">Test Download</Button> -->
|
<!-- <Button Click="Button_OnClick">Test Download</Button> -->
|
||||||
|
<ToggleSwitch HorizontalAlignment="Right" Margin="0 0 10 0 " IsChecked="{Binding RemoveFinished}" OffContent="Remove Finished" OnContent="Remove Finished"></ToggleSwitch>
|
||||||
<ToggleSwitch HorizontalAlignment="Right" Margin="0 0 10 0 " IsChecked="{Binding AutoDownload}" OffContent="Auto Download" OnContent="Auto Download"></ToggleSwitch>
|
<ToggleSwitch HorizontalAlignment="Right" Margin="0 0 10 0 " IsChecked="{Binding AutoDownload}" OffContent="Auto Download" OnContent="Auto Download"></ToggleSwitch>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue