Compare commits
No commits in common. "main" and "1.1" have entirely different histories.
@ -11,7 +11,6 @@ namespace ttrss_co_client
|
|||||||
public string OnDoneCopy { get; set; }
|
public string OnDoneCopy { get; set; }
|
||||||
public string WorkingDirectory { get; set; } = "./working/";
|
public string WorkingDirectory { get; set; } = "./working/";
|
||||||
public string ChatScript { get; set; }
|
public string ChatScript { get; set; }
|
||||||
public string UserAgent { get; set; }
|
|
||||||
public IEnumerable<FeedAction> feedActions { get; set; }
|
public IEnumerable<FeedAction> feedActions { get; set; }
|
||||||
public class FeedAction
|
public class FeedAction
|
||||||
{
|
{
|
||||||
|
31
Program.cs
31
Program.cs
@ -152,24 +152,18 @@ namespace ttrss_co_client
|
|||||||
{
|
{
|
||||||
var wo = await lingeringTask;
|
var wo = await lingeringTask;
|
||||||
var wop = Path.Combine(conf.WorkingDirectory, wo.Item2.guid.ToString(), "workorder.json");
|
var wop = Path.Combine(conf.WorkingDirectory, wo.Item2.guid.ToString(), "workorder.json");
|
||||||
|
File.WriteAllText(wop, JsonConvert.SerializeObject(wo.Item2));
|
||||||
//if you tell me it's done, or you need to continue now.... I believe you.
|
//if you tell me it's done, or you need to continue now.... I believe you.
|
||||||
switch (wo.Item1)
|
switch (wo.Item1)
|
||||||
{
|
{
|
||||||
case Phase2Task.TaskStatus.Done:
|
case Phase2Task.TaskStatus.Done:
|
||||||
var workingSubDir = Path.Combine(conf.WorkingDirectory, wo.Item2.guid.ToString());
|
File.Delete(wop);
|
||||||
foreach(var file in Directory.GetFiles(workingSubDir, "*.*", SearchOption.AllDirectories))
|
Directory.Delete(Path.Combine(conf.WorkingDirectory, wo.Item2.guid.ToString()));
|
||||||
{
|
|
||||||
File.Delete(file);
|
|
||||||
}
|
|
||||||
//imo this next line should also handle the above, but apparently I'm alone in that.
|
|
||||||
Directory.Delete(workingSubDir, true);
|
|
||||||
break;
|
break;
|
||||||
case Phase2Task.TaskStatus.ContinueNow:
|
case Phase2Task.TaskStatus.ContinueNow:
|
||||||
remainingWork.Add(wo.Item2);
|
remainingWork.Add(wo.Item2);
|
||||||
break;
|
break;
|
||||||
case Phase2Task.TaskStatus.TryLater:
|
case Phase2Task.TaskStatus.TryLater:
|
||||||
|
|
||||||
File.WriteAllText(wop, JsonConvert.SerializeObject(wo.Item2));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -179,25 +173,6 @@ namespace ttrss_co_client
|
|||||||
await ttrssClient.Logout();
|
await ttrssClient.Logout();
|
||||||
Console.WriteLine($"logged out of ttrss.");
|
Console.WriteLine($"logged out of ttrss.");
|
||||||
|
|
||||||
#region cleanup
|
|
||||||
Console.WriteLine("===== phase 3 =====");
|
|
||||||
//loop through working directory looking for other work orders to add
|
|
||||||
var subdirs = Directory.GetDirectories(conf.WorkingDirectory);
|
|
||||||
foreach(var subdir in subdirs)
|
|
||||||
{
|
|
||||||
if(Directory.GetFiles(subdir)?.Length == 0)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"{subdir} is empty");
|
|
||||||
Directory.Delete(subdir);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine($"{subdir} is not empty: {string.Join(", ", Directory.GetFiles(subdir))}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
Console.WriteLine($"done for real");
|
Console.WriteLine($"done for real");
|
||||||
}
|
}
|
||||||
static Configuration Configure(string configurationPath = "appsettings.json")
|
static Configuration Configure(string configurationPath = "appsettings.json")
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
"onDoneCopy":"./",
|
"onDoneCopy":"./",
|
||||||
"workingDirectory":"working/",
|
"workingDirectory":"working/",
|
||||||
"chatScript": "miscChat.sh",
|
"chatScript": "miscChat.sh",
|
||||||
"userAgent": "Mozilla/5.0 (compatible; wget-is-not-a-crime/1.0)",
|
|
||||||
"feedActions":
|
"feedActions":
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
@ -15,11 +15,8 @@ public class ChatMessage : Phase2Task
|
|||||||
public override async Task<Tuple<TaskStatus, WorkOrder>> ActOn(WorkOrder workOrder)
|
public override async Task<Tuple<TaskStatus, WorkOrder>> ActOn(WorkOrder workOrder)
|
||||||
{
|
{
|
||||||
await Process.Start(ChatScript,
|
await Process.Start(ChatScript,
|
||||||
workOrder.data["chatmessage"] +
|
workOrder.data["chatmessage"] + (await TtrssClient.GetArticles(workOrder.articleId)).First().feed_title
|
||||||
(await TtrssClient.GetArticles(workOrder.articleId)).First().feed_title +
|
).WaitForExitAsync();
|
||||||
": " +
|
|
||||||
(await TtrssClient.GetArticles(workOrder.articleId)).First().title
|
|
||||||
).WaitForExitAsync();
|
|
||||||
return new Tuple<TaskStatus, WorkOrder>(TaskStatus.Done, workOrder);
|
return new Tuple<TaskStatus, WorkOrder>(TaskStatus.Done, workOrder);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,16 +25,10 @@ namespace ttrss_co_client.tasks
|
|||||||
var extensionUpstream = attachmentLink.Substring(attachmentLink.LastIndexOf('.'));
|
var extensionUpstream = attachmentLink.Substring(attachmentLink.LastIndexOf('.'));
|
||||||
var downloadPath = Path.Combine(workingFolder, headline.title) + extensionUpstream;
|
var downloadPath = Path.Combine(workingFolder, headline.title) + extensionUpstream;
|
||||||
var downloader = new HttpClient();
|
var downloader = new HttpClient();
|
||||||
downloader.DefaultRequestHeaders.UserAgent.ParseAdd(Conf.UserAgent);
|
|
||||||
sw.Start();
|
sw.Start();
|
||||||
var dlResult = (await downloader.GetAsync(attachmentLink));
|
File.WriteAllBytes(downloadPath, await (await downloader.GetAsync(attachmentLink)).Content.ReadAsByteArrayAsync());
|
||||||
File.WriteAllBytes(downloadPath, await dlResult.Content.ReadAsByteArrayAsync());
|
|
||||||
sw.Stop();
|
sw.Stop();
|
||||||
var outputStr = $"{(dlResult.IsSuccessStatusCode ? "Success" : "fail")} in {sw.Elapsed}";
|
var outputStr = $"{(File.Exists(downloadPath) ? "Success" : "fail")} in {sw.Elapsed}";
|
||||||
if(!dlResult.IsSuccessStatusCode)
|
|
||||||
{
|
|
||||||
outputStr += $"\n\t{dlResult.StatusCode} - {dlResult.ReasonPhrase}";
|
|
||||||
}
|
|
||||||
|
|
||||||
Console.WriteLine($" {attachmentLink}\n{outputStr}");
|
Console.WriteLine($" {attachmentLink}\n{outputStr}");
|
||||||
await TtrssClient.SetArticleLabel(labelsWRTArticle.First(l => l.caption?.ToLower() == this.TriggerLabel.ToLower()).id, false, headline.id);
|
await TtrssClient.SetArticleLabel(labelsWRTArticle.First(l => l.caption?.ToLower() == this.TriggerLabel.ToLower()).id, false, headline.id);
|
||||||
@ -51,7 +45,7 @@ namespace ttrss_co_client.tasks
|
|||||||
Console.WriteLine($"article {headline.id} - podcastifying; {podcastTitle}");
|
Console.WriteLine($"article {headline.id} - podcastifying; {podcastTitle}");
|
||||||
|
|
||||||
await TtrssClient.UpdateArticleNote($"{headline.note}\n[{DateTime.Now.ToString("o")}] - podcastify attachment (dl): {outputStr}", headline.id);
|
await TtrssClient.UpdateArticleNote($"{headline.note}\n[{DateTime.Now.ToString("o")}] - podcastify attachment (dl): {outputStr}", headline.id);
|
||||||
if (!dlResult.IsSuccessStatusCode)
|
if (!File.Exists(downloadPath))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user