feat: add single-blog filter to -ingest
`-ingest <blogname>` now restricts the run to one blog's folder, mirroring
the existing -parse <blogname> ergonomics. `-ingest` with no arg still
processes every blog under appSettings:PathTTRoot (or PathInput fallback).
Breaking vs 3aff849: the first positional arg is interpreted as a blog
name, not a path. Configure the root via appSettings:PathTTRoot.
Co-Authored-By: Claude Opus 4.7 <[email protected]>
This commit is contained in:
@@ -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<string>();
|
||||
@@ -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<string, string>(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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user