From dce7e7a6bdfc00f773a2e5e6e5bc945639b55820 Mon Sep 17 00:00:00 2001 From: whimsical-c4lic0 Date: Wed, 18 Feb 2026 02:30:47 -0600 Subject: [PATCH] Detect if a single post is paid or free --- OF DL.Core/Services/DownloadService.cs | 49 ++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/OF DL.Core/Services/DownloadService.cs b/OF DL.Core/Services/DownloadService.cs index 5fedd5a..91e09aa 100644 --- a/OF DL.Core/Services/DownloadService.cs +++ b/OF DL.Core/Services/DownloadService.cs @@ -1,3 +1,4 @@ +using System.Globalization; using System.Security.Cryptography; using System.Text.RegularExpressions; using FFmpeg.NET; @@ -1882,6 +1883,7 @@ public class DownloadService( } int oldCount = 0, newCount = 0; + bool hasPaidPostMedia = false; foreach (KeyValuePair postKvp in post.SinglePosts) { @@ -1889,11 +1891,23 @@ public class DownloadService( PostEntities.SinglePost? postInfo = mediaInfo == null ? null : post.SinglePostObjects.FirstOrDefault(p => p.Media?.Contains(mediaInfo) == true); - string filenameFormat = configService.CurrentConfig.GetCreatorFileNameFormatConfig(username) - .PostFileNameFormat ?? ""; - string postPath = configService.CurrentConfig.FolderPerPost && postInfo != null && postInfo.Id != 0 - ? $"/Posts/Free/{postInfo.Id} {postInfo.PostedAt:yyyy-MM-dd HH-mm-ss}" - : "/Posts/Free"; + + bool isPaidPost = IsPaidSinglePost(postInfo); + if (isPaidPost) + { + hasPaidPostMedia = true; + } + + string filenameFormat = hasPaidPostMedia + ? configService.CurrentConfig.GetCreatorFileNameFormatConfig(username).PaidPostFileNameFormat ?? "" + : configService.CurrentConfig.GetCreatorFileNameFormatConfig(username).PostFileNameFormat ?? ""; + string postPath = hasPaidPostMedia + ? configService.CurrentConfig.FolderPerPaidPost && postInfo != null && postInfo.Id != 0 + ? $"/Posts/Paid/{postInfo.Id} {postInfo.PostedAt:yyyy-MM-dd HH-mm-ss}" + : "/Posts/Paid" + : configService.CurrentConfig.FolderPerPost && postInfo != null && postInfo.Id != 0 + ? $"/Posts/Free/{postInfo.Id} {postInfo.PostedAt:yyyy-MM-dd HH-mm-ss}" + : "/Posts/Free"; bool isNew; if (postKvp.Value.Contains("cdn3.onlyfans.com/dash/files")) @@ -1942,11 +1956,34 @@ public class DownloadService( TotalCount = post.SinglePosts.Count, NewDownloads = newCount, ExistingDownloads = oldCount, - MediaType = "Posts", + MediaType = hasPaidPostMedia ? "Paid Posts" : "Posts", Success = true }; } + private static bool IsPaidSinglePost(PostEntities.SinglePost? postInfo) + { + if (postInfo == null || !postInfo.IsOpened) + { + return false; + } + + if (string.IsNullOrWhiteSpace(postInfo.Price)) + { + return false; + } + + string normalizedPrice = postInfo.Price.Trim(); + if (decimal.TryParse(normalizedPrice, NumberStyles.Any, CultureInfo.InvariantCulture, out decimal amount)) + { + return amount > 0; + } + + return !string.Equals(normalizedPrice, "0", StringComparison.OrdinalIgnoreCase) && + !string.Equals(normalizedPrice, "0.0", StringComparison.OrdinalIgnoreCase) && + !string.Equals(normalizedPrice, "0.00", StringComparison.OrdinalIgnoreCase); + } + /// /// Downloads a single paid message collection (including previews). ///