2024-07-06 18:48:58 +00:00
|
|
|
using System;
|
2024-05-04 15:35:32 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
using System.Collections.Specialized;
|
2024-06-19 00:16:02 +00:00
|
|
|
using System.ComponentModel;
|
2024-08-20 16:40:45 +00:00
|
|
|
using System.IO;
|
2024-05-04 15:35:32 +00:00
|
|
|
using System.Linq;
|
|
|
|
using System.Net.Mime;
|
|
|
|
using System.Reflection;
|
2024-06-21 01:49:44 +00:00
|
|
|
using System.Threading.Tasks;
|
2024-05-04 15:35:32 +00:00
|
|
|
using Avalonia;
|
|
|
|
using Avalonia.Controls;
|
|
|
|
using Avalonia.Media;
|
2024-06-21 01:49:44 +00:00
|
|
|
using Avalonia.Platform.Storage;
|
2024-05-04 15:35:32 +00:00
|
|
|
using Avalonia.Styling;
|
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
2024-06-11 21:58:44 +00:00
|
|
|
using CommunityToolkit.Mvvm.Input;
|
2024-05-04 15:35:32 +00:00
|
|
|
using CRD.Downloader;
|
2024-07-21 09:30:20 +00:00
|
|
|
using CRD.Downloader.Crunchyroll;
|
2024-05-04 15:35:32 +00:00
|
|
|
using CRD.Utils;
|
2024-07-16 23:52:46 +00:00
|
|
|
using CRD.Utils.CustomList;
|
2024-05-25 22:02:45 +00:00
|
|
|
using CRD.Utils.Sonarr;
|
2024-05-04 15:35:32 +00:00
|
|
|
using CRD.Utils.Structs;
|
2024-08-20 16:40:45 +00:00
|
|
|
using CRD.Utils.Structs.History;
|
2024-05-04 15:35:32 +00:00
|
|
|
using FluentAvalonia.Styling;
|
|
|
|
|
|
|
|
namespace CRD.ViewModels;
|
|
|
|
|
|
|
|
public partial class SettingsPageViewModel : ViewModelBase{
|
2024-05-22 21:22:02 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private string _currentVersion;
|
2024-05-04 15:35:32 +00:00
|
|
|
|
2024-05-22 21:22:02 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private bool _downloadVideo = true;
|
2024-05-04 15:35:32 +00:00
|
|
|
|
2024-05-22 21:22:02 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private bool _downloadAudio = true;
|
2024-05-04 15:35:32 +00:00
|
|
|
|
2024-05-22 21:22:02 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private bool _downloadChapters = true;
|
2024-06-21 01:49:44 +00:00
|
|
|
|
2024-06-19 10:37:06 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private bool _addScaledBorderAndShadow = false;
|
2024-06-21 01:49:44 +00:00
|
|
|
|
2024-06-24 15:40:20 +00:00
|
|
|
[ObservableProperty]
|
2024-08-09 21:16:13 +00:00
|
|
|
private bool _includeSignSubs;
|
2024-08-20 16:40:45 +00:00
|
|
|
|
2024-08-09 21:16:13 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private bool _includeCcSubs;
|
2024-08-20 16:40:45 +00:00
|
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
private bool _downloadToTempFolder;
|
2024-06-24 15:40:20 +00:00
|
|
|
|
2024-06-19 10:37:06 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private ComboBoxItem _selectedScaledBorderAndShadow;
|
2024-06-21 01:49:44 +00:00
|
|
|
|
2024-06-19 10:37:06 +00:00
|
|
|
public ObservableCollection<ComboBoxItem> ScaledBorderAndShadow{ get; } = new(){
|
|
|
|
new ComboBoxItem(){ Content = "ScaledBorderAndShadow: yes" },
|
|
|
|
new ComboBoxItem(){ Content = "ScaledBorderAndShadow: no" },
|
|
|
|
};
|
2024-05-04 15:35:32 +00:00
|
|
|
|
2024-05-22 21:22:02 +00:00
|
|
|
[ObservableProperty]
|
2024-05-24 22:46:11 +00:00
|
|
|
private bool _muxToMp4;
|
2024-08-20 16:40:45 +00:00
|
|
|
|
2024-07-16 23:52:46 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private bool _syncTimings;
|
|
|
|
|
2024-07-26 00:18:39 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private bool _defaultSubSigns;
|
2024-08-20 16:40:45 +00:00
|
|
|
|
2024-07-26 04:05:05 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private bool _defaultSubForcedDisplay;
|
2024-07-06 18:48:58 +00:00
|
|
|
|
2024-06-24 15:40:20 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private bool _includeEpisodeDescription;
|
2024-06-21 01:49:44 +00:00
|
|
|
|
2024-06-19 00:16:02 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private bool _downloadVideoForEveryDub;
|
2024-08-20 16:40:45 +00:00
|
|
|
|
2024-08-05 03:06:40 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private bool _keepDubsSeparate;
|
2024-06-19 00:16:02 +00:00
|
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
private bool _skipSubMux;
|
2024-05-04 15:35:32 +00:00
|
|
|
|
2024-05-22 21:22:02 +00:00
|
|
|
[ObservableProperty]
|
2024-05-24 22:46:11 +00:00
|
|
|
private bool _history;
|
2024-08-20 16:40:45 +00:00
|
|
|
|
2024-07-24 13:19:18 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private bool _historyAddSpecials;
|
2024-06-21 01:49:44 +00:00
|
|
|
|
2024-08-05 03:06:40 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private bool _historyCountSonarr;
|
|
|
|
|
2024-05-22 21:22:02 +00:00
|
|
|
[ObservableProperty]
|
2024-07-06 18:48:58 +00:00
|
|
|
private double? _leadingNumbers;
|
|
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
private double? _simultaneousDownloads;
|
2024-05-04 15:35:32 +00:00
|
|
|
|
2024-05-22 21:22:02 +00:00
|
|
|
[ObservableProperty]
|
2024-07-06 18:48:58 +00:00
|
|
|
private double? _downloadSpeed;
|
2024-05-04 15:35:32 +00:00
|
|
|
|
2024-05-22 21:22:02 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private string _fileName = "";
|
2024-07-06 18:48:58 +00:00
|
|
|
|
2024-06-24 15:40:20 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private string _fileTitle = "";
|
2024-05-04 15:35:32 +00:00
|
|
|
|
2024-05-22 21:22:02 +00:00
|
|
|
[ObservableProperty]
|
2024-06-19 00:16:02 +00:00
|
|
|
private ObservableCollection<MuxingParam> _mkvMergeOptions = new();
|
|
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
private string _mkvMergeOption = "";
|
|
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
private string _ffmpegOption = "";
|
2024-05-04 15:35:32 +00:00
|
|
|
|
2024-05-22 21:22:02 +00:00
|
|
|
[ObservableProperty]
|
2024-06-19 00:16:02 +00:00
|
|
|
private ObservableCollection<MuxingParam> _ffmpegOptions = new();
|
2024-05-04 15:35:32 +00:00
|
|
|
|
2024-05-22 21:22:02 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private string _selectedSubs = "all";
|
2024-05-04 15:35:32 +00:00
|
|
|
|
2024-05-22 21:22:02 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private ComboBoxItem _selectedHSLang;
|
2024-07-06 18:48:58 +00:00
|
|
|
|
2024-06-27 20:52:12 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private ComboBoxItem _selectedHistoryLang;
|
2024-07-06 18:48:58 +00:00
|
|
|
|
2024-06-27 20:52:12 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private ComboBoxItem _selectedDescriptionLang;
|
2024-08-20 16:40:45 +00:00
|
|
|
|
2024-05-22 21:22:02 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private string _selectedDubs = "ja-JP";
|
2024-05-04 15:35:32 +00:00
|
|
|
|
2024-05-22 21:22:02 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private ObservableCollection<ListBoxItem> _selectedDubLang = new();
|
2024-05-04 15:35:32 +00:00
|
|
|
|
2024-06-19 01:50:10 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private ComboBoxItem _selectedStreamEndpoint;
|
2024-06-21 01:49:44 +00:00
|
|
|
|
2024-06-19 00:16:02 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private ComboBoxItem _selectedDefaultDubLang;
|
|
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
private ComboBoxItem _selectedDefaultSubLang;
|
|
|
|
|
2024-05-22 21:22:02 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private ComboBoxItem? _selectedVideoQuality;
|
2024-05-04 15:35:32 +00:00
|
|
|
|
2024-05-22 21:22:02 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private ComboBoxItem? _selectedAudioQuality;
|
2024-05-04 15:35:32 +00:00
|
|
|
|
2024-05-22 21:22:02 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private ComboBoxItem? _currentAppTheme;
|
2024-05-04 15:35:32 +00:00
|
|
|
|
2024-05-22 21:22:02 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private ObservableCollection<ListBoxItem> _selectedSubLang = new();
|
|
|
|
|
|
|
|
[ObservableProperty]
|
2024-05-24 22:46:11 +00:00
|
|
|
private bool _useCustomAccent;
|
2024-05-22 21:22:02 +00:00
|
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
private Color _listBoxColor;
|
|
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
private Color _customAccentColor = Colors.SlateBlue;
|
2024-05-04 15:35:32 +00:00
|
|
|
|
2024-05-25 22:02:45 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private string _sonarrHost = "localhost";
|
|
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
private string _sonarrPort = "8989";
|
|
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
private string _sonarrApiKey = "";
|
|
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
private bool _sonarrUseSsl = false;
|
|
|
|
|
2024-06-11 21:58:44 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private bool _sonarrUseSonarrNumbering = false;
|
2024-06-19 00:16:02 +00:00
|
|
|
|
2024-06-15 13:55:39 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private bool _logMode = false;
|
2024-06-11 21:58:44 +00:00
|
|
|
|
2024-05-04 15:35:32 +00:00
|
|
|
public ObservableCollection<Color> PredefinedColors{ get; } = new(){
|
|
|
|
Color.FromRgb(255, 185, 0),
|
|
|
|
Color.FromRgb(255, 140, 0),
|
|
|
|
Color.FromRgb(247, 99, 12),
|
|
|
|
Color.FromRgb(202, 80, 16),
|
|
|
|
Color.FromRgb(218, 59, 1),
|
|
|
|
Color.FromRgb(239, 105, 80),
|
|
|
|
Color.FromRgb(209, 52, 56),
|
|
|
|
Color.FromRgb(255, 67, 67),
|
|
|
|
Color.FromRgb(231, 72, 86),
|
|
|
|
Color.FromRgb(232, 17, 35),
|
|
|
|
Color.FromRgb(234, 0, 94),
|
|
|
|
Color.FromRgb(195, 0, 82),
|
|
|
|
Color.FromRgb(227, 0, 140),
|
|
|
|
Color.FromRgb(191, 0, 119),
|
|
|
|
Color.FromRgb(194, 57, 179),
|
|
|
|
Color.FromRgb(154, 0, 137),
|
|
|
|
Color.FromRgb(0, 120, 212),
|
|
|
|
Color.FromRgb(0, 99, 177),
|
|
|
|
Color.FromRgb(142, 140, 216),
|
|
|
|
Color.FromRgb(107, 105, 214),
|
|
|
|
Colors.SlateBlue,
|
|
|
|
Color.FromRgb(135, 100, 184),
|
|
|
|
Color.FromRgb(116, 77, 169),
|
|
|
|
Color.FromRgb(177, 70, 194),
|
|
|
|
Color.FromRgb(136, 23, 152),
|
|
|
|
Color.FromRgb(0, 153, 188),
|
|
|
|
Color.FromRgb(45, 125, 154),
|
|
|
|
Color.FromRgb(0, 183, 195),
|
|
|
|
Color.FromRgb(3, 131, 135),
|
|
|
|
Color.FromRgb(0, 178, 148),
|
|
|
|
Color.FromRgb(1, 133, 116),
|
|
|
|
Color.FromRgb(0, 204, 106),
|
|
|
|
Color.FromRgb(16, 137, 62),
|
|
|
|
Color.FromRgb(122, 117, 116),
|
|
|
|
Color.FromRgb(93, 90, 88),
|
|
|
|
Color.FromRgb(104, 118, 138),
|
|
|
|
Color.FromRgb(81, 92, 107),
|
|
|
|
Color.FromRgb(86, 124, 115),
|
|
|
|
Color.FromRgb(72, 104, 96),
|
|
|
|
Color.FromRgb(73, 130, 5),
|
|
|
|
Color.FromRgb(16, 124, 16),
|
|
|
|
Color.FromRgb(118, 118, 118),
|
|
|
|
Color.FromRgb(76, 74, 72),
|
|
|
|
Color.FromRgb(105, 121, 126),
|
|
|
|
Color.FromRgb(74, 84, 89),
|
|
|
|
Color.FromRgb(100, 124, 100),
|
|
|
|
Color.FromRgb(82, 94, 84),
|
|
|
|
Color.FromRgb(132, 117, 69),
|
|
|
|
Color.FromRgb(126, 115, 95)
|
|
|
|
};
|
|
|
|
|
|
|
|
public ObservableCollection<ComboBoxItem> AppThemes{ get; } = new(){
|
|
|
|
new ComboBoxItem(){ Content = "System" },
|
|
|
|
new ComboBoxItem(){ Content = "Light" },
|
|
|
|
new ComboBoxItem(){ Content = "Dark" },
|
|
|
|
};
|
|
|
|
|
|
|
|
public ObservableCollection<ComboBoxItem> VideoQualityList{ get; } = new(){
|
|
|
|
new ComboBoxItem(){ Content = "best" },
|
|
|
|
new ComboBoxItem(){ Content = "1080" },
|
|
|
|
new ComboBoxItem(){ Content = "720" },
|
|
|
|
new ComboBoxItem(){ Content = "480" },
|
|
|
|
new ComboBoxItem(){ Content = "360" },
|
|
|
|
new ComboBoxItem(){ Content = "240" },
|
|
|
|
new ComboBoxItem(){ Content = "worst" },
|
|
|
|
};
|
|
|
|
|
|
|
|
public ObservableCollection<ComboBoxItem> AudioQualityList{ get; } = new(){
|
|
|
|
new ComboBoxItem(){ Content = "best" },
|
|
|
|
new ComboBoxItem(){ Content = "128kB/s" },
|
|
|
|
new ComboBoxItem(){ Content = "96kB/s" },
|
|
|
|
new ComboBoxItem(){ Content = "64kB/s" },
|
|
|
|
new ComboBoxItem(){ Content = "worst" },
|
|
|
|
};
|
|
|
|
|
|
|
|
public ObservableCollection<ComboBoxItem> HardSubLangList{ get; } = new(){
|
|
|
|
new ComboBoxItem(){ Content = "none" },
|
|
|
|
};
|
|
|
|
|
2024-06-27 20:52:12 +00:00
|
|
|
public ObservableCollection<ComboBoxItem> HistoryLangList{ get; } = new(){
|
|
|
|
new ComboBoxItem(){ Content = "default" },
|
|
|
|
new ComboBoxItem(){ Content = "de-DE" },
|
|
|
|
new ComboBoxItem(){ Content = "en-US" },
|
|
|
|
new ComboBoxItem(){ Content = "es-419" },
|
|
|
|
new ComboBoxItem(){ Content = "es-ES" },
|
|
|
|
new ComboBoxItem(){ Content = "fr-FR" },
|
|
|
|
new ComboBoxItem(){ Content = "it-IT" },
|
|
|
|
new ComboBoxItem(){ Content = "pt-BR" },
|
|
|
|
new ComboBoxItem(){ Content = "pt-PT" },
|
|
|
|
new ComboBoxItem(){ Content = "ru-RU" },
|
|
|
|
new ComboBoxItem(){ Content = "hi-IN" },
|
|
|
|
new ComboBoxItem(){ Content = "ar-SA" },
|
|
|
|
};
|
2024-07-06 18:48:58 +00:00
|
|
|
|
2024-06-27 20:52:12 +00:00
|
|
|
public ObservableCollection<ComboBoxItem> DescriptionLangList{ get; } = new(){
|
|
|
|
new ComboBoxItem(){ Content = "default" },
|
|
|
|
new ComboBoxItem(){ Content = "de-DE" },
|
|
|
|
new ComboBoxItem(){ Content = "en-US" },
|
|
|
|
new ComboBoxItem(){ Content = "es-419" },
|
|
|
|
new ComboBoxItem(){ Content = "es-ES" },
|
|
|
|
new ComboBoxItem(){ Content = "fr-FR" },
|
|
|
|
new ComboBoxItem(){ Content = "it-IT" },
|
|
|
|
new ComboBoxItem(){ Content = "pt-BR" },
|
|
|
|
new ComboBoxItem(){ Content = "pt-PT" },
|
|
|
|
new ComboBoxItem(){ Content = "ru-RU" },
|
|
|
|
new ComboBoxItem(){ Content = "hi-IN" },
|
|
|
|
new ComboBoxItem(){ Content = "ar-SA" },
|
|
|
|
};
|
2024-07-06 18:48:58 +00:00
|
|
|
|
2024-07-16 23:52:46 +00:00
|
|
|
public ObservableCollection<ListBoxItem> DubLangList{ get; } = new(){
|
2024-05-04 15:35:32 +00:00
|
|
|
};
|
|
|
|
|
2024-06-19 00:16:02 +00:00
|
|
|
|
|
|
|
public ObservableCollection<ComboBoxItem> DefaultDubLangList{ get; } = new(){
|
|
|
|
};
|
|
|
|
|
|
|
|
public ObservableCollection<ComboBoxItem> DefaultSubLangList{ get; } = new(){
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2024-05-04 15:35:32 +00:00
|
|
|
public ObservableCollection<ListBoxItem> SubLangList{ get; } = new(){
|
|
|
|
new ListBoxItem(){ Content = "all" },
|
|
|
|
new ListBoxItem(){ Content = "none" },
|
|
|
|
};
|
2024-06-21 01:49:44 +00:00
|
|
|
|
2024-06-19 01:50:10 +00:00
|
|
|
public ObservableCollection<ComboBoxItem> StreamEndpoints{ get; } = new(){
|
|
|
|
new ComboBoxItem(){ Content = "web/firefox" },
|
|
|
|
new ComboBoxItem(){ Content = "console/switch" },
|
|
|
|
new ComboBoxItem(){ Content = "console/ps4" },
|
|
|
|
new ComboBoxItem(){ Content = "console/ps5" },
|
|
|
|
new ComboBoxItem(){ Content = "console/xbox_one" },
|
|
|
|
new ComboBoxItem(){ Content = "web/edge" },
|
|
|
|
// new ComboBoxItem(){ Content = "web/safari" },
|
|
|
|
new ComboBoxItem(){ Content = "web/chrome" },
|
|
|
|
new ComboBoxItem(){ Content = "web/fallback" },
|
|
|
|
// new ComboBoxItem(){ Content = "ios/iphone" },
|
|
|
|
// new ComboBoxItem(){ Content = "ios/ipad" },
|
|
|
|
new ComboBoxItem(){ Content = "android/phone" },
|
|
|
|
new ComboBoxItem(){ Content = "tv/samsung" },
|
|
|
|
};
|
2024-07-06 18:48:58 +00:00
|
|
|
|
2024-06-21 01:49:44 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private string _downloadDirPath;
|
2024-05-04 15:35:32 +00:00
|
|
|
|
2024-08-20 16:40:45 +00:00
|
|
|
[ObservableProperty]
|
|
|
|
private string _tempDownloadDirPath;
|
|
|
|
|
2024-05-04 15:35:32 +00:00
|
|
|
private readonly FluentAvaloniaTheme _faTheme;
|
|
|
|
|
2024-05-24 22:46:11 +00:00
|
|
|
private bool settingsLoaded;
|
2024-05-22 21:22:02 +00:00
|
|
|
|
2024-06-21 01:49:44 +00:00
|
|
|
private IStorageProvider _storageProvider;
|
|
|
|
|
2024-05-04 15:35:32 +00:00
|
|
|
public SettingsPageViewModel(){
|
|
|
|
var version = Assembly.GetExecutingAssembly().GetName().Version;
|
|
|
|
_currentVersion = $"{version?.Major}.{version?.Minor}.{version?.Build}";
|
2024-05-22 21:22:02 +00:00
|
|
|
|
2024-05-04 15:35:32 +00:00
|
|
|
_faTheme = App.Current.Styles[0] as FluentAvaloniaTheme;
|
2024-05-22 21:22:02 +00:00
|
|
|
|
2024-05-04 15:35:32 +00:00
|
|
|
foreach (var languageItem in Languages.languages){
|
|
|
|
HardSubLangList.Add(new ComboBoxItem{ Content = languageItem.CrLocale });
|
|
|
|
SubLangList.Add(new ListBoxItem{ Content = languageItem.CrLocale });
|
2024-07-16 23:52:46 +00:00
|
|
|
DubLangList.Add(new ListBoxItem{ Content = languageItem.CrLocale });
|
2024-06-19 00:16:02 +00:00
|
|
|
DefaultDubLangList.Add(new ComboBoxItem{ Content = languageItem.CrLocale });
|
|
|
|
DefaultSubLangList.Add(new ComboBoxItem{ Content = languageItem.CrLocale });
|
2024-05-04 15:35:32 +00:00
|
|
|
}
|
|
|
|
|
2024-07-21 09:30:20 +00:00
|
|
|
CrDownloadOptions options = CrunchyrollManager.Instance.CrunOptions;
|
2024-05-25 22:02:45 +00:00
|
|
|
|
2024-06-21 01:49:44 +00:00
|
|
|
DownloadDirPath = string.IsNullOrEmpty(options.DownloadDirPath) ? CfgManager.PathVIDEOS_DIR : options.DownloadDirPath;
|
2024-08-20 16:40:45 +00:00
|
|
|
TempDownloadDirPath = string.IsNullOrEmpty(options.DownloadTempDirPath) ? CfgManager.PathTEMP_DIR : options.DownloadTempDirPath;
|
2024-07-06 18:48:58 +00:00
|
|
|
|
2024-06-27 20:52:12 +00:00
|
|
|
ComboBoxItem? descriptionLang = DescriptionLangList.FirstOrDefault(a => a.Content != null && (string)a.Content == options.DescriptionLang) ?? null;
|
|
|
|
SelectedDescriptionLang = descriptionLang ?? DescriptionLangList[0];
|
2024-07-06 18:48:58 +00:00
|
|
|
|
2024-06-27 20:52:12 +00:00
|
|
|
ComboBoxItem? historyLang = HistoryLangList.FirstOrDefault(a => a.Content != null && (string)a.Content == options.HistoryLang) ?? null;
|
|
|
|
SelectedHistoryLang = historyLang ?? HistoryLangList[0];
|
2024-07-06 18:48:58 +00:00
|
|
|
|
2024-07-21 09:30:20 +00:00
|
|
|
ComboBoxItem? hsLang = HardSubLangList.FirstOrDefault(a => a.Content != null && (string)a.Content == Languages.Locale2language(options.Hslang).CrLocale) ?? null;
|
2024-05-24 22:46:11 +00:00
|
|
|
SelectedHSLang = hsLang ?? HardSubLangList[0];
|
2024-07-06 18:48:58 +00:00
|
|
|
|
2024-06-19 00:16:02 +00:00
|
|
|
ComboBoxItem? defaultDubLang = DefaultDubLangList.FirstOrDefault(a => a.Content != null && (string)a.Content == (options.DefaultAudio ?? "")) ?? null;
|
|
|
|
SelectedDefaultDubLang = defaultDubLang ?? DefaultDubLangList[0];
|
|
|
|
|
|
|
|
ComboBoxItem? defaultSubLang = DefaultSubLangList.FirstOrDefault(a => a.Content != null && (string)a.Content == (options.DefaultSub ?? "")) ?? null;
|
|
|
|
SelectedDefaultSubLang = defaultSubLang ?? DefaultSubLangList[0];
|
|
|
|
|
2024-06-19 01:50:10 +00:00
|
|
|
ComboBoxItem? streamEndpoint = StreamEndpoints.FirstOrDefault(a => a.Content != null && (string)a.Content == (options.StreamEndpoint ?? "")) ?? null;
|
|
|
|
SelectedStreamEndpoint = streamEndpoint ?? StreamEndpoints[0];
|
2024-06-21 01:49:44 +00:00
|
|
|
|
2024-05-04 15:35:32 +00:00
|
|
|
var softSubLang = SubLangList.Where(a => options.DlSubs.Contains(a.Content)).ToList();
|
|
|
|
|
|
|
|
SelectedSubLang.Clear();
|
|
|
|
foreach (var listBoxItem in softSubLang){
|
|
|
|
SelectedSubLang.Add(listBoxItem);
|
|
|
|
}
|
2024-05-22 21:22:02 +00:00
|
|
|
|
|
|
|
var dubLang = DubLangList.Where(a => options.DubLang.Contains(a.Content)).ToList();
|
|
|
|
|
|
|
|
SelectedDubLang.Clear();
|
|
|
|
foreach (var listBoxItem in dubLang){
|
|
|
|
SelectedDubLang.Add(listBoxItem);
|
|
|
|
}
|
2024-08-20 16:40:45 +00:00
|
|
|
|
2024-05-25 22:02:45 +00:00
|
|
|
var props = options.SonarrProperties;
|
|
|
|
|
|
|
|
if (props != null){
|
|
|
|
SonarrUseSsl = props.UseSsl;
|
2024-06-11 21:58:44 +00:00
|
|
|
SonarrUseSonarrNumbering = props.UseSonarrNumbering;
|
2024-05-25 22:02:45 +00:00
|
|
|
SonarrHost = props.Host + "";
|
|
|
|
SonarrPort = props.Port + "";
|
|
|
|
SonarrApiKey = props.ApiKey + "";
|
|
|
|
}
|
2024-06-19 10:37:06 +00:00
|
|
|
|
|
|
|
AddScaledBorderAndShadow = options.SubsAddScaledBorder is ScaledBorderAndShadowSelection.ScaledBorderAndShadowNo or ScaledBorderAndShadowSelection.ScaledBorderAndShadowYes;
|
|
|
|
SelectedScaledBorderAndShadow = GetScaledBorderAndShadowFromOptions(options);
|
2024-06-21 01:49:44 +00:00
|
|
|
|
2024-07-26 04:05:05 +00:00
|
|
|
DefaultSubForcedDisplay = options.DefaultSubForcedDisplay;
|
2024-07-26 00:18:39 +00:00
|
|
|
DefaultSubSigns = options.DefaultSubSigns;
|
2024-07-24 13:19:18 +00:00
|
|
|
HistoryAddSpecials = options.HistoryAddSpecials;
|
2024-08-05 03:06:40 +00:00
|
|
|
HistoryCountSonarr = options.HistoryCountSonarr;
|
2024-07-06 18:48:58 +00:00
|
|
|
DownloadSpeed = options.DownloadSpeedLimit;
|
2024-06-24 15:40:20 +00:00
|
|
|
IncludeEpisodeDescription = options.IncludeVideoDescription;
|
|
|
|
FileTitle = options.VideoTitle ?? "";
|
|
|
|
IncludeSignSubs = options.IncludeSignsSubs;
|
2024-08-09 21:16:13 +00:00
|
|
|
IncludeCcSubs = options.IncludeCcSubs;
|
2024-05-04 15:35:32 +00:00
|
|
|
DownloadVideo = !options.Novids;
|
|
|
|
DownloadAudio = !options.Noaudio;
|
2024-06-19 00:16:02 +00:00
|
|
|
DownloadVideoForEveryDub = !options.DlVideoOnce;
|
2024-08-20 16:40:45 +00:00
|
|
|
DownloadToTempFolder = options.DownloadToTempFolder;
|
2024-08-05 03:06:40 +00:00
|
|
|
KeepDubsSeparate = options.KeepDubsSeperate;
|
2024-05-04 15:35:32 +00:00
|
|
|
DownloadChapters = options.Chapters;
|
|
|
|
MuxToMp4 = options.Mp4;
|
2024-07-16 23:52:46 +00:00
|
|
|
SyncTimings = options.SyncTiming;
|
2024-06-19 00:16:02 +00:00
|
|
|
SkipSubMux = options.SkipSubsMux;
|
2024-05-04 15:35:32 +00:00
|
|
|
LeadingNumbers = options.Numbers;
|
|
|
|
FileName = options.FileName;
|
|
|
|
SimultaneousDownloads = options.SimultaneousDownloads;
|
2024-06-15 13:55:39 +00:00
|
|
|
LogMode = options.LogMode;
|
2024-05-04 15:35:32 +00:00
|
|
|
|
|
|
|
ComboBoxItem? qualityAudio = AudioQualityList.FirstOrDefault(a => a.Content != null && (string)a.Content == options.QualityAudio) ?? null;
|
|
|
|
SelectedAudioQuality = qualityAudio ?? AudioQualityList[0];
|
|
|
|
|
|
|
|
ComboBoxItem? qualityVideo = VideoQualityList.FirstOrDefault(a => a.Content != null && (string)a.Content == options.QualityVideo) ?? null;
|
|
|
|
SelectedVideoQuality = qualityVideo ?? VideoQualityList[0];
|
|
|
|
|
|
|
|
ComboBoxItem? theme = AppThemes.FirstOrDefault(a => a.Content != null && (string)a.Content == options.Theme) ?? null;
|
|
|
|
CurrentAppTheme = theme ?? AppThemes[0];
|
|
|
|
|
|
|
|
if (options.AccentColor != CustomAccentColor.ToString()){
|
|
|
|
UseCustomAccent = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
History = options.History;
|
|
|
|
|
2024-06-19 00:16:02 +00:00
|
|
|
MkvMergeOptions.Clear();
|
|
|
|
if (options.MkvmergeOptions != null){
|
|
|
|
foreach (var mkvmergeParam in options.MkvmergeOptions){
|
|
|
|
MkvMergeOptions.Add(new MuxingParam(){ ParamValue = mkvmergeParam });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FfmpegOptions.Clear();
|
|
|
|
if (options.FfmpegOptions != null){
|
|
|
|
foreach (var ffmpegParam in options.FfmpegOptions){
|
|
|
|
FfmpegOptions.Add(new MuxingParam(){ ParamValue = ffmpegParam });
|
|
|
|
}
|
|
|
|
}
|
2024-08-20 16:40:45 +00:00
|
|
|
|
2024-07-16 23:52:46 +00:00
|
|
|
var dubs = SelectedDubLang.Select(item => item.Content?.ToString());
|
|
|
|
SelectedDubs = string.Join(", ", dubs) ?? "";
|
2024-08-20 16:40:45 +00:00
|
|
|
|
2024-07-16 23:52:46 +00:00
|
|
|
var subs = SelectedSubLang.Select(item => item.Content?.ToString());
|
|
|
|
SelectedSubs = string.Join(", ", subs) ?? "";
|
2024-05-04 15:35:32 +00:00
|
|
|
|
|
|
|
SelectedSubLang.CollectionChanged += Changes;
|
2024-05-22 21:22:02 +00:00
|
|
|
SelectedDubLang.CollectionChanged += Changes;
|
2024-05-04 15:35:32 +00:00
|
|
|
|
2024-06-19 00:16:02 +00:00
|
|
|
MkvMergeOptions.CollectionChanged += Changes;
|
|
|
|
FfmpegOptions.CollectionChanged += Changes;
|
|
|
|
|
2024-05-04 15:35:32 +00:00
|
|
|
settingsLoaded = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void UpdateSettings(){
|
|
|
|
if (!settingsLoaded){
|
|
|
|
return;
|
|
|
|
}
|
2024-07-26 00:18:39 +00:00
|
|
|
|
2024-08-20 16:40:45 +00:00
|
|
|
CrunchyrollManager.Instance.CrunOptions.DownloadToTempFolder = DownloadToTempFolder;
|
2024-07-26 00:18:39 +00:00
|
|
|
CrunchyrollManager.Instance.CrunOptions.DefaultSubSigns = DefaultSubSigns;
|
2024-07-26 04:05:05 +00:00
|
|
|
CrunchyrollManager.Instance.CrunOptions.DefaultSubForcedDisplay = DefaultSubForcedDisplay;
|
2024-07-21 09:30:20 +00:00
|
|
|
CrunchyrollManager.Instance.CrunOptions.IncludeVideoDescription = IncludeEpisodeDescription;
|
2024-07-24 13:19:18 +00:00
|
|
|
CrunchyrollManager.Instance.CrunOptions.HistoryAddSpecials = HistoryAddSpecials;
|
2024-08-05 03:06:40 +00:00
|
|
|
CrunchyrollManager.Instance.CrunOptions.HistoryCountSonarr = HistoryCountSonarr;
|
2024-07-21 09:30:20 +00:00
|
|
|
CrunchyrollManager.Instance.CrunOptions.VideoTitle = FileTitle;
|
|
|
|
CrunchyrollManager.Instance.CrunOptions.Novids = !DownloadVideo;
|
|
|
|
CrunchyrollManager.Instance.CrunOptions.Noaudio = !DownloadAudio;
|
|
|
|
CrunchyrollManager.Instance.CrunOptions.DlVideoOnce = !DownloadVideoForEveryDub;
|
2024-08-05 03:06:40 +00:00
|
|
|
CrunchyrollManager.Instance.CrunOptions.KeepDubsSeperate = KeepDubsSeparate;
|
2024-07-21 09:30:20 +00:00
|
|
|
CrunchyrollManager.Instance.CrunOptions.Chapters = DownloadChapters;
|
|
|
|
CrunchyrollManager.Instance.CrunOptions.Mp4 = MuxToMp4;
|
|
|
|
CrunchyrollManager.Instance.CrunOptions.SyncTiming = SyncTimings;
|
|
|
|
CrunchyrollManager.Instance.CrunOptions.SkipSubsMux = SkipSubMux;
|
2024-08-20 16:40:45 +00:00
|
|
|
CrunchyrollManager.Instance.CrunOptions.Numbers = Math.Clamp((int)(LeadingNumbers ?? 0), 0, 10);
|
2024-07-21 09:30:20 +00:00
|
|
|
CrunchyrollManager.Instance.CrunOptions.FileName = FileName;
|
2024-08-20 16:40:45 +00:00
|
|
|
CrunchyrollManager.Instance.CrunOptions.IncludeSignsSubs = IncludeSignSubs;
|
|
|
|
CrunchyrollManager.Instance.CrunOptions.IncludeCcSubs = IncludeCcSubs;
|
|
|
|
CrunchyrollManager.Instance.CrunOptions.DownloadSpeedLimit = Math.Clamp((int)(DownloadSpeed ?? 0), 0, 1000000000);
|
|
|
|
CrunchyrollManager.Instance.CrunOptions.SimultaneousDownloads = Math.Clamp((int)(SimultaneousDownloads ?? 0), 1, 10);
|
2024-07-21 09:30:20 +00:00
|
|
|
|
|
|
|
CrunchyrollManager.Instance.CrunOptions.SubsAddScaledBorder = GetScaledBorderAndShadowSelection();
|
2024-05-04 15:35:32 +00:00
|
|
|
|
|
|
|
List<string> softSubs = new List<string>();
|
|
|
|
foreach (var listBoxItem in SelectedSubLang){
|
|
|
|
softSubs.Add(listBoxItem.Content + "");
|
|
|
|
}
|
|
|
|
|
2024-07-21 09:30:20 +00:00
|
|
|
CrunchyrollManager.Instance.CrunOptions.DlSubs = softSubs;
|
2024-05-04 15:35:32 +00:00
|
|
|
|
2024-06-27 20:52:12 +00:00
|
|
|
string descLang = SelectedDescriptionLang.Content + "";
|
|
|
|
|
2024-07-21 09:30:20 +00:00
|
|
|
CrunchyrollManager.Instance.CrunOptions.DescriptionLang = descLang != "default" ? descLang : CrunchyrollManager.Instance.DefaultLocale;
|
2024-07-06 18:48:58 +00:00
|
|
|
|
2024-06-27 20:52:12 +00:00
|
|
|
string historyLang = SelectedHistoryLang.Content + "";
|
|
|
|
|
2024-07-21 09:30:20 +00:00
|
|
|
CrunchyrollManager.Instance.CrunOptions.HistoryLang = historyLang != "default" ? historyLang : CrunchyrollManager.Instance.DefaultLocale;
|
2024-07-06 18:48:58 +00:00
|
|
|
|
2024-05-04 15:35:32 +00:00
|
|
|
string hslang = SelectedHSLang.Content + "";
|
|
|
|
|
2024-07-21 09:30:20 +00:00
|
|
|
CrunchyrollManager.Instance.CrunOptions.Hslang = hslang != "none" ? Languages.FindLang(hslang).Locale : hslang;
|
2024-05-04 15:35:32 +00:00
|
|
|
|
2024-07-21 09:30:20 +00:00
|
|
|
CrunchyrollManager.Instance.CrunOptions.DefaultAudio = SelectedDefaultDubLang.Content + "";
|
|
|
|
CrunchyrollManager.Instance.CrunOptions.DefaultSub = SelectedDefaultSubLang.Content + "";
|
2024-06-21 01:49:44 +00:00
|
|
|
|
|
|
|
|
2024-07-21 09:30:20 +00:00
|
|
|
CrunchyrollManager.Instance.CrunOptions.StreamEndpoint = SelectedStreamEndpoint.Content + "";
|
2024-05-04 15:35:32 +00:00
|
|
|
|
2024-05-22 21:22:02 +00:00
|
|
|
List<string> dubLangs = new List<string>();
|
|
|
|
foreach (var listBoxItem in SelectedDubLang){
|
|
|
|
dubLangs.Add(listBoxItem.Content + "");
|
2024-05-04 15:35:32 +00:00
|
|
|
}
|
|
|
|
|
2024-07-21 09:30:20 +00:00
|
|
|
CrunchyrollManager.Instance.CrunOptions.DubLang = dubLangs;
|
2024-08-20 16:40:45 +00:00
|
|
|
|
2024-07-21 09:30:20 +00:00
|
|
|
CrunchyrollManager.Instance.CrunOptions.QualityAudio = SelectedAudioQuality?.Content + "";
|
|
|
|
CrunchyrollManager.Instance.CrunOptions.QualityVideo = SelectedVideoQuality?.Content + "";
|
|
|
|
CrunchyrollManager.Instance.CrunOptions.Theme = CurrentAppTheme?.Content + "";
|
2024-05-04 15:35:32 +00:00
|
|
|
|
2024-07-21 09:30:20 +00:00
|
|
|
CrunchyrollManager.Instance.CrunOptions.AccentColor = _faTheme.CustomAccentColor.ToString();
|
2024-05-04 15:35:32 +00:00
|
|
|
|
2024-07-21 09:30:20 +00:00
|
|
|
CrunchyrollManager.Instance.CrunOptions.History = History;
|
2024-05-22 21:22:02 +00:00
|
|
|
|
2024-05-25 22:02:45 +00:00
|
|
|
var props = new SonarrProperties();
|
|
|
|
|
|
|
|
props.UseSsl = SonarrUseSsl;
|
2024-06-11 21:58:44 +00:00
|
|
|
props.UseSonarrNumbering = SonarrUseSonarrNumbering;
|
2024-05-25 22:02:45 +00:00
|
|
|
props.Host = SonarrHost;
|
2024-06-11 21:58:44 +00:00
|
|
|
|
|
|
|
if (int.TryParse(SonarrPort, out var portNumber)){
|
|
|
|
props.Port = portNumber;
|
|
|
|
} else{
|
|
|
|
props.Port = 8989;
|
|
|
|
}
|
|
|
|
|
2024-05-25 22:02:45 +00:00
|
|
|
props.ApiKey = SonarrApiKey;
|
|
|
|
|
2024-06-11 21:58:44 +00:00
|
|
|
|
2024-07-21 09:30:20 +00:00
|
|
|
CrunchyrollManager.Instance.CrunOptions.SonarrProperties = props;
|
2024-05-25 22:02:45 +00:00
|
|
|
|
2024-07-21 09:30:20 +00:00
|
|
|
CrunchyrollManager.Instance.CrunOptions.LogMode = LogMode;
|
2024-05-25 22:02:45 +00:00
|
|
|
|
2024-06-19 00:16:02 +00:00
|
|
|
List<string> mkvmergeParams = new List<string>();
|
|
|
|
foreach (var mkvmergeParam in MkvMergeOptions){
|
|
|
|
mkvmergeParams.Add(mkvmergeParam.ParamValue);
|
|
|
|
}
|
|
|
|
|
2024-07-21 09:30:20 +00:00
|
|
|
CrunchyrollManager.Instance.CrunOptions.MkvmergeOptions = mkvmergeParams;
|
2024-06-19 00:16:02 +00:00
|
|
|
|
|
|
|
List<string> ffmpegParams = new List<string>();
|
|
|
|
foreach (var ffmpegParam in FfmpegOptions){
|
|
|
|
ffmpegParams.Add(ffmpegParam.ParamValue);
|
|
|
|
}
|
|
|
|
|
2024-07-21 09:30:20 +00:00
|
|
|
CrunchyrollManager.Instance.CrunOptions.FfmpegOptions = ffmpegParams;
|
2024-05-04 15:35:32 +00:00
|
|
|
|
|
|
|
CfgManager.WriteSettingsToFile();
|
|
|
|
}
|
|
|
|
|
2024-06-19 10:37:06 +00:00
|
|
|
|
|
|
|
private ScaledBorderAndShadowSelection GetScaledBorderAndShadowSelection(){
|
|
|
|
if (!AddScaledBorderAndShadow){
|
|
|
|
return ScaledBorderAndShadowSelection.DontAdd;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SelectedScaledBorderAndShadow.Content + "" == "ScaledBorderAndShadow: yes"){
|
|
|
|
return ScaledBorderAndShadowSelection.ScaledBorderAndShadowYes;
|
|
|
|
}
|
2024-06-21 01:49:44 +00:00
|
|
|
|
2024-06-19 10:37:06 +00:00
|
|
|
if (SelectedScaledBorderAndShadow.Content + "" == "ScaledBorderAndShadow: no"){
|
|
|
|
return ScaledBorderAndShadowSelection.ScaledBorderAndShadowNo;
|
|
|
|
}
|
2024-06-21 01:49:44 +00:00
|
|
|
|
2024-06-19 10:37:06 +00:00
|
|
|
return ScaledBorderAndShadowSelection.ScaledBorderAndShadowYes;
|
|
|
|
}
|
|
|
|
|
|
|
|
private ComboBoxItem GetScaledBorderAndShadowFromOptions(CrDownloadOptions options){
|
|
|
|
switch (options.SubsAddScaledBorder){
|
|
|
|
case (ScaledBorderAndShadowSelection.ScaledBorderAndShadowYes):
|
|
|
|
return ScaledBorderAndShadow.FirstOrDefault(a => a.Content != null && (string)a.Content == "ScaledBorderAndShadow: yes") ?? ScaledBorderAndShadow[0];
|
|
|
|
case ScaledBorderAndShadowSelection.ScaledBorderAndShadowNo:
|
|
|
|
return ScaledBorderAndShadow.FirstOrDefault(a => a.Content != null && (string)a.Content == "ScaledBorderAndShadow: no") ?? ScaledBorderAndShadow[0];
|
|
|
|
default:
|
|
|
|
return ScaledBorderAndShadow[0];
|
|
|
|
}
|
|
|
|
}
|
2024-08-20 16:40:45 +00:00
|
|
|
|
2024-06-19 00:16:02 +00:00
|
|
|
[RelayCommand]
|
|
|
|
public void AddMkvMergeParam(){
|
|
|
|
MkvMergeOptions.Add(new MuxingParam(){ ParamValue = MkvMergeOption });
|
|
|
|
MkvMergeOption = "";
|
|
|
|
RaisePropertyChanged(nameof(MkvMergeOptions));
|
|
|
|
}
|
|
|
|
|
|
|
|
[RelayCommand]
|
|
|
|
public void RemoveMkvMergeParam(MuxingParam param){
|
|
|
|
MkvMergeOptions.Remove(param);
|
|
|
|
RaisePropertyChanged(nameof(MkvMergeOptions));
|
|
|
|
}
|
|
|
|
|
|
|
|
[RelayCommand]
|
|
|
|
public void AddFfmpegParam(){
|
|
|
|
FfmpegOptions.Add(new MuxingParam(){ ParamValue = FfmpegOption });
|
|
|
|
FfmpegOption = "";
|
|
|
|
RaisePropertyChanged(nameof(FfmpegOptions));
|
|
|
|
}
|
|
|
|
|
|
|
|
[RelayCommand]
|
|
|
|
public void RemoveFfmpegParam(MuxingParam param){
|
|
|
|
FfmpegOptions.Remove(param);
|
|
|
|
RaisePropertyChanged(nameof(FfmpegOptions));
|
|
|
|
}
|
|
|
|
|
2024-06-21 01:49:44 +00:00
|
|
|
[RelayCommand]
|
|
|
|
public async Task OpenFolderDialogAsync(){
|
2024-08-20 16:40:45 +00:00
|
|
|
await OpenFolderDialogAsyncInternal(
|
|
|
|
pathSetter: (path) => CrunchyrollManager.Instance.CrunOptions.DownloadDirPath = path,
|
|
|
|
pathGetter: () => CrunchyrollManager.Instance.CrunOptions.DownloadDirPath,
|
|
|
|
defaultPath: CfgManager.PathVIDEOS_DIR
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
[RelayCommand]
|
|
|
|
public async Task OpenFolderDialogTempFolderAsync(){
|
|
|
|
await OpenFolderDialogAsyncInternal(
|
|
|
|
pathSetter: (path) => CrunchyrollManager.Instance.CrunOptions.DownloadTempDirPath = path,
|
|
|
|
pathGetter: () => CrunchyrollManager.Instance.CrunOptions.DownloadTempDirPath,
|
|
|
|
defaultPath: CfgManager.PathTEMP_DIR
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
private async Task OpenFolderDialogAsyncInternal(Action<string> pathSetter, Func<string> pathGetter, string defaultPath){
|
2024-06-21 01:49:44 +00:00
|
|
|
if (_storageProvider == null){
|
|
|
|
Console.Error.WriteLine("StorageProvider must be set before using the dialog.");
|
|
|
|
throw new InvalidOperationException("StorageProvider must be set before using the dialog.");
|
|
|
|
}
|
|
|
|
|
|
|
|
var result = await _storageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions{
|
|
|
|
Title = "Select Folder"
|
|
|
|
});
|
|
|
|
|
|
|
|
if (result.Count > 0){
|
|
|
|
var selectedFolder = result[0];
|
|
|
|
Console.WriteLine($"Selected folder: {selectedFolder.Path.LocalPath}");
|
2024-08-20 16:40:45 +00:00
|
|
|
pathSetter(selectedFolder.Path.LocalPath);
|
|
|
|
var finalPath = string.IsNullOrEmpty(pathGetter()) ? defaultPath : pathGetter();
|
|
|
|
pathSetter(finalPath);
|
2024-06-21 01:49:44 +00:00
|
|
|
CfgManager.WriteSettingsToFile();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SetStorageProvider(IStorageProvider storageProvider){
|
|
|
|
_storageProvider = storageProvider ?? throw new ArgumentNullException(nameof(storageProvider));
|
|
|
|
}
|
|
|
|
|
2024-05-04 15:35:32 +00:00
|
|
|
partial void OnCurrentAppThemeChanged(ComboBoxItem? value){
|
|
|
|
if (value?.Content?.ToString() == "System"){
|
|
|
|
_faTheme.PreferSystemTheme = true;
|
|
|
|
} else if (value?.Content?.ToString() == "Dark"){
|
|
|
|
_faTheme.PreferSystemTheme = false;
|
|
|
|
Application.Current.RequestedThemeVariant = ThemeVariant.Dark;
|
|
|
|
} else{
|
|
|
|
_faTheme.PreferSystemTheme = false;
|
|
|
|
Application.Current.RequestedThemeVariant = ThemeVariant.Light;
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdateSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
partial void OnUseCustomAccentChanged(bool value){
|
|
|
|
if (value){
|
|
|
|
if (_faTheme.TryGetResource("SystemAccentColor", null, out var curColor)){
|
|
|
|
CustomAccentColor = (Color)curColor;
|
|
|
|
ListBoxColor = CustomAccentColor;
|
2024-05-22 21:22:02 +00:00
|
|
|
|
2024-05-04 15:35:32 +00:00
|
|
|
RaisePropertyChanged(nameof(CustomAccentColor));
|
|
|
|
RaisePropertyChanged(nameof(ListBoxColor));
|
|
|
|
}
|
|
|
|
} else{
|
|
|
|
CustomAccentColor = default;
|
|
|
|
ListBoxColor = default;
|
|
|
|
UpdateAppAccentColor(Colors.SlateBlue);
|
|
|
|
}
|
|
|
|
}
|
2024-05-22 21:22:02 +00:00
|
|
|
|
2024-05-04 15:35:32 +00:00
|
|
|
partial void OnListBoxColorChanged(Color value){
|
|
|
|
if (value != null){
|
|
|
|
CustomAccentColor = value;
|
|
|
|
RaisePropertyChanged(nameof(CustomAccentColor));
|
2024-05-22 21:22:02 +00:00
|
|
|
|
2024-05-04 15:35:32 +00:00
|
|
|
UpdateAppAccentColor(value);
|
|
|
|
}
|
|
|
|
}
|
2024-05-22 21:22:02 +00:00
|
|
|
|
2024-05-04 15:35:32 +00:00
|
|
|
partial void OnCustomAccentColorChanged(Color value){
|
|
|
|
ListBoxColor = value;
|
|
|
|
RaisePropertyChanged(nameof(ListBoxColor));
|
|
|
|
UpdateAppAccentColor(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void UpdateAppAccentColor(Color? color){
|
|
|
|
_faTheme.CustomAccentColor = color;
|
|
|
|
UpdateSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Changes(object? sender, NotifyCollectionChangedEventArgs e){
|
|
|
|
UpdateSettings();
|
2024-08-20 16:40:45 +00:00
|
|
|
|
2024-07-16 23:52:46 +00:00
|
|
|
var dubs = SelectedDubLang.Select(item => item.Content?.ToString());
|
|
|
|
SelectedDubs = string.Join(", ", dubs) ?? "";
|
2024-08-20 16:40:45 +00:00
|
|
|
|
2024-07-16 23:52:46 +00:00
|
|
|
var subs = SelectedSubLang.Select(item => item.Content?.ToString());
|
|
|
|
SelectedSubs = string.Join(", ", subs) ?? "";
|
2024-05-04 15:35:32 +00:00
|
|
|
}
|
2024-08-20 16:40:45 +00:00
|
|
|
|
2024-06-24 15:40:20 +00:00
|
|
|
protected override void OnPropertyChanged(PropertyChangedEventArgs e){
|
|
|
|
base.OnPropertyChanged(e);
|
2024-05-04 15:35:32 +00:00
|
|
|
|
2024-08-20 16:40:45 +00:00
|
|
|
if (e.PropertyName is nameof(SelectedDubs) or nameof(SelectedSubs) or nameof(CustomAccentColor) or nameof(ListBoxColor) or nameof(CurrentAppTheme) or nameof(UseCustomAccent) or nameof(LogMode)){
|
2024-06-24 15:40:20 +00:00
|
|
|
return;
|
|
|
|
}
|
2024-08-20 16:40:45 +00:00
|
|
|
|
2024-06-11 21:58:44 +00:00
|
|
|
UpdateSettings();
|
2024-08-20 16:40:45 +00:00
|
|
|
|
|
|
|
if (e.PropertyName is nameof(History)){
|
|
|
|
if (CrunchyrollManager.Instance.CrunOptions.History){
|
|
|
|
if (File.Exists(CfgManager.PathCrHistory)){
|
|
|
|
var decompressedJson = CfgManager.DecompressJsonFile(CfgManager.PathCrHistory);
|
|
|
|
if (!string.IsNullOrEmpty(decompressedJson)){
|
|
|
|
CrunchyrollManager.Instance.HistoryList = Helpers.Deserialize<ObservableCollection<HistorySeries>>(decompressedJson, CrunchyrollManager.Instance.SettingsJsonSerializerSettings) ??
|
|
|
|
new ObservableCollection<HistorySeries>();
|
|
|
|
|
|
|
|
foreach (var historySeries in CrunchyrollManager.Instance.HistoryList){
|
|
|
|
historySeries.Init();
|
|
|
|
foreach (var historySeriesSeason in historySeries.Seasons){
|
|
|
|
historySeriesSeason.Init();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else{
|
|
|
|
CrunchyrollManager.Instance.HistoryList =[];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_ = SonarrClient.Instance.RefreshSonarrLite();
|
|
|
|
} else{
|
|
|
|
CrunchyrollManager.Instance.HistoryList =[];
|
|
|
|
}
|
|
|
|
}
|
2024-06-11 21:58:44 +00:00
|
|
|
}
|
2024-08-20 16:40:45 +00:00
|
|
|
|
2024-06-15 13:55:39 +00:00
|
|
|
partial void OnLogModeChanged(bool value){
|
|
|
|
UpdateSettings();
|
|
|
|
if (value){
|
|
|
|
CfgManager.EnableLogMode();
|
|
|
|
} else{
|
|
|
|
CfgManager.DisableLogMode();
|
|
|
|
}
|
|
|
|
}
|
2024-06-19 00:16:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public class MuxingParam{
|
|
|
|
public string ParamValue{ get; set; }
|
2024-05-04 15:35:32 +00:00
|
|
|
}
|