Chg - Save Auto Download & Remove Finished in settings
Fix - Search popup didn't close when dismissed
This commit is contained in:
parent
18c99f2a02
commit
9d499682ba
|
@ -148,8 +148,6 @@ public class CalendarManager{
|
||||||
|
|
||||||
|
|
||||||
public async Task<CalendarWeek> BuildCustomCalendar(bool forceUpdate){
|
public async Task<CalendarWeek> BuildCustomCalendar(bool forceUpdate){
|
||||||
Console.WriteLine("C" + DateTime.Now.ToString("yyyy-MM-dd"));
|
|
||||||
|
|
||||||
if (!forceUpdate && calendar.TryGetValue("C" + DateTime.Now.ToString("yyyy-MM-dd"), out var forDate)){
|
if (!forceUpdate && calendar.TryGetValue("C" + DateTime.Now.ToString("yyyy-MM-dd"), out var forDate)){
|
||||||
return forDate;
|
return forDate;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
|
@ -18,6 +19,7 @@ using CRD.Utils.Muxing;
|
||||||
using CRD.Utils.Sonarr;
|
using CRD.Utils.Sonarr;
|
||||||
using CRD.Utils.Structs;
|
using CRD.Utils.Structs;
|
||||||
using CRD.Utils.Structs.History;
|
using CRD.Utils.Structs.History;
|
||||||
|
using CRD.ViewModels;
|
||||||
using CRD.Views;
|
using CRD.Views;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
@ -30,7 +32,8 @@ public class CrunchyrollManager{
|
||||||
public CrCmsToken? CmsToken;
|
public CrCmsToken? CmsToken;
|
||||||
|
|
||||||
public CrProfile Profile = new();
|
public CrProfile Profile = new();
|
||||||
public CrDownloadOptions CrunOptions;
|
private readonly Lazy<CrDownloadOptions> _optionsLazy;
|
||||||
|
public CrDownloadOptions CrunOptions => _optionsLazy.Value;
|
||||||
|
|
||||||
#region History Variables
|
#region History Variables
|
||||||
|
|
||||||
|
@ -78,42 +81,50 @@ public class CrunchyrollManager{
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public CrunchyrollManager(){
|
public CrunchyrollManager(){
|
||||||
CrunOptions = new CrDownloadOptions();
|
_optionsLazy = new Lazy<CrDownloadOptions>(InitDownloadOptions, LazyThreadSafetyMode.ExecutionAndPublication);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private CrDownloadOptions InitDownloadOptions(){
|
||||||
|
|
||||||
|
var options = new CrDownloadOptions();
|
||||||
|
|
||||||
|
options.AutoDownload = false;
|
||||||
|
options.RemoveFinishedDownload = false;
|
||||||
|
options.Chapters = true;
|
||||||
|
options.Hslang = "none";
|
||||||
|
options.Force = "Y";
|
||||||
|
options.FileName = "${seriesTitle} - S${season}E${episode} [${height}p]";
|
||||||
|
options.Partsize = 10;
|
||||||
|
options.DlSubs = new List<string>{ "de-DE" };
|
||||||
|
options.Skipmux = false;
|
||||||
|
options.MkvmergeOptions = new List<string>{ "--no-date", "--disable-track-statistics-tags", "--engage no_variable_data" };
|
||||||
|
options.FfmpegOptions = new();
|
||||||
|
options.DefaultAudio = "ja-JP";
|
||||||
|
options.DefaultSub = "de-DE";
|
||||||
|
options.CcTag = "cc";
|
||||||
|
options.FsRetryTime = 5;
|
||||||
|
options.Numbers = 2;
|
||||||
|
options.Timeout = 15000;
|
||||||
|
options.DubLang = new List<string>(){ "ja-JP" };
|
||||||
|
options.SimultaneousDownloads = 2;
|
||||||
|
options.AccentColor = Colors.SlateBlue.ToString();
|
||||||
|
options.Theme = "System";
|
||||||
|
options.SelectedCalendarLanguage = "en-us";
|
||||||
|
options.CalendarDubFilter = "none";
|
||||||
|
options.DlVideoOnce = true;
|
||||||
|
options.StreamEndpoint = "web/firefox";
|
||||||
|
options.SubsAddScaledBorder = ScaledBorderAndShadowSelection.ScaledBorderAndShadowYes;
|
||||||
|
options.HistoryLang = DefaultLocale;
|
||||||
|
|
||||||
|
options.History = true;
|
||||||
|
|
||||||
|
CfgManager.UpdateSettingsFromFile(options);
|
||||||
|
|
||||||
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitOptions(){
|
public void InitOptions(){
|
||||||
CrunOptions.AutoDownload = false;
|
|
||||||
CrunOptions.RemoveFinishedDownload = false;
|
|
||||||
CrunOptions.Chapters = true;
|
|
||||||
CrunOptions.Hslang = "none";
|
|
||||||
CrunOptions.Force = "Y";
|
|
||||||
CrunOptions.FileName = "${seriesTitle} - S${season}E${episode} [${height}p]";
|
|
||||||
CrunOptions.Partsize = 10;
|
|
||||||
CrunOptions.DlSubs = new List<string>{ "de-DE" };
|
|
||||||
CrunOptions.Skipmux = false;
|
|
||||||
CrunOptions.MkvmergeOptions = new List<string>{ "--no-date", "--disable-track-statistics-tags", "--engage no_variable_data" };
|
|
||||||
CrunOptions.FfmpegOptions = new();
|
|
||||||
CrunOptions.DefaultAudio = "ja-JP";
|
|
||||||
CrunOptions.DefaultSub = "de-DE";
|
|
||||||
CrunOptions.CcTag = "cc";
|
|
||||||
CrunOptions.FsRetryTime = 5;
|
|
||||||
CrunOptions.Numbers = 2;
|
|
||||||
CrunOptions.Timeout = 15000;
|
|
||||||
CrunOptions.DubLang = new List<string>(){ "ja-JP" };
|
|
||||||
CrunOptions.SimultaneousDownloads = 2;
|
|
||||||
CrunOptions.AccentColor = Colors.SlateBlue.ToString();
|
|
||||||
CrunOptions.Theme = "System";
|
|
||||||
CrunOptions.SelectedCalendarLanguage = "en-us";
|
|
||||||
CrunOptions.CalendarDubFilter = "none";
|
|
||||||
CrunOptions.DlVideoOnce = true;
|
|
||||||
CrunOptions.StreamEndpoint = "web/firefox";
|
|
||||||
CrunOptions.SubsAddScaledBorder = ScaledBorderAndShadowSelection.ScaledBorderAndShadowYes;
|
|
||||||
CrunOptions.HistoryLang = DefaultLocale;
|
|
||||||
|
|
||||||
CrunOptions.History = true;
|
|
||||||
|
|
||||||
CfgManager.UpdateSettingsFromFile();
|
|
||||||
|
|
||||||
_widevine = Widevine.Instance;
|
_widevine = Widevine.Instance;
|
||||||
|
|
||||||
CrAuth = new CrAuth();
|
CrAuth = new CrAuth();
|
||||||
|
|
|
@ -147,7 +147,7 @@ public class CfgManager{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void UpdateSettingsFromFile(){
|
public static void UpdateSettingsFromFile(CrDownloadOptions options){
|
||||||
string dirPath = Path.GetDirectoryName(PathCrDownloadOptions) ?? string.Empty;
|
string dirPath = Path.GetDirectoryName(PathCrDownloadOptions) ?? string.Empty;
|
||||||
|
|
||||||
if (!Directory.Exists(dirPath)){
|
if (!Directory.Exists(dirPath)){
|
||||||
|
@ -174,7 +174,7 @@ public class CfgManager{
|
||||||
|
|
||||||
var propertiesPresentInYaml = GetTopLevelPropertiesInYaml(input);
|
var propertiesPresentInYaml = GetTopLevelPropertiesInYaml(input);
|
||||||
var loadedOptions = deserializer.Deserialize<CrDownloadOptions>(new StringReader(input));
|
var loadedOptions = deserializer.Deserialize<CrDownloadOptions>(new StringReader(input));
|
||||||
var instanceOptions = CrunchyrollManager.Instance.CrunOptions;
|
var instanceOptions = options;
|
||||||
|
|
||||||
foreach (PropertyInfo property in typeof(CrDownloadOptions).GetProperties()){
|
foreach (PropertyInfo property in typeof(CrDownloadOptions).GetProperties()){
|
||||||
var yamlMemberAttribute = property.GetCustomAttribute<YamlMemberAttribute>();
|
var yamlMemberAttribute = property.GetCustomAttribute<YamlMemberAttribute>();
|
||||||
|
|
|
@ -7,11 +7,11 @@ namespace CRD.Utils.Structs;
|
||||||
|
|
||||||
public class CrDownloadOptions{
|
public class CrDownloadOptions{
|
||||||
|
|
||||||
[YamlIgnore]
|
[YamlMember(Alias = "auto_download", ApplyNamingConventions = false)]
|
||||||
public bool AutoDownload{ get; set; }
|
public bool AutoDownload{ get; set; }
|
||||||
|
|
||||||
|
|
||||||
[YamlIgnore]
|
[YamlMember(Alias = "remove_finished_downloads", ApplyNamingConventions = false)]
|
||||||
public bool RemoveFinishedDownload{ get; set; }
|
public bool RemoveFinishedDownload{ get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,6 @@ public partial class AddDownloadPageViewModel : ViewModelBase{
|
||||||
|
|
||||||
SearchItems.Add(episode);
|
SearchItems.Add(episode);
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchPopupVisible = true;
|
SearchPopupVisible = true;
|
||||||
RaisePropertyChanged(nameof(SearchItems));
|
RaisePropertyChanged(nameof(SearchItems));
|
||||||
RaisePropertyChanged(nameof(SearchVisible));
|
RaisePropertyChanged(nameof(SearchVisible));
|
||||||
|
|
|
@ -9,6 +9,7 @@ using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
using CRD.Downloader;
|
using CRD.Downloader;
|
||||||
using CRD.Downloader.Crunchyroll;
|
using CRD.Downloader.Crunchyroll;
|
||||||
|
using CRD.Utils;
|
||||||
using CRD.Utils.Structs;
|
using CRD.Utils.Structs;
|
||||||
|
|
||||||
namespace CRD.ViewModels;
|
namespace CRD.ViewModels;
|
||||||
|
@ -17,10 +18,10 @@ public partial class DownloadsPageViewModel : ViewModelBase{
|
||||||
public ObservableCollection<DownloadItemModel> Items{ get; }
|
public ObservableCollection<DownloadItemModel> Items{ get; }
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
public bool _autoDownload;
|
private bool _autoDownload;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
public bool _removeFinished;
|
private bool _removeFinished;
|
||||||
|
|
||||||
public DownloadsPageViewModel(){
|
public DownloadsPageViewModel(){
|
||||||
QueueManager.Instance.UpdateDownloadListItems();
|
QueueManager.Instance.UpdateDownloadListItems();
|
||||||
|
@ -34,10 +35,12 @@ public partial class DownloadsPageViewModel : ViewModelBase{
|
||||||
if (value){
|
if (value){
|
||||||
QueueManager.Instance.UpdateDownloadListItems();
|
QueueManager.Instance.UpdateDownloadListItems();
|
||||||
}
|
}
|
||||||
|
CfgManager.WriteSettingsToFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
partial void OnRemoveFinishedChanged(bool value){
|
partial void OnRemoveFinishedChanged(bool value){
|
||||||
CrunchyrollManager.Instance.CrunOptions.RemoveFinishedDownload = value;
|
CrunchyrollManager.Instance.CrunOptions.RemoveFinishedDownload = value;
|
||||||
|
CfgManager.WriteSettingsToFile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@ public partial class MainWindowViewModel : ViewModelBase{
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
CleanUpOldUpdater();
|
CleanUpOldUpdater();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CleanUpOldUpdater(){
|
private void CleanUpOldUpdater(){
|
||||||
|
@ -66,6 +65,5 @@ public partial class MainWindowViewModel : ViewModelBase{
|
||||||
}
|
}
|
||||||
|
|
||||||
await CrunchyrollManager.Instance.Init();
|
await CrunchyrollManager.Instance.Init();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -25,12 +25,13 @@
|
||||||
<TextBox x:Name="SearchBar" Watermark="Enter series or episode url" Text="{Binding UrlInput}" Margin="10"
|
<TextBox x:Name="SearchBar" Watermark="Enter series or episode url" Text="{Binding UrlInput}" Margin="10"
|
||||||
VerticalAlignment="Top" />
|
VerticalAlignment="Top" />
|
||||||
|
|
||||||
<Popup IsLightDismissEnabled="False"
|
<Popup IsLightDismissEnabled="True"
|
||||||
MaxWidth="{Binding Bounds.Width, ElementName=SearchBar}"
|
MaxWidth="{Binding Bounds.Width, ElementName=SearchBar}"
|
||||||
MaxHeight="{Binding Bounds.Height, ElementName=Grid}"
|
MaxHeight="{Binding Bounds.Height, ElementName=Grid}"
|
||||||
IsOpen="{Binding SearchPopupVisible}"
|
IsOpen="{Binding SearchPopupVisible}"
|
||||||
Placement="Bottom"
|
Placement="Bottom"
|
||||||
PlacementTarget="{Binding ElementName=SearchBar}">
|
PlacementTarget="{Binding ElementName=SearchBar}"
|
||||||
|
Closed="Popup_Closed">
|
||||||
<Border BorderThickness="1" Background="{DynamicResource ComboBoxDropDownBackground}">
|
<Border BorderThickness="1" Background="{DynamicResource ComboBoxDropDownBackground}">
|
||||||
<ListBox x:Name="ListBoxDubsSelection"
|
<ListBox x:Name="ListBoxDubsSelection"
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
using Avalonia;
|
using System;
|
||||||
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
|
using CRD.ViewModels;
|
||||||
|
|
||||||
namespace CRD.Views;
|
namespace CRD.Views;
|
||||||
|
|
||||||
|
@ -8,4 +10,10 @@ public partial class AddDownloadPageView : UserControl{
|
||||||
public AddDownloadPageView(){
|
public AddDownloadPageView(){
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Popup_Closed(object? sender, EventArgs e){
|
||||||
|
if (DataContext is AddDownloadPageViewModel viewModel){
|
||||||
|
viewModel.SearchPopupVisible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue