Compare commits
2
Commits
2640854f79
...
fdfe85d118
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fdfe85d118 | ||
|
|
de51068d0a |
Vendored
+7
-5
@@ -1,13 +1,15 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"args": [
|
||||
"-pn"
|
||||
], // <--- ADD OR MODIFY THIS LINE
|
||||
"-test 12h45m 724733451895455700"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "C#: Launch Startup Project",
|
||||
"type": "dotnet",
|
||||
"request": "launch"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -194,7 +194,9 @@ namespace URLNotesGrabberCORE
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
string sql = "INSERT INTO DailyAPICount (Date) values(@date)";
|
||||
// Use INSERT OR IGNORE to avoid UNIQUE constraint errors when the date row already exists.
|
||||
// Also explicitly initialize APICount to 0 in case the table has no default.
|
||||
string sql = "INSERT OR IGNORE INTO DailyAPICount (Date, APICount) values(@date, 0)";
|
||||
using (SQLiteCommand command = new SQLiteCommand(sql, connection))
|
||||
{
|
||||
command.Parameters.AddWithValue("@date", DateTime.Today.ToShortDateString());
|
||||
@@ -536,6 +538,9 @@ namespace URLNotesGrabberCORE
|
||||
|
||||
try
|
||||
{
|
||||
// Informative output when marking a post as NotFound
|
||||
Console.WriteLine($"Marking post NotFound: {blogName}/{postID}");
|
||||
|
||||
connection.Open();
|
||||
|
||||
string sql = "UPDATE Posts SET NotFound = 1 WHERE BlogName = @BlogName AND PostID = @PostID";
|
||||
|
||||
@@ -71,6 +71,7 @@ namespace URLNotesGrabberCORE
|
||||
TraverseDirectory(settings.GetValue<string>("PathInput"), settings.GetValue<string>("PathOutputBlogs"), contains, blogNameToParse);
|
||||
|
||||
break;
|
||||
|
||||
case "-test":
|
||||
#region Manual test
|
||||
|
||||
@@ -80,6 +81,14 @@ namespace URLNotesGrabberCORE
|
||||
var response = APIAccess.GrabNotes(blogName, postID).GetAwaiter().GetResult();
|
||||
List<Tuple<string, string>> notes = new List<Tuple<string, string>>();
|
||||
|
||||
// If the API returned a 404 inside the JSON `meta` block, mark the post NotFound
|
||||
if (response?.meta != null && response.meta.status == 404)
|
||||
{
|
||||
Console.WriteLine($"ERROR: Post not found - {blogName}/{postID} (meta.status=404)");
|
||||
DataAccess.UpdatePostMarkNotFound(blogName, postID);
|
||||
break;
|
||||
}
|
||||
|
||||
// Check for API errors
|
||||
if (response.statusCode == "NotFound")
|
||||
{
|
||||
@@ -332,6 +341,15 @@ namespace URLNotesGrabberCORE
|
||||
|
||||
Console.WriteLine(post.Item1 + '\t' + post.Item2 + '\t' + DateTime.Now + "\t" + APICount);
|
||||
var response = APIAccess.GrabNotes(post.Item1, post.Item2, post.Item3.ToString()).GetAwaiter().GetResult();
|
||||
|
||||
// If the API returned a 404 inside the JSON `meta` block, mark the post NotFound and return
|
||||
if (response?.meta != null && response.meta.status == 404)
|
||||
{
|
||||
Console.WriteLine($"API returned 404 Not Found for {post.Item1}/{post.Item2} (meta.status=404)");
|
||||
DataAccess.UpdatePostMarkNotFound(post.Item1, post.Item2);
|
||||
Thread.Sleep(1000);
|
||||
return "NotFound";
|
||||
}
|
||||
List<Tuple<string, string>> notes = new List<Tuple<string, string>>();
|
||||
|
||||
if (response.statusCode == "NotFound")
|
||||
|
||||
Reference in New Issue
Block a user