using Newtonsoft.Json; using Newtonsoft.Json.Converters; using OF_DL.Enumerations; using Serilog; namespace OF_DL.Models.Config; public class Config : IFileNameFormatConfig { [ToggleableConfig] public bool DownloadAvatarHeaderPhoto { get; set; } = true; [ToggleableConfig] public bool DownloadPaidPosts { get; set; } = true; [ToggleableConfig] public bool DownloadPosts { get; set; } = true; [ToggleableConfig] public bool DownloadArchived { get; set; } = true; [ToggleableConfig] public bool DownloadStreams { get; set; } = true; [ToggleableConfig] public bool DownloadStories { get; set; } = true; [ToggleableConfig] public bool DownloadHighlights { get; set; } = true; [ToggleableConfig] public bool DownloadMessages { get; set; } = true; [ToggleableConfig] public bool DownloadPaidMessages { get; set; } = true; [ToggleableConfig] public bool DownloadImages { get; set; } = true; [ToggleableConfig] public bool DownloadVideos { get; set; } = true; [ToggleableConfig] public bool DownloadAudios { get; set; } = true; [ToggleableConfig] public bool IncludeExpiredSubscriptions { get; set; } [ToggleableConfig] public bool IncludeRestrictedSubscriptions { get; set; } [ToggleableConfig] public bool SkipAds { get; set; } public string? DownloadPath { get; set; } = ""; [ToggleableConfig] public bool RenameExistingFilesWhenCustomFormatIsSelected { get; set; } public int? Timeout { get; set; } = -1; [ToggleableConfig] public bool FolderPerPaidPost { get; set; } [ToggleableConfig] public bool FolderPerPost { get; set; } [ToggleableConfig] public bool FolderPerPaidMessage { get; set; } [ToggleableConfig] public bool FolderPerMessage { get; set; } [ToggleableConfig] public bool LimitDownloadRate { get; set; } public int DownloadLimitInMbPerSec { get; set; } = 4; // Indicates if you want to download only on specific dates. [ToggleableConfig] public bool DownloadOnlySpecificDates { get; set; } // This enum will define if we want data from before or after the CustomDate. [JsonConverter(typeof(StringEnumConverter))] public DownloadDateSelection DownloadDateSelection { get; set; } = DownloadDateSelection.before; // This is the specific date used in combination with the above enum. [JsonConverter(typeof(ShortDateConverter))] public DateTime? CustomDate { get; set; } = null; [ToggleableConfig] public bool ShowScrapeSize { get; set; } [ToggleableConfig] public bool DownloadPostsIncrementally { get; set; } public bool NonInteractiveMode { get; set; } public string NonInteractiveModeListName { get; set; } = ""; [ToggleableConfig] public bool NonInteractiveModePurchasedTab { get; set; } public string? FFmpegPath { get; set; } = ""; public string? FFprobePath { get; set; } = ""; [ToggleableConfig] public bool BypassContentForCreatorsWhoNoLongerExist { get; set; } public Dictionary CreatorConfigs { get; set; } = new(); [ToggleableConfig] public bool DownloadDuplicatedMedia { get; set; } public string IgnoredUsersListName { get; set; } = ""; [JsonConverter(typeof(StringEnumConverter))] public LoggingLevel LoggingLevel { get; set; } = LoggingLevel.Error; [JsonConverter(typeof(StringEnumConverter))] public Theme Theme { get; set; } = Theme.dark; [ToggleableConfig] public bool HideMissingCdmKeysWarning { get; set; } [ToggleableConfig] public bool IgnoreOwnMessages { get; set; } [ToggleableConfig] public bool DisableBrowserAuth { get; set; } [JsonConverter(typeof(StringEnumConverter))] public VideoResolution DownloadVideoResolution { get; set; } = VideoResolution.source; public double DrmVideoDurationMatchThreshold { get; set; } = 0.98; // When enabled, post/message text is stored as-is without XML stripping. [ToggleableConfig] public bool DisableTextSanitization { get; set; } public string? PaidPostFileNameFormat { get; set; } = ""; public string? PostFileNameFormat { get; set; } = ""; public string? PaidMessageFileNameFormat { get; set; } = ""; public string? MessageFileNameFormat { get; set; } = ""; public IFileNameFormatConfig GetCreatorFileNameFormatConfig(string username) { FileNameFormatConfig combinedFilenameFormatConfig = new() { PaidPostFileNameFormat = PaidPostFileNameFormat, PostFileNameFormat = PostFileNameFormat, PaidMessageFileNameFormat = PaidMessageFileNameFormat, MessageFileNameFormat = MessageFileNameFormat }; if (CreatorConfigs.TryGetValue(username, out CreatorConfig? creatorConfig)) { if (!string.IsNullOrEmpty(creatorConfig.PaidPostFileNameFormat)) { combinedFilenameFormatConfig.PaidPostFileNameFormat = creatorConfig.PaidPostFileNameFormat; } if (!string.IsNullOrEmpty(creatorConfig.PostFileNameFormat)) { combinedFilenameFormatConfig.PostFileNameFormat = creatorConfig.PostFileNameFormat; } if (!string.IsNullOrEmpty(creatorConfig.PaidMessageFileNameFormat)) { combinedFilenameFormatConfig.PaidMessageFileNameFormat = creatorConfig.PaidMessageFileNameFormat; } if (!string.IsNullOrEmpty(creatorConfig.MessageFileNameFormat)) { combinedFilenameFormatConfig.MessageFileNameFormat = creatorConfig.MessageFileNameFormat; } } Log.Debug("PaidMessageFilenameFormat: {CombinedConfigPaidMessageFileNameFormat}", combinedFilenameFormatConfig.PaidMessageFileNameFormat); Log.Debug("PostFileNameFormat: {CombinedConfigPostFileNameFormat}", combinedFilenameFormatConfig.PostFileNameFormat); Log.Debug("MessageFileNameFormat: {CombinedConfigMessageFileNameFormat}", combinedFilenameFormatConfig.MessageFileNameFormat); Log.Debug("PaidPostFileNameFormat: {CombinedConfigPaidPostFileNameFormat}", combinedFilenameFormatConfig.PaidPostFileNameFormat); return combinedFilenameFormatConfig; } private class ShortDateConverter : IsoDateTimeConverter { public ShortDateConverter() => DateTimeFormat = "yyyy-MM-dd"; } }