Add - Filter By Air date toggle to custom calendar
This commit is contained in:
parent
c4922af741
commit
6b44dbf28c
|
@ -0,0 +1,51 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||||
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
|
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
||||||
|
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||||
|
<ApplicationIcon>Assets\app_icon.ico</ApplicationIcon>
|
||||||
|
<Version>1.5.2.0</Version>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<AvaloniaResource Include="Assets\**"/>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Avalonia" Version="11.1.0-beta2" />
|
||||||
|
<PackageReference Include="Avalonia.Desktop" Version="11.1.0-beta2" />
|
||||||
|
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.1.0-beta2" />
|
||||||
|
<PackageReference Include="Avalonia.ReactiveUI" Version="11.1.0-beta2" />
|
||||||
|
<PackageReference Include="BouncyCastle.Cryptography" Version="2.3.0" />
|
||||||
|
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
|
||||||
|
<PackageReference Include="ExtendedXmlSerializer" Version="3.7.18" />
|
||||||
|
<PackageReference Include="FluentAvaloniaUI" Version="2.1.0-preview5" />
|
||||||
|
<PackageReference Include="HtmlAgilityPack" Version="1.11.60" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
<PackageReference Include="protobuf-net" Version="3.2.30" />
|
||||||
|
<PackageReference Include="YamlDotNet" Version="15.1.2" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<UpToDateCheckInput Remove="Styling\ControlsGalleryStyles.axaml" />
|
||||||
|
<UpToDateCheckInput Remove="Styling\ControlThemes.axaml" />
|
||||||
|
<UpToDateCheckInput Remove="Views\Utils\ErrorWindow.axaml" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Update="Views\Utils\ContentDialogUpdateView.axaml.cs">
|
||||||
|
<DependentUpon>ContentDialogInputLoginView.axaml</DependentUpon>
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Update="Views\Utils\ContentDialogInputLoginView.axaml.cs">
|
||||||
|
<DependentUpon>ContentDialogInputLoginView.axaml</DependentUpon>
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
|
</Project>
|
|
@ -141,6 +141,9 @@ public class CrDownloadOptions{
|
||||||
[YamlMember(Alias = "calendar_hide_dubs", ApplyNamingConventions = false)]
|
[YamlMember(Alias = "calendar_hide_dubs", ApplyNamingConventions = false)]
|
||||||
public bool CalendarHideDubs{ get; set; }
|
public bool CalendarHideDubs{ get; set; }
|
||||||
|
|
||||||
|
[YamlMember(Alias = "calendar_filter_by_air_date", ApplyNamingConventions = false)]
|
||||||
|
public bool CalendarFilterByAirDate{ get; set; }
|
||||||
|
|
||||||
[YamlMember(Alias = "history", ApplyNamingConventions = false)]
|
[YamlMember(Alias = "history", ApplyNamingConventions = false)]
|
||||||
public bool History{ get; set; }
|
public bool History{ get; set; }
|
||||||
|
|
||||||
|
|
|
@ -16,13 +16,15 @@ public partial class CalendarPageViewModel : ViewModelBase{
|
||||||
public ObservableCollection<CalendarDay> CalendarDays{ get; set; }
|
public ObservableCollection<CalendarDay> CalendarDays{ get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool _showLoading;
|
private bool _showLoading;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool _customCalendar;
|
private bool _customCalendar;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private bool _filterByAirDate;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool _hideDubs;
|
private bool _hideDubs;
|
||||||
|
|
||||||
|
@ -63,6 +65,7 @@ public partial class CalendarPageViewModel : ViewModelBase{
|
||||||
|
|
||||||
CustomCalendar = Crunchyroll.Instance.CrunOptions.CustomCalendar;
|
CustomCalendar = Crunchyroll.Instance.CrunOptions.CustomCalendar;
|
||||||
HideDubs = Crunchyroll.Instance.CrunOptions.CalendarHideDubs;
|
HideDubs = Crunchyroll.Instance.CrunOptions.CalendarHideDubs;
|
||||||
|
HideDubs = Crunchyroll.Instance.CrunOptions.CalendarFilterByAirDate;
|
||||||
|
|
||||||
ComboBoxItem? dubfilter = CalendarDubFilter.FirstOrDefault(a => a.Content != null && (string)a.Content == Crunchyroll.Instance.CrunOptions.CalendarDubFilter) ?? null;
|
ComboBoxItem? dubfilter = CalendarDubFilter.FirstOrDefault(a => a.Content != null && (string)a.Content == Crunchyroll.Instance.CrunOptions.CalendarDubFilter) ?? null;
|
||||||
CurrentCalendarDubFilter = dubfilter ?? CalendarDubFilter[0];
|
CurrentCalendarDubFilter = dubfilter ?? CalendarDubFilter[0];
|
||||||
|
@ -95,7 +98,6 @@ public partial class CalendarPageViewModel : ViewModelBase{
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void LoadCalendar(string mondayDate, bool forceUpdate){
|
public async void LoadCalendar(string mondayDate, bool forceUpdate){
|
||||||
|
|
||||||
if (CustomCalendar){
|
if (CustomCalendar){
|
||||||
BuildCustomCalendar();
|
BuildCustomCalendar();
|
||||||
return;
|
return;
|
||||||
|
@ -121,6 +123,7 @@ public partial class CalendarPageViewModel : ViewModelBase{
|
||||||
calendarDay.CalendarEpisodes.Remove(calendarDayCalendarEpisode);
|
calendarDay.CalendarEpisodes.Remove(calendarDayCalendarEpisode);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (calendarDayCalendarEpisode.ImageBitmap == null){
|
if (calendarDayCalendarEpisode.ImageBitmap == null){
|
||||||
calendarDayCalendarEpisode.LoadImage();
|
calendarDayCalendarEpisode.LoadImage();
|
||||||
}
|
}
|
||||||
|
@ -141,7 +144,6 @@ public partial class CalendarPageViewModel : ViewModelBase{
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
public void Refresh(){
|
public void Refresh(){
|
||||||
|
|
||||||
if (loading){
|
if (loading){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -233,6 +235,15 @@ public partial class CalendarPageViewModel : ViewModelBase{
|
||||||
CfgManager.WriteSettingsToFile();
|
CfgManager.WriteSettingsToFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
partial void OnFilterByAirDateChanged(bool value){
|
||||||
|
if (loading){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Crunchyroll.Instance.CrunOptions.CalendarFilterByAirDate = value;
|
||||||
|
CfgManager.WriteSettingsToFile();
|
||||||
|
}
|
||||||
|
|
||||||
partial void OnCurrentCalendarDubFilterChanged(ComboBoxItem? value){
|
partial void OnCurrentCalendarDubFilterChanged(ComboBoxItem? value){
|
||||||
if (loading){
|
if (loading){
|
||||||
return;
|
return;
|
||||||
|
@ -242,13 +253,12 @@ public partial class CalendarPageViewModel : ViewModelBase{
|
||||||
Crunchyroll.Instance.CrunOptions.CalendarDubFilter = value?.Content + "";
|
Crunchyroll.Instance.CrunOptions.CalendarDubFilter = value?.Content + "";
|
||||||
CfgManager.WriteSettingsToFile();
|
CfgManager.WriteSettingsToFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void BuildCustomCalendar(){
|
private async void BuildCustomCalendar(){
|
||||||
ShowLoading = true;
|
ShowLoading = true;
|
||||||
|
|
||||||
var newEpisodesBase = await Crunchyroll.Instance.CrEpisode.GetNewEpisodes(Crunchyroll.Instance.CrunOptions.HistoryLang,200);
|
var newEpisodesBase = await Crunchyroll.Instance.CrEpisode.GetNewEpisodes(Crunchyroll.Instance.CrunOptions.HistoryLang, 200);
|
||||||
|
|
||||||
CalendarWeek week = new CalendarWeek();
|
CalendarWeek week = new CalendarWeek();
|
||||||
week.CalendarDays = new List<CalendarDay>();
|
week.CalendarDays = new List<CalendarDay>();
|
||||||
|
@ -271,7 +281,7 @@ public partial class CalendarPageViewModel : ViewModelBase{
|
||||||
var newEpisodes = newEpisodesBase.Data;
|
var newEpisodes = newEpisodesBase.Data;
|
||||||
|
|
||||||
foreach (var crBrowseEpisode in newEpisodes){
|
foreach (var crBrowseEpisode in newEpisodes){
|
||||||
var episodeAirDate = crBrowseEpisode.EpisodeMetadata.EpisodeAirDate;
|
var targetDate = FilterByAirDate ? crBrowseEpisode.EpisodeMetadata.EpisodeAirDate : crBrowseEpisode.LastPublic;
|
||||||
|
|
||||||
if (HideDubs && crBrowseEpisode.EpisodeMetadata.SeasonTitle != null && crBrowseEpisode.EpisodeMetadata.SeasonTitle.EndsWith("Dub)")){
|
if (HideDubs && crBrowseEpisode.EpisodeMetadata.SeasonTitle != null && crBrowseEpisode.EpisodeMetadata.SeasonTitle.EndsWith("Dub)")){
|
||||||
continue;
|
continue;
|
||||||
|
@ -284,13 +294,15 @@ public partial class CalendarPageViewModel : ViewModelBase{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var calendarDay = week.CalendarDays.FirstOrDefault(day => day.DateTime != null && day.DateTime.Value.Date == episodeAirDate.Date);
|
var calendarDay = (from day in week.CalendarDays
|
||||||
|
where day.DateTime.HasValue && day.DateTime.Value.Date == targetDate.Date
|
||||||
|
select day).FirstOrDefault();
|
||||||
|
|
||||||
if (calendarDay != null){
|
if (calendarDay != null){
|
||||||
CalendarEpisode calEpisode = new CalendarEpisode();
|
CalendarEpisode calEpisode = new CalendarEpisode();
|
||||||
|
|
||||||
calEpisode.DateTime = episodeAirDate;
|
calEpisode.DateTime = targetDate;
|
||||||
calEpisode.HasPassed = DateTime.Now > episodeAirDate;
|
calEpisode.HasPassed = DateTime.Now > targetDate;
|
||||||
calEpisode.EpisodeName = crBrowseEpisode.Title;
|
calEpisode.EpisodeName = crBrowseEpisode.Title;
|
||||||
calEpisode.SeriesUrl = "https://www.crunchyroll.com/series/" + crBrowseEpisode.EpisodeMetadata.SeriesId;
|
calEpisode.SeriesUrl = "https://www.crunchyroll.com/series/" + crBrowseEpisode.EpisodeMetadata.SeriesId;
|
||||||
calEpisode.EpisodeUrl = $"https://www.crunchyroll.com/de/watch/{crBrowseEpisode.Id}/";
|
calEpisode.EpisodeUrl = $"https://www.crunchyroll.com/de/watch/{crBrowseEpisode.Id}/";
|
||||||
|
|
|
@ -90,16 +90,21 @@
|
||||||
<controls:SettingsExpander IsVisible="{Binding CustomCalendar}" Header="Custom Calendar Dub Filter">
|
<controls:SettingsExpander IsVisible="{Binding CustomCalendar}" Header="Custom Calendar Dub Filter">
|
||||||
|
|
||||||
<controls:SettingsExpander.Footer>
|
<controls:SettingsExpander.Footer>
|
||||||
|
<StackPanel Orientation="Vertical">
|
||||||
<ComboBox HorizontalAlignment="Center" Margin="10 0 0 0" MinWidth="200"
|
<ComboBox HorizontalAlignment="Center" Margin="5 0 0 5" MinWidth="200"
|
||||||
SelectedItem="{Binding CurrentCalendarDubFilter}"
|
SelectedItem="{Binding CurrentCalendarDubFilter}"
|
||||||
ItemsSource="{Binding CalendarDubFilter}">
|
ItemsSource="{Binding CalendarDubFilter}">
|
||||||
</ComboBox>
|
</ComboBox>
|
||||||
|
<CheckBox IsChecked="{Binding FilterByAirDate}"
|
||||||
|
Content="Filter by episode air date" Margin="5 5 0 0">
|
||||||
|
</CheckBox>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
</controls:SettingsExpander.Footer>
|
</controls:SettingsExpander.Footer>
|
||||||
|
|
||||||
</controls:SettingsExpander>
|
</controls:SettingsExpander>
|
||||||
|
|
||||||
|
|
||||||
<controls:SettingsExpander Header="Calendar ">
|
<controls:SettingsExpander Header="Calendar ">
|
||||||
<controls:SettingsExpander.Footer>
|
<controls:SettingsExpander.Footer>
|
||||||
<CheckBox IsChecked="{Binding HideDubs}"
|
<CheckBox IsChecked="{Binding HideDubs}"
|
||||||
|
|
Loading…
Reference in New Issue