forked from sim0n00ps/OF-DL
Merge branch 'master' into replace-puppeteer-with-playwright
This commit is contained in:
commit
15a5a1d5f1
@ -433,7 +433,7 @@ public class DownloadOrchestrationService(
|
|||||||
: purchasedTabCollection.PaidPosts.PaidPosts.Count;
|
: purchasedTabCollection.PaidPosts.PaidPosts.Count;
|
||||||
|
|
||||||
DownloadResult postResult = await eventHandler.WithProgressAsync(
|
DownloadResult postResult = await eventHandler.WithProgressAsync(
|
||||||
$"Downloading {purchasedTabCollection.PaidPosts.PaidPosts.Count} Paid Posts",
|
$"Downloading {purchasedTabCollection.PaidPosts.PaidPosts.Count} Media from {purchasedTabCollection.PaidPosts.PaidPostObjects.Count} Paid Posts",
|
||||||
totalSize, config.ShowScrapeSize,
|
totalSize, config.ShowScrapeSize,
|
||||||
async reporter => await downloadService.DownloadPaidPostsPurchasedTab(
|
async reporter => await downloadService.DownloadPaidPostsPurchasedTab(
|
||||||
purchasedTabCollection.Username, path, users,
|
purchasedTabCollection.Username, path, users,
|
||||||
@ -461,7 +461,7 @@ public class DownloadOrchestrationService(
|
|||||||
: purchasedTabCollection.PaidMessages.PaidMessages.Count;
|
: purchasedTabCollection.PaidMessages.PaidMessages.Count;
|
||||||
|
|
||||||
DownloadResult msgResult = await eventHandler.WithProgressAsync(
|
DownloadResult msgResult = await eventHandler.WithProgressAsync(
|
||||||
$"Downloading {purchasedTabCollection.PaidMessages.PaidMessages.Count} Paid Messages",
|
$"Downloading {purchasedTabCollection.PaidMessages.PaidMessages.Count} Media from {purchasedTabCollection.PaidMessages.PaidMessageObjects.Count} Paid Messages",
|
||||||
totalSize, config.ShowScrapeSize,
|
totalSize, config.ShowScrapeSize,
|
||||||
async reporter => await downloadService.DownloadPaidMessagesPurchasedTab(
|
async reporter => await downloadService.DownloadPaidMessagesPurchasedTab(
|
||||||
purchasedTabCollection.Username, path, users,
|
purchasedTabCollection.Username, path, users,
|
||||||
@ -502,48 +502,77 @@ public class DownloadOrchestrationService(
|
|||||||
PurchasedEntities.SinglePaidMessageCollection singlePaidMessageCollection =
|
PurchasedEntities.SinglePaidMessageCollection singlePaidMessageCollection =
|
||||||
await apiService.GetPaidMessage($"/messages/{messageId}", path);
|
await apiService.GetPaidMessage($"/messages/{messageId}", path);
|
||||||
|
|
||||||
if (singlePaidMessageCollection.SingleMessages.Count == 0)
|
if (singlePaidMessageCollection.SingleMessages.Count == 0 &&
|
||||||
|
singlePaidMessageCollection.PreviewSingleMessages.Count == 0)
|
||||||
{
|
{
|
||||||
eventHandler.OnNoContentFound("Paid Messages");
|
eventHandler.OnNoContentFound("Paid Messages");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Config config = configService.CurrentConfig;
|
Config config = configService.CurrentConfig;
|
||||||
|
int messageCount = singlePaidMessageCollection.SingleMessageObjects.Count;
|
||||||
|
string messageLabel = messageCount == 1 ? "Paid Message" : "Paid Messages";
|
||||||
|
int previewCount = singlePaidMessageCollection.PreviewSingleMessages.Count;
|
||||||
|
int paidCount = singlePaidMessageCollection.SingleMessages.Count;
|
||||||
|
int totalCount = previewCount + paidCount;
|
||||||
|
|
||||||
// Handle preview messages
|
// Handle mixed paid + preview message media.
|
||||||
if (singlePaidMessageCollection.PreviewSingleMessages.Count > 0)
|
if (previewCount > 0 && paidCount > 0)
|
||||||
|
{
|
||||||
|
eventHandler.OnContentFound("Paid Messages",
|
||||||
|
totalCount,
|
||||||
|
singlePaidMessageCollection.SingleMessageObjects.Count);
|
||||||
|
|
||||||
|
List<string> allMessageUrls = [];
|
||||||
|
allMessageUrls.AddRange(singlePaidMessageCollection.PreviewSingleMessages.Values);
|
||||||
|
allMessageUrls.AddRange(singlePaidMessageCollection.SingleMessages.Values);
|
||||||
|
|
||||||
|
long totalSize = config.ShowScrapeSize
|
||||||
|
? await downloadService.CalculateTotalFileSize(allMessageUrls)
|
||||||
|
: totalCount;
|
||||||
|
|
||||||
|
DownloadResult result = await eventHandler.WithProgressAsync(
|
||||||
|
$"Downloading {totalCount} Media from {messageCount} {messageLabel} ({paidCount} Paid + {previewCount} Preview)",
|
||||||
|
totalSize, config.ShowScrapeSize,
|
||||||
|
async reporter => await downloadService.DownloadSinglePaidMessage(username, path, users,
|
||||||
|
clientIdBlobMissing, devicePrivateKeyMissing, singlePaidMessageCollection, reporter));
|
||||||
|
|
||||||
|
eventHandler.OnDownloadComplete("Paid Messages", result);
|
||||||
|
}
|
||||||
|
// Handle preview-only message media.
|
||||||
|
else if (previewCount > 0)
|
||||||
{
|
{
|
||||||
eventHandler.OnContentFound("Preview Paid Messages",
|
eventHandler.OnContentFound("Preview Paid Messages",
|
||||||
singlePaidMessageCollection.PreviewSingleMessages.Count,
|
previewCount,
|
||||||
singlePaidMessageCollection.SingleMessageObjects.Count);
|
singlePaidMessageCollection.SingleMessageObjects.Count);
|
||||||
|
|
||||||
long previewSize = config.ShowScrapeSize
|
long previewSize = config.ShowScrapeSize
|
||||||
? await downloadService.CalculateTotalFileSize(
|
? await downloadService.CalculateTotalFileSize(
|
||||||
singlePaidMessageCollection.PreviewSingleMessages.Values.ToList())
|
singlePaidMessageCollection.PreviewSingleMessages.Values.ToList())
|
||||||
: singlePaidMessageCollection.PreviewSingleMessages.Count;
|
: previewCount;
|
||||||
|
|
||||||
DownloadResult previewResult = await eventHandler.WithProgressAsync(
|
DownloadResult previewResult = await eventHandler.WithProgressAsync(
|
||||||
$"Downloading {singlePaidMessageCollection.PreviewSingleMessages.Count} Preview Paid Messages",
|
$"Downloading {previewCount} Preview Media from {messageCount} {messageLabel}",
|
||||||
previewSize, config.ShowScrapeSize,
|
previewSize, config.ShowScrapeSize,
|
||||||
async reporter => await downloadService.DownloadSinglePaidMessage(username, path, users,
|
async reporter => await downloadService.DownloadSinglePaidMessage(username, path, users,
|
||||||
clientIdBlobMissing, devicePrivateKeyMissing, singlePaidMessageCollection, reporter));
|
clientIdBlobMissing, devicePrivateKeyMissing, singlePaidMessageCollection, reporter));
|
||||||
|
|
||||||
eventHandler.OnDownloadComplete("Paid Messages", previewResult);
|
eventHandler.OnDownloadComplete("Paid Messages", previewResult);
|
||||||
}
|
}
|
||||||
else if (singlePaidMessageCollection.SingleMessages.Count > 0)
|
else if (paidCount > 0)
|
||||||
{
|
{
|
||||||
// Only actual paid messages, no preview
|
// Only actual paid messages, no preview
|
||||||
eventHandler.OnContentFound("Paid Messages",
|
eventHandler.OnContentFound("Paid Messages",
|
||||||
singlePaidMessageCollection.SingleMessages.Count,
|
paidCount,
|
||||||
singlePaidMessageCollection.SingleMessageObjects.Count);
|
singlePaidMessageCollection.SingleMessageObjects.Count);
|
||||||
|
|
||||||
long totalSize = config.ShowScrapeSize
|
long totalSize = config.ShowScrapeSize
|
||||||
? await downloadService.CalculateTotalFileSize(
|
? await downloadService.CalculateTotalFileSize(
|
||||||
singlePaidMessageCollection.SingleMessages.Values.ToList())
|
singlePaidMessageCollection.SingleMessages.Values.ToList())
|
||||||
: singlePaidMessageCollection.SingleMessages.Count;
|
: paidCount;
|
||||||
|
|
||||||
DownloadResult result = await eventHandler.WithProgressAsync(
|
DownloadResult result = await eventHandler.WithProgressAsync(
|
||||||
$"Downloading {singlePaidMessageCollection.SingleMessages.Count} Paid Messages",
|
$"Downloading {paidCount} Paid Media from {messageCount} {messageLabel}",
|
||||||
totalSize, config.ShowScrapeSize,
|
totalSize, config.ShowScrapeSize,
|
||||||
async reporter => await downloadService.DownloadSinglePaidMessage(username, path, users,
|
async reporter => await downloadService.DownloadSinglePaidMessage(username, path, users,
|
||||||
clientIdBlobMissing, devicePrivateKeyMissing, singlePaidMessageCollection, reporter));
|
clientIdBlobMissing, devicePrivateKeyMissing, singlePaidMessageCollection, reporter));
|
||||||
@ -607,7 +636,7 @@ public class DownloadOrchestrationService(
|
|||||||
: mediaCount;
|
: mediaCount;
|
||||||
|
|
||||||
DownloadResult result = await eventHandler.WithProgressAsync(
|
DownloadResult result = await eventHandler.WithProgressAsync(
|
||||||
$"Downloading {mediaCount} {contentType}", totalSize, config.ShowScrapeSize,
|
$"Downloading {mediaCount} Media from {objectCount} {contentType}", totalSize, config.ShowScrapeSize,
|
||||||
async reporter => await downloadData(data, reporter));
|
async reporter => await downloadData(data, reporter));
|
||||||
|
|
||||||
eventHandler.OnDownloadComplete(contentType, result);
|
eventHandler.OnDownloadComplete(contentType, result);
|
||||||
|
|||||||
@ -146,10 +146,10 @@ public class DownloadService(
|
|||||||
|
|
||||||
if (logLevelArgs.Contains("-report", StringComparison.OrdinalIgnoreCase))
|
if (logLevelArgs.Contains("-report", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
// Direct ffmpeg report files into the same logs directory Serilog uses (relative to current working directory)
|
// Use a relative path so FFREPORT parsing works on Windows (drive-letter ':' breaks option parsing).
|
||||||
string logDir = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, "logs"));
|
string logDir = Path.Combine(Environment.CurrentDirectory, "logs");
|
||||||
Directory.CreateDirectory(logDir);
|
Directory.CreateDirectory(logDir);
|
||||||
string ffReportPath = Path.Combine(logDir, "ffmpeg-%p-%t.log"); // ffmpeg will replace %p/%t
|
string ffReportPath = Path.Combine("logs", "ffmpeg-%p-%t.log").Replace("\\", "/");
|
||||||
Environment.SetEnvironmentVariable("FFREPORT", $"file={ffReportPath}:level=32");
|
Environment.SetEnvironmentVariable("FFREPORT", $"file={ffReportPath}:level=32");
|
||||||
Log.Debug("FFREPORT enabled at: {FFREPORT} (cwd: {Cwd})",
|
Log.Debug("FFREPORT enabled at: {FFREPORT} (cwd: {Cwd})",
|
||||||
Environment.GetEnvironmentVariable("FFREPORT"), Environment.CurrentDirectory);
|
Environment.GetEnvironmentVariable("FFREPORT"), Environment.CurrentDirectory);
|
||||||
|
|||||||
@ -196,7 +196,7 @@ public class DownloadOrchestrationServiceTests
|
|||||||
await service.DownloadSinglePaidMessageAsync("creator", 5, "/tmp", new Dictionary<string, long>(),
|
await service.DownloadSinglePaidMessageAsync("creator", 5, "/tmp", new Dictionary<string, long>(),
|
||||||
true, true, eventHandler);
|
true, true, eventHandler);
|
||||||
|
|
||||||
Assert.Contains(eventHandler.ContentFound, entry => entry.contentType == "Preview Paid Messages");
|
Assert.Contains(eventHandler.ContentFound, entry => entry.contentType == "Paid Messages");
|
||||||
Assert.True(downloadService.SinglePaidMessageCalled);
|
Assert.True(downloadService.SinglePaidMessageCalled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user