Compare commits
4 Commits
77bd5f7ed9
...
40a7687606
| Author | SHA1 | Date | |
|---|---|---|---|
| 40a7687606 | |||
| ccb990675a | |||
| e22d2b63a2 | |||
| dce7e7a6bd |
@ -2082,6 +2082,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)
|
||||||
{
|
{
|
||||||
@ -2089,9 +2090,21 @@ 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)
|
||||||
|
{
|
||||||
|
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/{postInfo.Id} {postInfo.PostedAt:yyyy-MM-dd HH-mm-ss}"
|
||||||
: "/Posts/Free";
|
: "/Posts/Free";
|
||||||
|
|
||||||
@ -2142,11 +2155,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