forked from sim0n00ps/OF-DL
Detect if a single post is paid or free
This commit is contained in:
parent
aee920a9f1
commit
dce7e7a6bd
@ -1,3 +1,4 @@
|
|||||||
|
using System.Globalization;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using FFmpeg.NET;
|
using FFmpeg.NET;
|
||||||
@ -1882,6 +1883,7 @@ public class DownloadService(
|
|||||||
}
|
}
|
||||||
|
|
||||||
int oldCount = 0, newCount = 0;
|
int oldCount = 0, newCount = 0;
|
||||||
|
bool hasPaidPostMedia = false;
|
||||||
|
|
||||||
foreach (KeyValuePair<long, string> postKvp in post.SinglePosts)
|
foreach (KeyValuePair<long, string> postKvp in post.SinglePosts)
|
||||||
{
|
{
|
||||||
@ -1889,11 +1891,23 @@ public class DownloadService(
|
|||||||
PostEntities.SinglePost? postInfo = mediaInfo == null
|
PostEntities.SinglePost? postInfo = mediaInfo == null
|
||||||
? null
|
? null
|
||||||
: post.SinglePostObjects.FirstOrDefault(p => p.Media?.Contains(mediaInfo) == true);
|
: post.SinglePostObjects.FirstOrDefault(p => p.Media?.Contains(mediaInfo) == true);
|
||||||
string filenameFormat = configService.CurrentConfig.GetCreatorFileNameFormatConfig(username)
|
|
||||||
.PostFileNameFormat ?? "";
|
bool isPaidPost = IsPaidSinglePost(postInfo);
|
||||||
string postPath = configService.CurrentConfig.FolderPerPost && postInfo != null && postInfo.Id != 0
|
if (isPaidPost)
|
||||||
? $"/Posts/Free/{postInfo.Id} {postInfo.PostedAt:yyyy-MM-dd HH-mm-ss}"
|
{
|
||||||
: "/Posts/Free";
|
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;
|
bool isNew;
|
||||||
if (postKvp.Value.Contains("cdn3.onlyfans.com/dash/files"))
|
if (postKvp.Value.Contains("cdn3.onlyfans.com/dash/files"))
|
||||||
@ -1942,11 +1956,34 @@ public class DownloadService(
|
|||||||
TotalCount = post.SinglePosts.Count,
|
TotalCount = post.SinglePosts.Count,
|
||||||
NewDownloads = newCount,
|
NewDownloads = newCount,
|
||||||
ExistingDownloads = oldCount,
|
ExistingDownloads = oldCount,
|
||||||
MediaType = "Posts",
|
MediaType = hasPaidPostMedia ? "Paid Posts" : "Posts",
|
||||||
Success = true
|
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>
|
/// <summary>
|
||||||
/// Downloads a single paid message collection (including previews).
|
/// Downloads a single paid message collection (including previews).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user