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