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>
|
|
@ -140,6 +140,9 @@ public class CrDownloadOptions{
|
|||
|
||||
[YamlMember(Alias = "calendar_hide_dubs", ApplyNamingConventions = false)]
|
||||
public bool CalendarHideDubs{ get; set; }
|
||||
|
||||
[YamlMember(Alias = "calendar_filter_by_air_date", ApplyNamingConventions = false)]
|
||||
public bool CalendarFilterByAirDate{ get; set; }
|
||||
|
||||
[YamlMember(Alias = "history", ApplyNamingConventions = false)]
|
||||
public bool History{ get; set; }
|
||||
|
|
|
@ -16,23 +16,25 @@ public partial class CalendarPageViewModel : ViewModelBase{
|
|||
public ObservableCollection<CalendarDay> CalendarDays{ get; set; }
|
||||
|
||||
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _showLoading;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _customCalendar;
|
||||
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _filterByAirDate;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _hideDubs;
|
||||
|
||||
public ObservableCollection<ComboBoxItem> CalendarDubFilter{ get; } = new(){
|
||||
new ComboBoxItem(){ Content = "none" },
|
||||
};
|
||||
|
||||
|
||||
[ObservableProperty]
|
||||
private ComboBoxItem? _currentCalendarDubFilter;
|
||||
|
||||
|
||||
public ObservableCollection<ComboBoxItem> CalendarLanguage{ get; } = new(){
|
||||
new ComboBoxItem(){ Content = "en-us" },
|
||||
new ComboBoxItem(){ Content = "es" },
|
||||
|
@ -46,27 +48,28 @@ public partial class CalendarPageViewModel : ViewModelBase{
|
|||
new ComboBoxItem(){ Content = "ru" },
|
||||
new ComboBoxItem(){ Content = "hi" },
|
||||
};
|
||||
|
||||
|
||||
[ObservableProperty]
|
||||
private ComboBoxItem? _currentCalendarLanguage;
|
||||
|
||||
private CalendarWeek? currentWeek;
|
||||
|
||||
private bool loading = true;
|
||||
|
||||
|
||||
public CalendarPageViewModel(){
|
||||
CalendarDays = new ObservableCollection<CalendarDay>();
|
||||
|
||||
|
||||
foreach (var languageItem in Languages.languages){
|
||||
CalendarDubFilter.Add(new ComboBoxItem{ Content = languageItem.CrLocale });
|
||||
}
|
||||
|
||||
|
||||
CustomCalendar = Crunchyroll.Instance.CrunOptions.CustomCalendar;
|
||||
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;
|
||||
CurrentCalendarDubFilter = dubfilter ?? CalendarDubFilter[0];
|
||||
|
||||
|
||||
CurrentCalendarLanguage = CalendarLanguage.FirstOrDefault(a => a.Content != null && (string)a.Content == Crunchyroll.Instance.CrunOptions.SelectedCalendarLanguage) ?? CalendarLanguage[0];
|
||||
loading = false;
|
||||
LoadCalendar(GetThisWeeksMondayDate(), false);
|
||||
|
@ -95,12 +98,11 @@ public partial class CalendarPageViewModel : ViewModelBase{
|
|||
}
|
||||
|
||||
public async void LoadCalendar(string mondayDate, bool forceUpdate){
|
||||
|
||||
if (CustomCalendar){
|
||||
BuildCustomCalendar();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ShowLoading = true;
|
||||
CalendarWeek week = await Crunchyroll.Instance.GetCalendarForDate(mondayDate, forceUpdate);
|
||||
if (currentWeek != null && currentWeek == week){
|
||||
|
@ -113,7 +115,7 @@ public partial class CalendarPageViewModel : ViewModelBase{
|
|||
CalendarDays.AddRange(week.CalendarDays);
|
||||
RaisePropertyChanged(nameof(CalendarDays));
|
||||
ShowLoading = false;
|
||||
|
||||
|
||||
foreach (var calendarDay in CalendarDays){
|
||||
var episodesCopy = new List<CalendarEpisode>(calendarDay.CalendarEpisodes);
|
||||
foreach (var calendarDayCalendarEpisode in episodesCopy){
|
||||
|
@ -121,6 +123,7 @@ public partial class CalendarPageViewModel : ViewModelBase{
|
|||
calendarDay.CalendarEpisodes.Remove(calendarDayCalendarEpisode);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (calendarDayCalendarEpisode.ImageBitmap == null){
|
||||
calendarDayCalendarEpisode.LoadImage();
|
||||
}
|
||||
|
@ -141,16 +144,15 @@ public partial class CalendarPageViewModel : ViewModelBase{
|
|||
|
||||
[RelayCommand]
|
||||
public void Refresh(){
|
||||
|
||||
if (loading){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (CustomCalendar){
|
||||
BuildCustomCalendar();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
string mondayDate;
|
||||
|
||||
if (currentWeek is{ FirstDayOfWeekString: not null }){
|
||||
|
@ -167,7 +169,7 @@ public partial class CalendarPageViewModel : ViewModelBase{
|
|||
if (loading){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
string mondayDate;
|
||||
|
||||
if (currentWeek is{ FirstDayOfWeek: not null }){
|
||||
|
@ -184,7 +186,7 @@ public partial class CalendarPageViewModel : ViewModelBase{
|
|||
if (loading){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
string mondayDate;
|
||||
|
||||
if (currentWeek is{ FirstDayOfWeek: not null }){
|
||||
|
@ -201,7 +203,7 @@ public partial class CalendarPageViewModel : ViewModelBase{
|
|||
if (loading){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (value?.Content != null){
|
||||
Crunchyroll.Instance.CrunOptions.SelectedCalendarLanguage = value.Content.ToString();
|
||||
Refresh();
|
||||
|
@ -213,13 +215,13 @@ public partial class CalendarPageViewModel : ViewModelBase{
|
|||
if (loading){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (CustomCalendar){
|
||||
BuildCustomCalendar();
|
||||
} else{
|
||||
LoadCalendar(GetThisWeeksMondayDate(), true);
|
||||
}
|
||||
|
||||
|
||||
Crunchyroll.Instance.CrunOptions.CustomCalendar = value;
|
||||
CfgManager.WriteSettingsToFile();
|
||||
}
|
||||
|
@ -228,10 +230,19 @@ public partial class CalendarPageViewModel : ViewModelBase{
|
|||
if (loading){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Crunchyroll.Instance.CrunOptions.CalendarHideDubs = value;
|
||||
CfgManager.WriteSettingsToFile();
|
||||
}
|
||||
|
||||
partial void OnFilterByAirDateChanged(bool value){
|
||||
if (loading){
|
||||
return;
|
||||
}
|
||||
|
||||
Crunchyroll.Instance.CrunOptions.CalendarFilterByAirDate = value;
|
||||
CfgManager.WriteSettingsToFile();
|
||||
}
|
||||
|
||||
partial void OnCurrentCalendarDubFilterChanged(ComboBoxItem? value){
|
||||
if (loading){
|
||||
|
@ -242,13 +253,12 @@ public partial class CalendarPageViewModel : ViewModelBase{
|
|||
Crunchyroll.Instance.CrunOptions.CalendarDubFilter = value?.Content + "";
|
||||
CfgManager.WriteSettingsToFile();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private async void BuildCustomCalendar(){
|
||||
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();
|
||||
week.CalendarDays = new List<CalendarDay>();
|
||||
|
@ -271,8 +281,8 @@ public partial class CalendarPageViewModel : ViewModelBase{
|
|||
var newEpisodes = newEpisodesBase.Data;
|
||||
|
||||
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)")){
|
||||
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){
|
||||
CalendarEpisode calEpisode = new CalendarEpisode();
|
||||
|
||||
calEpisode.DateTime = episodeAirDate;
|
||||
calEpisode.HasPassed = DateTime.Now > episodeAirDate;
|
||||
calEpisode.DateTime = targetDate;
|
||||
calEpisode.HasPassed = DateTime.Now > targetDate;
|
||||
calEpisode.EpisodeName = crBrowseEpisode.Title;
|
||||
calEpisode.SeriesUrl = "https://www.crunchyroll.com/series/" + crBrowseEpisode.EpisodeMetadata.SeriesId;
|
||||
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.Footer>
|
||||
|
||||
<ComboBox HorizontalAlignment="Center" Margin="10 0 0 0" MinWidth="200"
|
||||
SelectedItem="{Binding CurrentCalendarDubFilter}"
|
||||
ItemsSource="{Binding CalendarDubFilter}">
|
||||
</ComboBox>
|
||||
|
||||
<StackPanel Orientation="Vertical">
|
||||
<ComboBox HorizontalAlignment="Center" Margin="5 0 0 5" MinWidth="200"
|
||||
SelectedItem="{Binding CurrentCalendarDubFilter}"
|
||||
ItemsSource="{Binding CalendarDubFilter}">
|
||||
</ComboBox>
|
||||
<CheckBox IsChecked="{Binding FilterByAirDate}"
|
||||
Content="Filter by episode air date" Margin="5 5 0 0">
|
||||
</CheckBox>
|
||||
</StackPanel>
|
||||
|
||||
</controls:SettingsExpander.Footer>
|
||||
|
||||
</controls:SettingsExpander>
|
||||
|
||||
|
||||
<controls:SettingsExpander Header="Calendar ">
|
||||
<controls:SettingsExpander.Footer>
|
||||
<CheckBox IsChecked="{Binding HideDubs}"
|
||||
|
|
Loading…
Reference in New Issue