diff --git a/URLNotesGrabberCORE/IngestMode.cs b/URLNotesGrabberCORE/IngestMode.cs index ae999d2..da5ab31 100644 --- a/URLNotesGrabberCORE/IngestMode.cs +++ b/URLNotesGrabberCORE/IngestMode.cs @@ -10,13 +10,16 @@ namespace URLNotesGrabberCORE { public static int Run(IConfiguration config, string[] args) { - string? rootPath = args.Length > 0 ? args[0] : config["appSettings:PathTTRoot"]; + string? targetBlog = args.Length > 0 ? args[0]?.Trim() : null; + if (string.IsNullOrWhiteSpace(targetBlog)) targetBlog = null; + + string? rootPath = config["appSettings:PathTTRoot"]; if (string.IsNullOrWhiteSpace(rootPath)) rootPath = config["appSettings:PathInput"]; if (string.IsNullOrWhiteSpace(rootPath)) { - Console.WriteLine("Ingest: no root path provided. Set appSettings:PathTTRoot, appSettings:PathInput, or pass a path after -ingest."); + Console.WriteLine("Ingest: no root path configured. Set appSettings:PathTTRoot or appSettings:PathInput."); return 1; } @@ -43,6 +46,7 @@ namespace URLNotesGrabberCORE Console.WriteLine($"========== Ingest Settings =========="); Console.WriteLine($"Root path: {rootPath}"); + Console.WriteLine($"Blog filter: {(targetBlog == null ? "(all blogs)" : targetBlog)}"); Console.WriteLine($"====================================="); var txtFiles = new List(); @@ -66,6 +70,7 @@ namespace URLNotesGrabberCORE Console.WriteLine($"Processing {txtFiles.Count} .txt file(s)..."); int filesProcessed = 0; + int filesSkipped = 0; int postsTouched = 0; try @@ -77,14 +82,20 @@ namespace URLNotesGrabberCORE { try { - filesProcessed++; - if (filesProcessed % 50 == 0 || filesProcessed == 1) - Console.WriteLine($"[{filesProcessed}/{txtFiles.Count}] {Path.GetFileName(file)}"); - string rawBlogName = Path.GetFileName(Path.GetDirectoryName(file) ?? "unknown"); string blogName = Regex.Replace(rawBlogName, @"_\d+$", ""); string postType = Path.GetFileNameWithoutExtension(file); + if (targetBlog != null && !string.Equals(blogName, targetBlog, StringComparison.OrdinalIgnoreCase)) + { + filesSkipped++; + continue; + } + + filesProcessed++; + if (filesProcessed % 50 == 0 || filesProcessed == 1) + Console.WriteLine($"[{filesProcessed}/{txtFiles.Count}] {Path.GetFileName(file)}"); + string currentPostId = ""; var currentPostData = new Dictionary(StringComparer.OrdinalIgnoreCase); @@ -158,7 +169,7 @@ namespace URLNotesGrabberCORE DataAccess.RestoreImportModePragmas(); } - Console.WriteLine($"\nIngest complete. Files processed: {filesProcessed}. Posts touched: {postsTouched}."); + Console.WriteLine($"\nIngest complete. Files processed: {filesProcessed}. Files skipped (blog filter): {filesSkipped}. Posts touched: {postsTouched}."); return 0; } diff --git a/URLNotesGrabberCORE/Program.cs b/URLNotesGrabberCORE/Program.cs index 3211640..af4dc38 100644 --- a/URLNotesGrabberCORE/Program.cs +++ b/URLNotesGrabberCORE/Program.cs @@ -181,7 +181,7 @@ namespace URLNotesGrabberCORE Console.WriteLine("-api [section]\t Use a specific API settings section from appsettings.json (e.g. TumblrApi3)"); - Console.WriteLine("-ingest [path]\t Ingest Tumblr .txt exports under path (or appSettings:PathTTRoot) into TL.db"); + Console.WriteLine("-ingest [blogname]\t Ingest Tumblr .txt exports from appSettings:PathTTRoot into TL.db (all blogs, or single blog if name given)"); Console.WriteLine("-output\t Export posts from TL.db back to .txt files in each blog's TTFolderPath");