forked from sim0n00ps/OF-DL
Compare commits
4 Commits
333e91d01c
...
a91fb06885
| Author | SHA1 | Date | |
|---|---|---|---|
| a91fb06885 | |||
| 27e19a8749 | |||
| 95438ad538 | |||
| 5f1870f32f |
@ -83,6 +83,7 @@ public class Program
|
||||
AnsiConsole.MarkupLine($"[red]Press any key to exit.[/]");
|
||||
Log.Error(e, "auth invalid after attempt to get auth from browser");
|
||||
|
||||
Log.CloseAndFlush();
|
||||
Environment.Exit(2);
|
||||
}
|
||||
|
||||
@ -95,6 +96,7 @@ public class Program
|
||||
AnsiConsole.MarkupLine($"[red]Press any key to exit.[/]");
|
||||
Log.Error("auth invalid after attempt to get auth from browser");
|
||||
|
||||
Log.CloseAndFlush();
|
||||
Environment.Exit(2);
|
||||
}
|
||||
else
|
||||
@ -117,7 +119,7 @@ public class Program
|
||||
.Enrich.WithProperty("StartTime", $"{DateTime.Now:yyyy-MM-dd HH:mm:ss} ")
|
||||
.Enrich.WithProperty("MachineName", Environment.MachineName)
|
||||
.MinimumLevel.ControlledBy(levelSwitch)
|
||||
.WriteTo.File("logs/OFDL.txt", rollingInterval: RollingInterval.Day)
|
||||
.WriteTo.File("logs/OFDL.txt", rollingInterval: RollingInterval.Day, restrictedToMinimumLevel: LogEventLevel.Error)
|
||||
.WriteTo.Seq("https://seq.cajetan.dk")
|
||||
.CreateLogger();
|
||||
|
||||
@ -244,6 +246,8 @@ public class Program
|
||||
{
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
||||
Log.CloseAndFlush();
|
||||
Environment.Exit(3);
|
||||
}
|
||||
}
|
||||
@ -373,6 +377,8 @@ public class Program
|
||||
{
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
||||
Log.CloseAndFlush();
|
||||
Environment.Exit(3);
|
||||
}
|
||||
}
|
||||
@ -482,6 +488,8 @@ public class Program
|
||||
{
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
||||
Log.CloseAndFlush();
|
||||
Environment.Exit(3);
|
||||
}
|
||||
|
||||
@ -498,6 +506,8 @@ public class Program
|
||||
|
||||
config.NonInteractiveMode = true;
|
||||
|
||||
Log.Logger = Log.Logger.ForContext("Mode", "NonInteractiveMode");
|
||||
|
||||
int indexOfSpecificListsArg = Array.FindIndex(args, a => a.Contains(SPECIFIC_LISTS_ARG, StringComparison.OrdinalIgnoreCase));
|
||||
int indexOfSpecificUsersArg = Array.FindIndex(args, a => a.Contains(SPECIFIC_USERS_ARG, StringComparison.OrdinalIgnoreCase));
|
||||
char[] separator = [','];
|
||||
@ -511,6 +521,8 @@ public class Program
|
||||
{
|
||||
config.NonInteractiveSpecificLists = strListValues;
|
||||
config.NonInteractiveModeListName = string.Empty;
|
||||
|
||||
Log.Logger = Log.Logger.ForContext("NonInteractiveSpecificLists", string.Join(",", strListValues));
|
||||
}
|
||||
}
|
||||
|
||||
@ -521,6 +533,8 @@ public class Program
|
||||
if (strUserValues.Length > 0)
|
||||
{
|
||||
config.NonInteractiveSpecificUsers = strUserValues;
|
||||
|
||||
Log.Logger = Log.Logger.ForContext("NonInteractiveSpecificUsers", string.Join(",", strUserValues));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -531,6 +545,8 @@ public class Program
|
||||
{
|
||||
config.NonInteractiveMode = true;
|
||||
config.OutputBlockedUsers = true;
|
||||
|
||||
Log.Logger = Log.Logger.ForContext("Mode", "OutputBlockedUsers");
|
||||
}
|
||||
|
||||
const string UPDATE_ALL_USER_INFO_ARG = "--update-userinfo";
|
||||
@ -539,6 +555,8 @@ public class Program
|
||||
{
|
||||
config.NonInteractiveMode = true;
|
||||
config.UpdateAllUserInfo = true;
|
||||
|
||||
Log.Logger = Log.Logger.ForContext("Mode", "UpdateAllUserInfo");
|
||||
}
|
||||
|
||||
Log.Debug("Additional arguments:");
|
||||
@ -566,6 +584,8 @@ public class Program
|
||||
{
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
||||
Log.CloseAndFlush();
|
||||
Environment.Exit(1);
|
||||
}
|
||||
else
|
||||
@ -649,6 +669,7 @@ public class Program
|
||||
AnsiConsole.MarkupLine($"[red]Press any key to exit.[/]");
|
||||
|
||||
Console.ReadKey();
|
||||
Log.CloseAndFlush();
|
||||
Environment.Exit(2);
|
||||
}
|
||||
|
||||
@ -665,6 +686,7 @@ public class Program
|
||||
AnsiConsole.MarkupLine($"[red]Press any key to exit.[/]");
|
||||
|
||||
Console.ReadKey();
|
||||
Log.CloseAndFlush();
|
||||
Environment.Exit(2);
|
||||
}
|
||||
}
|
||||
@ -679,6 +701,7 @@ public class Program
|
||||
AnsiConsole.MarkupLine($"[red]Press any key to exit.[/]");
|
||||
|
||||
Console.ReadKey();
|
||||
Log.CloseAndFlush();
|
||||
Environment.Exit(2);
|
||||
}
|
||||
|
||||
@ -694,6 +717,7 @@ public class Program
|
||||
AnsiConsole.MarkupLine($"[red]Press any key to exit.[/]");
|
||||
|
||||
Console.ReadKey();
|
||||
Log.CloseAndFlush();
|
||||
Environment.Exit(2);
|
||||
}
|
||||
}
|
||||
@ -723,6 +747,8 @@ public class Program
|
||||
{
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
||||
Log.CloseAndFlush();
|
||||
Environment.Exit(2);
|
||||
}
|
||||
}
|
||||
@ -811,6 +837,8 @@ public class Program
|
||||
{
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
||||
Log.CloseAndFlush();
|
||||
Environment.Exit(4);
|
||||
}
|
||||
|
||||
@ -867,7 +895,10 @@ public class Program
|
||||
{
|
||||
AnsiConsole.MarkupLine($"\n[red]Auth failed. Please try again or use other authentication methods detailed here:[/]\n");
|
||||
AnsiConsole.MarkupLine($"[link]https://docs.ofdl.tools/config/auth[/]\n");
|
||||
|
||||
Console.ReadKey();
|
||||
|
||||
Log.CloseAndFlush();
|
||||
Environment.Exit(2);
|
||||
}
|
||||
}
|
||||
@ -910,6 +941,7 @@ public class Program
|
||||
{
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
||||
Log.CloseAndFlush();
|
||||
Environment.Exit(5);
|
||||
}
|
||||
@ -986,10 +1018,12 @@ public class Program
|
||||
|
||||
using (LogContext.PushProperty("Username", username))
|
||||
using (LogContext.PushProperty("UserId", userId))
|
||||
using (LogContext.PushProperty("UserNum", prevValue+1))
|
||||
using (LogContext.PushProperty("UserTotal", users.Count))
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.Information("Updating User Info for for: {Username:l}");
|
||||
Log.Information("[{UserNum:0} of {UserTotal}] Updating User Info for for: {Username:l}");
|
||||
User? user_info = await m_ApiHelper.GetUserInfo(username, $"/users/{username}");
|
||||
await dbHelper.UpdateUserInfo(username, user_info);
|
||||
|
||||
@ -997,7 +1031,7 @@ public class Program
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Warning(ex, "Failed to update User Info for: {Username:l}");
|
||||
Log.Warning(ex, "[{UserNum:0} of {UserTotal}] Failed to update User Info for: {Username:l}");
|
||||
AnsiConsole.Markup($"[red]Failed to update User Info for '{username}'\n[/]");
|
||||
|
||||
updateTask.Description = $"{description} - FAILED: {ex.Message}";
|
||||
@ -1355,6 +1389,15 @@ public class Program
|
||||
}
|
||||
else if (hasSelectedUsersKVP.Key && !hasSelectedUsersKVP.Value.ContainsKey("ConfigChanged"))
|
||||
{
|
||||
int totalNewPaidPostCount = 0;
|
||||
int totalNewPostCount = 0;
|
||||
int totalNewArchivedCount = 0;
|
||||
int totalNewStreamsCount = 0;
|
||||
int totalNewStoriesCount = 0;
|
||||
int totalNewHighlightsCount = 0;
|
||||
int totalNewMessagesCount = 0;
|
||||
int totalNewPaidMessagesCount = 0;
|
||||
|
||||
//Iterate over each user in the list of users
|
||||
int userNum = 0;
|
||||
int userCount = hasSelectedUsersKVP.Value.Count;
|
||||
@ -1425,41 +1468,49 @@ public class Program
|
||||
if (Config.DownloadPaidPosts)
|
||||
{
|
||||
(paidPostCount, newPaidPostCount) = await DownloadPaidPosts(downloadContext, hasSelectedUsersKVP, user, paidPostCount, path);
|
||||
totalNewPaidPostCount += newPaidPostCount;
|
||||
}
|
||||
|
||||
if (Config.DownloadPosts)
|
||||
{
|
||||
(postCount, newPostCount) = await DownloadFreePosts(downloadContext, hasSelectedUsersKVP, user, postCount, path);
|
||||
totalNewPostCount += newPostCount;
|
||||
}
|
||||
|
||||
if (Config.DownloadArchived)
|
||||
{
|
||||
(archivedCount, newArchivedCount) = await DownloadArchived(downloadContext, hasSelectedUsersKVP, user, archivedCount, path);
|
||||
totalNewArchivedCount += newArchivedCount;
|
||||
}
|
||||
|
||||
if (Config.DownloadStreams)
|
||||
{
|
||||
(streamsCount, newStreamsCount) = await DownloadStreams(downloadContext, hasSelectedUsersKVP, user, streamsCount, path);
|
||||
totalNewStreamsCount += newStreamsCount;
|
||||
}
|
||||
|
||||
if (Config.DownloadStories)
|
||||
{
|
||||
(storiesCount, newStoriesCount) = await DownloadStories(downloadContext, user, storiesCount, path);
|
||||
totalNewStoriesCount += newStoriesCount;
|
||||
}
|
||||
|
||||
if (Config.DownloadHighlights)
|
||||
{
|
||||
(highlightsCount, newHighlightsCount) = await DownloadHighlights(downloadContext, user, highlightsCount, path);
|
||||
totalNewHighlightsCount += newHighlightsCount;
|
||||
}
|
||||
|
||||
if (Config.DownloadMessages)
|
||||
{
|
||||
(messagesCount, newMessagesCount) = await DownloadMessages(downloadContext, hasSelectedUsersKVP, user, messagesCount, path);
|
||||
totalNewMessagesCount += newMessagesCount;
|
||||
}
|
||||
|
||||
if (Config.DownloadPaidMessages)
|
||||
{
|
||||
(paidMessagesCount, newPaidMessagesCount) = await DownloadPaidMessages(downloadContext, hasSelectedUsersKVP, user, paidMessagesCount, path);
|
||||
totalNewPaidMessagesCount += newPaidMessagesCount;
|
||||
}
|
||||
|
||||
AnsiConsole.Markup("\n");
|
||||
@ -1491,7 +1542,15 @@ public class Program
|
||||
|
||||
DateTime endTime = DateTime.Now;
|
||||
TimeSpan totalTime = endTime - startTime;
|
||||
Log.Information("Scrape Completed in {TotalMinutes:0.00} minutes", totalTime.TotalMinutes);
|
||||
Log.ForContext("Paid Posts", totalNewPaidPostCount)
|
||||
.ForContext("Posts", totalNewPostCount)
|
||||
.ForContext("Archived", totalNewArchivedCount)
|
||||
.ForContext("Streams", totalNewStreamsCount)
|
||||
.ForContext("Stories", totalNewStoriesCount)
|
||||
.ForContext("Highlights", totalNewHighlightsCount)
|
||||
.ForContext("Messages", totalNewMessagesCount)
|
||||
.ForContext("Paid Messages", totalNewPaidMessagesCount)
|
||||
.Information("Scrape Completed in {TotalMinutes:0.00} minutes", totalTime.TotalMinutes);
|
||||
AnsiConsole.Markup($"[green]Scrape Completed in {totalTime.TotalMinutes:0.00} minutes\n[/]");
|
||||
}
|
||||
else if (hasSelectedUsersKVP.Key && hasSelectedUsersKVP.Value != null && hasSelectedUsersKVP.Value.ContainsKey("ConfigChanged"))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user