From 407419a819c91506ddf8da807846d4bb449cd38f Mon Sep 17 00:00:00 2001 From: whimsical-c4lic0 Date: Mon, 9 Feb 2026 00:55:28 -0600 Subject: [PATCH] Replace string.Empty with "" --- OF DL/Models/Auth.cs | 10 ++--- OF DL/Models/Config.cs | 16 +++---- OF DL/Models/Mappers/SubscriptionsMapper.cs | 2 +- OF DL/Services/APIService.cs | 42 ++++++++--------- OF DL/Services/DownloadService.cs | 50 ++++++++++----------- OF DL/Utils/XmlUtils.cs | 4 +- 6 files changed, 62 insertions(+), 62 deletions(-) diff --git a/OF DL/Models/Auth.cs b/OF DL/Models/Auth.cs index e718a53..7369d34 100644 --- a/OF DL/Models/Auth.cs +++ b/OF DL/Models/Auth.cs @@ -4,10 +4,10 @@ namespace OF_DL.Models; public class Auth { - public string? USER_ID { get; set; } = string.Empty; - public string? USER_AGENT { get; set; } = string.Empty; - public string? X_BC { get; set; } = string.Empty; - public string? COOKIE { get; set; } = string.Empty; + public string? USER_ID { get; set; } = ""; + public string? USER_AGENT { get; set; } = ""; + public string? X_BC { get; set; } = ""; + public string? COOKIE { get; set; } = ""; - [JsonIgnore] public string? FFMPEG_PATH { get; set; } = string.Empty; + [JsonIgnore] public string? FFMPEG_PATH { get; set; } = ""; } diff --git a/OF DL/Models/Config.cs b/OF DL/Models/Config.cs index 05aa188..aeb77b7 100644 --- a/OF DL/Models/Config.cs +++ b/OF DL/Models/Config.cs @@ -37,7 +37,7 @@ public class Config : IFileNameFormatConfig [ToggleableConfig] public bool SkipAds { get; set; } = false; - public string? DownloadPath { get; set; } = string.Empty; + public string? DownloadPath { get; set; } = ""; [ToggleableConfig] public bool RenameExistingFilesWhenCustomFormatIsSelected { get; set; } = false; @@ -71,11 +71,11 @@ public class Config : IFileNameFormatConfig [ToggleableConfig] public bool DownloadPostsIncrementally { get; set; } = false; public bool NonInteractiveMode { get; set; } = false; - public string NonInteractiveModeListName { get; set; } = string.Empty; + public string NonInteractiveModeListName { get; set; } = ""; [ToggleableConfig] public bool NonInteractiveModePurchasedTab { get; set; } = false; - public string? FFmpegPath { get; set; } = string.Empty; + public string? FFmpegPath { get; set; } = ""; [ToggleableConfig] public bool BypassContentForCreatorsWhoNoLongerExist { get; set; } = false; @@ -83,7 +83,7 @@ public class Config : IFileNameFormatConfig [ToggleableConfig] public bool DownloadDuplicatedMedia { get; set; } = false; - public string IgnoredUsersListName { get; set; } = string.Empty; + public string IgnoredUsersListName { get; set; } = ""; [JsonConverter(typeof(StringEnumConverter))] public LoggingLevel LoggingLevel { get; set; } = LoggingLevel.Error; @@ -98,10 +98,10 @@ public class Config : IFileNameFormatConfig // When enabled, post/message text is stored as-is without XML stripping. [ToggleableConfig] public bool DisableTextSanitization { get; set; } = false; - public string? PaidPostFileNameFormat { get; set; } = string.Empty; - public string? PostFileNameFormat { get; set; } = string.Empty; - public string? PaidMessageFileNameFormat { get; set; } = string.Empty; - public string? MessageFileNameFormat { get; set; } = string.Empty; + 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) { diff --git a/OF DL/Models/Mappers/SubscriptionsMapper.cs b/OF DL/Models/Mappers/SubscriptionsMapper.cs index 29859d5..9c9f2fd 100644 --- a/OF DL/Models/Mappers/SubscriptionsMapper.cs +++ b/OF DL/Models/Mappers/SubscriptionsMapper.cs @@ -23,5 +23,5 @@ public static class SubscriptionsMapper } private static ListItem MapList(ListItemDto dto) => - new() { Id = dto.Id, Username = dto.Username ?? string.Empty, IsRestricted = dto.IsRestricted }; + new() { Id = dto.Id, Username = dto.Username ?? "", IsRestricted = dto.IsRestricted }; } diff --git a/OF DL/Services/APIService.cs b/OF DL/Services/APIService.cs index e3b6e88..0872e93 100644 --- a/OF DL/Services/APIService.cs +++ b/OF DL/Services/APIService.cs @@ -409,17 +409,17 @@ public class APIService(IAuthService authService, IConfigService configService, { if (story.Media[0].CreatedAt.HasValue) { - await dbService.AddStory(folder, story.Id, string.Empty, "0", false, false, + await dbService.AddStory(folder, story.Id, "", "0", false, false, story.Media[0].CreatedAt.Value); } else if (story.CreatedAt.HasValue) { - await dbService.AddStory(folder, story.Id, string.Empty, "0", false, false, + await dbService.AddStory(folder, story.Id, "", "0", false, false, story.CreatedAt.Value); } else { - await dbService.AddStory(folder, story.Id, string.Empty, "0", false, false, DateTime.Now); + await dbService.AddStory(folder, story.Id, "", "0", false, false, DateTime.Now); } if (story.Media != null && story.Media.Count > 0) @@ -505,7 +505,7 @@ public class APIService(IAuthService authService, IConfigService configService, foreach (string highlight_id in highlight_ids) { Dictionary highlight_headers = - GetDynamicHeaders("/api2/v2/stories/highlights/" + highlight_id, string.Empty); + GetDynamicHeaders("/api2/v2/stories/highlights/" + highlight_id, ""); HttpClient highlight_client = GetHttpClient(); @@ -529,17 +529,17 @@ public class APIService(IAuthService authService, IConfigService configService, { if (item.Media != null && item.Media.Count > 0 && item.Media[0].CreatedAt.HasValue) { - await dbService.AddStory(folder, item.Id, string.Empty, "0", false, false, + await dbService.AddStory(folder, item.Id, "", "0", false, false, item.Media[0].CreatedAt.Value); } else if (item.CreatedAt.HasValue) { - await dbService.AddStory(folder, item.Id, string.Empty, "0", false, false, + await dbService.AddStory(folder, item.Id, "", "0", false, false, item.CreatedAt.Value); } else { - await dbService.AddStory(folder, item.Id, string.Empty, "0", false, false, + await dbService.AddStory(folder, item.Id, "", "0", false, false, DateTime.Now); } @@ -547,7 +547,7 @@ public class APIService(IAuthService authService, IConfigService configService, { foreach (HighlightEntities.Medium medium in item.Media) { - string storyUrl = item.Media[0].Files?.Full?.Url ?? string.Empty; + string storyUrl = item.Media[0].Files?.Full?.Url ?? ""; await dbService.AddMedia(folder, medium.Id, item.Id, storyUrl, null, null, null, "Stories", medium.Type == "photo" ? "Images" : @@ -687,7 +687,7 @@ public class APIService(IAuthService authService, IConfigService configService, } } - await dbService.AddPost(folder, purchase.Id, purchase.Text != null ? purchase.Text : string.Empty, + await dbService.AddPost(folder, purchase.Id, purchase.Text != null ? purchase.Text : "", purchase.Price != null ? purchase.Price : "0", purchase.Price != null && purchase.IsOpened ? true : false, purchase.IsArchived.HasValue ? purchase.IsArchived.Value : false, @@ -926,7 +926,7 @@ public class APIService(IAuthService authService, IConfigService configService, } } - await dbService.AddPost(folder, post.Id, post.RawText != null ? post.RawText : string.Empty, + await dbService.AddPost(folder, post.Id, post.RawText != null ? post.RawText : "", post.Price != null ? post.Price : "0", post.Price != null && post.IsOpened ? true : false, post.IsArchived, post.PostedAt); postCollection.PostObjects.Add(post); @@ -1066,7 +1066,7 @@ public class APIService(IAuthService authService, IConfigService configService, } } - await dbService.AddPost(folder, singlePost.Id, singlePost.Text != null ? singlePost.Text : string.Empty, + await dbService.AddPost(folder, singlePost.Id, singlePost.Text != null ? singlePost.Text : "", singlePost.Price != null ? singlePost.Price : "0", singlePost.Price != null && singlePost.IsOpened ? true : false, singlePost.IsArchived, singlePost.PostedAt); @@ -1302,7 +1302,7 @@ public class APIService(IAuthService authService, IConfigService configService, } } - await dbService.AddPost(folder, stream.Id, stream.Text != null ? stream.Text : string.Empty, + await dbService.AddPost(folder, stream.Id, stream.Text != null ? stream.Text : "", stream.Price != null ? stream.Price : "0", stream.Price != null && stream.IsOpened ? true : false, stream.IsArchived, stream.PostedAt); streamsCollection.StreamObjects.Add(stream); @@ -1479,7 +1479,7 @@ public class APIService(IAuthService authService, IConfigService configService, } } - await dbService.AddPost(folder, archive.Id, archive.Text != null ? archive.Text : string.Empty, + await dbService.AddPost(folder, archive.Id, archive.Text != null ? archive.Text : "", archive.Price != null ? archive.Price : "0", archive.Price != null && archive.IsOpened ? true : false, archive.IsArchived, archive.PostedAt); archivedCollection.ArchivedPostObjects.Add(archive); @@ -1636,7 +1636,7 @@ public class APIService(IAuthService authService, IConfigService configService, if (!configService.CurrentConfig.IgnoreOwnMessages || list.FromUser?.Id != Convert.ToInt32(authService.CurrentAuth.USER_ID)) { - await dbService.AddMessage(folder, list.Id, list.Text ?? string.Empty, list.Price ?? "0", + await dbService.AddMessage(folder, list.Id, list.Text ?? "", list.Price ?? "0", list.CanPurchaseReason == "opened" ? true : list.CanPurchaseReason != "opened" ? false : (bool?)null ?? false, false, list.CreatedAt.HasValue ? list.CreatedAt.Value : DateTime.Now, @@ -1836,7 +1836,7 @@ public class APIService(IAuthService authService, IConfigService configService, if (!configService.CurrentConfig.IgnoreOwnMessages || message.FromUser?.Id != Convert.ToInt32(authService.CurrentAuth.USER_ID)) { - await dbService.AddMessage(folder, message.Id, message.Text ?? string.Empty, + await dbService.AddMessage(folder, message.Id, message.Text ?? "", message.Price != null ? message.Price.ToString() : "0", true, false, message.CreatedAt.HasValue ? message.CreatedAt.Value : DateTime.Now, message.FromUser?.Id ?? int.MinValue); @@ -2106,14 +2106,14 @@ public class APIService(IAuthService authService, IConfigService configService, if (purchase.PostedAt != null) { await dbService.AddMessage(folder, purchase.Id, - purchase.Text != null ? purchase.Text : string.Empty, + purchase.Text != null ? purchase.Text : "", purchase.Price != null ? purchase.Price : "0", true, false, purchase.PostedAt.Value, purchase.FromUser.Id); } else { await dbService.AddMessage(folder, purchase.Id, - purchase.Text != null ? purchase.Text : string.Empty, + purchase.Text != null ? purchase.Text : "", purchase.Price != null ? purchase.Price : "0", true, false, purchase.CreatedAt.Value, purchase.FromUser.Id); } @@ -2670,7 +2670,7 @@ public class APIService(IAuthService authService, IConfigService configService, } await dbService.AddPost(path, purchase.Id, - purchase.Text != null ? purchase.Text : string.Empty, + purchase.Text != null ? purchase.Text : "", purchase.Price != null ? purchase.Price : "0", purchase.Price != null && purchase.IsOpened ? true : false, purchase.IsArchived.HasValue ? purchase.IsArchived.Value : false, @@ -2775,14 +2775,14 @@ public class APIService(IAuthService authService, IConfigService configService, if (purchase.PostedAt != null) { await dbService.AddMessage(path, purchase.Id, - purchase.Text != null ? purchase.Text : string.Empty, + purchase.Text != null ? purchase.Text : "", purchase.Price != null ? purchase.Price : "0", true, false, purchase.PostedAt.Value, purchase.FromUser.Id); } else { await dbService.AddMessage(path, purchase.Id, - purchase.Text != null ? purchase.Text : string.Empty, + purchase.Text != null ? purchase.Text : "", purchase.Price != null ? purchase.Price : "0", true, false, purchase.CreatedAt.Value, purchase.FromUser.Id); } @@ -3124,7 +3124,7 @@ public class APIService(IAuthService authService, IConfigService configService, try { - string dcValue = string.Empty; + string dcValue = ""; HttpClient client = new(); CDRMProjectRequest cdrmProjectRequest = new() diff --git a/OF DL/Services/DownloadService.cs b/OF DL/Services/DownloadService.cs index 91cffc2..aa9d4c9 100644 --- a/OF DL/Services/DownloadService.cs +++ b/OF DL/Services/DownloadService.cs @@ -194,7 +194,7 @@ public class DownloadService( LoggingLevel.Warning => "-loglevel warning", LoggingLevel.Error => "-loglevel error", LoggingLevel.Fatal => "-loglevel fatal", - _ => string.Empty + _ => "" }; if (logLevelArgs.Contains("-report", StringComparison.OrdinalIgnoreCase)) @@ -430,7 +430,7 @@ public class DownloadService( { try { - string customFileName = string.Empty; + string customFileName = ""; if (!Directory.Exists(folder + path)) { Directory.CreateDirectory(folder + path); @@ -468,7 +468,7 @@ public class DownloadService( /// A string that represents the updated path based on the file extension. private string UpdatePathBasedOnExtension(string folder, string path, string extension) { - string subdirectory = string.Empty; + string subdirectory = ""; switch (extension.ToLower()) { @@ -531,7 +531,7 @@ public class DownloadService( return option switch { CustomFileNameOption.ReturnOriginal => filename, - CustomFileNameOption.ReturnEmpty => string.Empty, + CustomFileNameOption.ReturnEmpty => "", _ => filename }; } @@ -1198,7 +1198,7 @@ public class DownloadService( { try { - string customFileName = string.Empty; + string customFileName = ""; string path; Uri uri = new(url); string filename = Path.GetFileName(uri.LocalPath).Split(".")[0]; @@ -1327,7 +1327,7 @@ public class DownloadService( { try { - string customFileName = string.Empty; + string customFileName = ""; string path; Uri uri = new(url); string filename = Path.GetFileName(uri.LocalPath).Split(".")[0]; @@ -1458,7 +1458,7 @@ public class DownloadService( { try { - string customFileName = string.Empty; + string customFileName = ""; string path; Uri uri = new(url); string filename = Path.GetFileName(uri.LocalPath).Split(".")[0]; @@ -1586,7 +1586,7 @@ public class DownloadService( { try { - string customFileName = string.Empty; + string customFileName = ""; string path; Uri uri = new(url); string filename = Path.GetFileName(uri.LocalPath).Split(".")[0]; @@ -1716,7 +1716,7 @@ public class DownloadService( { try { - string customFileName = string.Empty; + string customFileName = ""; string path; Uri uri = new(url); string filename = Path.GetFileName(uri.LocalPath).Split(".")[0]; @@ -1845,7 +1845,7 @@ public class DownloadService( { try { - string customFileName = string.Empty; + string customFileName = ""; string path; Uri uri = new(url); string filename = Path.GetFileName(uri.LocalPath).Split(".")[0]; @@ -1974,7 +1974,7 @@ public class DownloadService( { try { - string customFileName = string.Empty; + string customFileName = ""; string path; Uri uri = new(url); string filename = Path.GetFileName(uri.LocalPath).Split(".")[0]; @@ -2103,7 +2103,7 @@ public class DownloadService( { try { - string customFileName = string.Empty; + string customFileName = ""; string path; Uri uri = new(url); string filename = Path.GetFileName(uri.LocalPath).Split(".")[0]; @@ -2234,7 +2234,7 @@ public class DownloadService( { try { - string customFileName = string.Empty; + string customFileName = ""; Uri uri = new(url); string filename = Path.GetFileName(uri.LocalPath).Split(".")[0]; string path = "/Archived/Posts/Free/Videos"; @@ -2529,7 +2529,7 @@ public class DownloadService( "Posts", progressReporter, configService.CurrentConfig.GetCreatorFileNameFormatConfig(username).PostFileNameFormat ?? - string.Empty, + "", postInfo, mediaInfo, postInfo?.Author, @@ -2554,7 +2554,7 @@ public class DownloadService( "Posts", progressReporter, configService.CurrentConfig.GetCreatorFileNameFormatConfig(username).PostFileNameFormat ?? - string.Empty, + "", postInfo, mediaInfo, postInfo?.Author, @@ -2659,7 +2659,7 @@ public class DownloadService( "Messages", progressReporter, configService.CurrentConfig.GetCreatorFileNameFormatConfig(username).MessageFileNameFormat ?? - string.Empty, + "", messageInfo, mediaInfo, messageInfo?.FromUser, @@ -2683,7 +2683,7 @@ public class DownloadService( "Messages", progressReporter, configService.CurrentConfig.GetCreatorFileNameFormatConfig(username).MessageFileNameFormat ?? - string.Empty, + "", messageInfo, mediaInfo, messageInfo?.FromUser, @@ -2770,7 +2770,7 @@ public class DownloadService( isNew = await DownloadPurchasedMessageDRMVideo(parsed[1], parsed[2], parsed[3], parsed[0], decryptionKey, path, lastModified, kvp.Key, "Messages", progressReporter, configService.CurrentConfig.GetCreatorFileNameFormatConfig(username).MessageFileNameFormat ?? - string.Empty, messageInfo, mediaInfo, messageInfo?.FromUser, users); + "", messageInfo, mediaInfo, messageInfo?.FromUser, users); } else { @@ -2785,7 +2785,7 @@ public class DownloadService( p?.Media?.Any(m => m.Id == kvp.Key) == true); isNew = await DownloadPurchasedMedia(kvp.Value, path, kvp.Key, "Messages", progressReporter, configService.CurrentConfig.GetCreatorFileNameFormatConfig(username).MessageFileNameFormat ?? - string.Empty, messageInfo, mediaInfo, messageInfo?.FromUser, users); + "", messageInfo, mediaInfo, messageInfo?.FromUser, users); } if (isNew) @@ -2862,7 +2862,7 @@ public class DownloadService( isNew = await DownloadStreamsDRMVideo(parsed[1], parsed[2], parsed[3], parsed[0], decryptionKey, path, lastModified, kvp.Key, "Streams", progressReporter, configService.CurrentConfig.GetCreatorFileNameFormatConfig(username).PostFileNameFormat ?? - string.Empty, streamInfo, mediaInfo, streamInfo?.Author, users); + "", streamInfo, mediaInfo, streamInfo?.Author, users); } else { @@ -2876,7 +2876,7 @@ public class DownloadService( streams.StreamObjects.FirstOrDefault(p => p?.Media?.Contains(mediaInfo) == true); isNew = await DownloadStreamMedia(kvp.Value, path, kvp.Key, "Streams", progressReporter, configService.CurrentConfig.GetCreatorFileNameFormatConfig(username).PostFileNameFormat ?? - string.Empty, streamInfo, mediaInfo, streamInfo?.Author, users); + "", streamInfo, mediaInfo, streamInfo?.Author, users); } if (isNew) @@ -2955,7 +2955,7 @@ public class DownloadService( isNew = await DownloadPostDRMVideo(parsed[1], parsed[2], parsed[3], parsed[0], decryptionKey, path, lastModified, postKVP.Key, "Posts", progressReporter, configService.CurrentConfig.GetCreatorFileNameFormatConfig(username).PostFileNameFormat ?? - string.Empty, postInfo, mediaInfo, postInfo?.Author, users); + "", postInfo, mediaInfo, postInfo?.Author, users); } else { @@ -2969,7 +2969,7 @@ public class DownloadService( posts.PostObjects.FirstOrDefault(p => p?.Media?.Contains(mediaInfo) == true); isNew = await DownloadPostMedia(postKVP.Value, path, postKVP.Key, "Posts", progressReporter, configService.CurrentConfig.GetCreatorFileNameFormatConfig(username).PostFileNameFormat ?? - string.Empty, postInfo, mediaInfo, postInfo?.Author, users); + "", postInfo, mediaInfo, postInfo?.Author, users); } if (isNew) @@ -3048,7 +3048,7 @@ public class DownloadService( isNew = await DownloadPurchasedPostDRMVideo(parsed[1], parsed[2], parsed[3], parsed[0], decryptionKey, path, lastModified, postKVP.Key, "Posts", progressReporter, configService.CurrentConfig.GetCreatorFileNameFormatConfig(username).PostFileNameFormat ?? - string.Empty, postInfo, mediaInfo, postInfo?.FromUser, users); + "", postInfo, mediaInfo, postInfo?.FromUser, users); } else { @@ -3063,7 +3063,7 @@ public class DownloadService( purchasedPosts.PaidPostObjects.FirstOrDefault(p => p?.Media?.Any(m => m.Id == postKVP.Key) == true); isNew = await DownloadPurchasedPostMedia(postKVP.Value, path, postKVP.Key, "Posts", progressReporter, configService.CurrentConfig.GetCreatorFileNameFormatConfig(username).PostFileNameFormat ?? - string.Empty, postInfo, mediaInfo, postInfo?.FromUser, users); + "", postInfo, mediaInfo, postInfo?.FromUser, users); } if (isNew) diff --git a/OF DL/Utils/XmlUtils.cs b/OF DL/Utils/XmlUtils.cs index eef2073..08d3864 100644 --- a/OF DL/Utils/XmlUtils.cs +++ b/OF DL/Utils/XmlUtils.cs @@ -11,7 +11,7 @@ internal static class XmlUtils { if (Passthrough) { - return xmlValue ?? string.Empty; + return xmlValue; } try @@ -23,6 +23,6 @@ internal static class XmlUtils { } - return string.Empty; + return ""; } }