Crunchy-Downloader/CRD/Utils/Structs/CalendarStructs.cs
Elwador aca28a4e17 Add - Added option to **mux fonts into the MKV**
Add - Added **completion sound** when downloads finish, allowing a specified sound to be played
Add - Added **changelog** for easier tracking of changes and updates
Add - Added **Retry button** to reset all failed downloads, allowing "Auto Download" to restart them
Add - Added **dub/sub info** to the Upcoming tab
Chg - Changed **history table view** to include missing features from the poster view
Chg - Changed and **adjusted error messages**
Chg - Changed **chapters formatting** for consistent output across locales
Chg - Changed **Clear Queue** button to icon-only
Chg - Changed **update button** behavior
Chg - Changed some **error messages** for better debugging
Chg - Changed **history series access**, now allowing it to open while others are refreshing
Chg - Changed **device ID reuse** to fix continuous login emails
Chg - Changed **authentication log** to write the full message for better debugging
Chg - Updated **dependencies**
Fix - Temporary fix for **authentication issues**
Fix - Fixed **unable to download movies** [#237](https://github.com/Crunchy-DL/Crunchy-Downloader/issues/237)
Fix - Fixed **buggy queue behavior** during active downloads
Fix - Fixed **duplicate seasons in history** when adding multiple episodes from the calendar
Fix - Fixed crash if  **all** subtitles option is selected
Fix - Fixed "**Cannot set download directory to Drive**" https://github.com/Crunchy-DL/Crunchy-Downloader/issues/220
Fix - Fixed missing **subtitles and none subs** for some series
2025-04-04 20:12:29 +02:00

80 lines
No EOL
2.6 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Avalonia.Media.Imaging;
using CommunityToolkit.Mvvm.Input;
using CRD.Downloader;
using CRD.Downloader.Crunchyroll;
namespace CRD.Utils.Structs;
public class CalendarWeek{
public DateTime FirstDayOfWeek{ get; set; }
public string? FirstDayOfWeekString{ get; set; }
public List<CalendarDay>? CalendarDays{ get; set; }
}
public class CalendarDay{
public DateTime DateTime{ get; set; }
public string? DayName{ get; set; }
public List<CalendarEpisode> CalendarEpisodes{ get; set; } =[];
}
public partial class CalendarEpisode : INotifyPropertyChanged{
public DateTime DateTime{ get; set; }
public bool? HasPassed{ get; set; }
public string? EpisodeName{ get; set; }
public string? SeriesUrl{ get; set; }
public string? EpisodeUrl{ get; set; }
public string? ThumbnailUrl{ get; set; }
public Bitmap? ImageBitmap{ get; set; }
public string? EpisodeNumber{ get; set; }
public bool IsPremiumOnly{ get; set; }
public bool IsPremiere{ get; set; }
public string? SeasonName{ get; set; }
public string? CrSeriesID{ get; set; }
public bool AnilistEpisode{ get; set; }
public List<CalendarEpisode> CalendarEpisodes{ get; set; } =[];
public event PropertyChangedEventHandler? PropertyChanged;
[RelayCommand]
public async Task AddEpisodeToQue(){
if (EpisodeUrl != null){
var match = Regex.Match(EpisodeUrl, "/([^/]+)/watch/([^/]+)");
if (match.Success){
var locale = match.Groups[1].Value; // Capture the locale part
var id = match.Groups[2].Value; // Capture the ID part
await QueueManager.Instance.CrAddEpisodeToQueue(id, Languages.Locale2language(locale).CrLocale, CrunchyrollManager.Instance.CrunOptions.DubLang, true);
}
}
if (CalendarEpisodes.Count > 0){
foreach (var calendarEpisode in CalendarEpisodes){
calendarEpisode.AddEpisodeToQue();
}
}
}
public async Task LoadImage(int width = 0, int height = 0){
try{
if (!string.IsNullOrEmpty(ThumbnailUrl)){
ImageBitmap = await Helpers.LoadImage(ThumbnailUrl, width, height);
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ImageBitmap)));
}
} catch (Exception ex){
// Handle exceptions
Console.Error.WriteLine("Failed to load image: " + ex.Message);
}
}
}