Detect if a single post is paid or free #144

Merged
sim0n00ps merged 3 commits from whimsical-c4lic0/OF-DL:detect-free-and-paid-single-posts into master 2026-02-19 18:23:25 +00:00

View File

@ -2082,6 +2082,7 @@ public class DownloadService(
}
int oldCount = 0, newCount = 0;
bool hasPaidPostMedia = false;
foreach (KeyValuePair<long, string> postKvp in post.SinglePosts)
{
@ -2089,11 +2090,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"))
@ -2142,11 +2155,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);
}
/// <summary>
/// Downloads a single paid message collection (including previews).
/// </summary>