Compare commits
No commits in common. "main" and "1.0" have entirely different histories.
@ -10,8 +10,6 @@ namespace ttrss_co_client
|
|||||||
public string PodcastTitlePrefix { get; set; }
|
public string PodcastTitlePrefix { get; set; }
|
||||||
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 UserAgent { get; set; }
|
|
||||||
public IEnumerable<FeedAction> feedActions { get; set; }
|
public IEnumerable<FeedAction> feedActions { get; set; }
|
||||||
public class FeedAction
|
public class FeedAction
|
||||||
{
|
{
|
||||||
|
35
Program.cs
35
Program.cs
@ -116,8 +116,6 @@ namespace ttrss_co_client
|
|||||||
phase2TaskConcretions.Add(concretion);
|
phase2TaskConcretions.Add(concretion);
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatMessage.ChatScript = conf.ChatScript;
|
|
||||||
|
|
||||||
while (remainingWork.Count > 0)
|
while (remainingWork.Count > 0)
|
||||||
{
|
{
|
||||||
//todo: solve the halting problem
|
//todo: solve the halting problem
|
||||||
@ -136,7 +134,6 @@ namespace ttrss_co_client
|
|||||||
if (appropriatePhase2Task != null)
|
if (appropriatePhase2Task != null)
|
||||||
{
|
{
|
||||||
wo.Phase2TaskList.Remove(wo.Phase2TaskList.Keys.Min());
|
wo.Phase2TaskList.Remove(wo.Phase2TaskList.Keys.Min());
|
||||||
Console.WriteLine("launching phase 2 task: " + taskName);
|
|
||||||
Phase2Tasks.Add(appropriatePhase2Task.ActOn(wo));
|
Phase2Tasks.Add(appropriatePhase2Task.ActOn(wo));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -151,25 +148,18 @@ namespace ttrss_co_client
|
|||||||
foreach (var lingeringTask in Phase2Tasks)
|
foreach (var lingeringTask in Phase2Tasks)
|
||||||
{
|
{
|
||||||
var wo = await lingeringTask;
|
var wo = await lingeringTask;
|
||||||
var wop = Path.Combine(conf.WorkingDirectory, wo.Item2.guid.ToString(), "workorder.json");
|
|
||||||
//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.
|
||||||
|
//TODO: be smart enough to override?
|
||||||
switch (wo.Item1)
|
switch (wo.Item1)
|
||||||
{
|
{
|
||||||
case Phase2Task.TaskStatus.Done:
|
case Phase2Task.TaskStatus.Done:
|
||||||
var workingSubDir = Path.Combine(conf.WorkingDirectory, wo.Item2.guid.ToString());
|
Directory.Delete(Path.Combine(conf.WorkingDirectory, wo.Item2.guid.ToString()));
|
||||||
foreach(var file in Directory.GetFiles(workingSubDir, "*.*", SearchOption.AllDirectories))
|
|
||||||
{
|
|
||||||
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(Path.Combine(conf.WorkingDirectory, wo.Item2.guid.ToString(), "workorder.json"), JsonConvert.SerializeObject(wo.Item2));
|
||||||
File.WriteAllText(wop, JsonConvert.SerializeObject(wo.Item2));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -179,25 +169,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")
|
||||||
|
@ -5,18 +5,16 @@
|
|||||||
"podcastTitlePrefix": "[podcast title] - ",
|
"podcastTitlePrefix": "[podcast title] - ",
|
||||||
"onDoneCopy":"./",
|
"onDoneCopy":"./",
|
||||||
"workingDirectory":"working/",
|
"workingDirectory":"working/",
|
||||||
"chatScript": "miscChat.sh",
|
"feedActions":
|
||||||
"userAgent": "Mozilla/5.0 (compatible; wget-is-not-a-crime/1.0)",
|
|
||||||
"feedActions":
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"triggerlabelCaption":"dl plz",
|
"triggerlabelCaption":"dl plz",
|
||||||
"command":"dl"
|
"command":"dl"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"triggerlabelCaption":"podcastify-yt plz",
|
"triggerlabelCaption":"podcastify-yt plz",
|
||||||
"command":"podcastifyYT"
|
"command":"podcastifyYT"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"triggerlabelCaption":"podcastify-attachment plz",
|
"triggerlabelCaption":"podcastify-attachment plz",
|
||||||
"command":"podcastifyAttachment"
|
"command":"podcastifyAttachment"
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
namespace ttrss_co_client.tasks;
|
|
||||||
|
|
||||||
using System.Linq;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using ttrss_co_client.ttrss;
|
|
||||||
using ttrss_co_client.ttrss.datastructures;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
public class ChatMessage : Phase2Task
|
|
||||||
{
|
|
||||||
public static string ChatScript { get; set; }
|
|
||||||
public override string TaskName => "chatmessage";
|
|
||||||
|
|
||||||
public override async Task<Tuple<TaskStatus, WorkOrder>> ActOn(WorkOrder workOrder)
|
|
||||||
{
|
|
||||||
await Process.Start(ChatScript,
|
|
||||||
workOrder.data["chatmessage"] +
|
|
||||||
(await TtrssClient.GetArticles(workOrder.articleId)).First().feed_title +
|
|
||||||
": " +
|
|
||||||
(await TtrssClient.GetArticles(workOrder.articleId)).First().title
|
|
||||||
).WaitForExitAsync();
|
|
||||||
return new Tuple<TaskStatus, WorkOrder>(TaskStatus.Done, workOrder);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
namespace ttrss_co_client.tasks;
|
|
||||||
|
|
||||||
using System.Linq;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using ttrss_co_client.ttrss;
|
|
||||||
using ttrss_co_client.ttrss.datastructures;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
public class MarkRead : Phase2Task
|
|
||||||
{
|
|
||||||
public override string TaskName => "markread";
|
|
||||||
|
|
||||||
public override async Task<Tuple<TaskStatus, WorkOrder>> ActOn(WorkOrder workOrder)
|
|
||||||
{
|
|
||||||
await TtrssClient.UpdateArticleField(ApiClient.UPDATEFIELD.unread, ApiClient.UPDATEMODE.SetFalse, workOrder.articleId);
|
|
||||||
return new Tuple<TaskStatus, WorkOrder>(TaskStatus.ContinueNow, 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);
|
||||||
@ -49,9 +43,9 @@ namespace ttrss_co_client.tasks
|
|||||||
podcastTitle = titlingLabel.caption.Substring(Conf.PodcastTitlePrefix.Length);
|
podcastTitle = titlingLabel.caption.Substring(Conf.PodcastTitlePrefix.Length);
|
||||||
}
|
}
|
||||||
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;
|
||||||
}
|
}
|
||||||
@ -76,11 +70,6 @@ namespace ttrss_co_client.tasks
|
|||||||
toReturn.data["conversion-target"] = ".mp3";
|
toReturn.data["conversion-target"] = ".mp3";
|
||||||
}
|
}
|
||||||
|
|
||||||
toReturn.Phase2TaskList[2] = "markread";
|
|
||||||
|
|
||||||
toReturn.Phase2TaskList[3] = "chatmessage";
|
|
||||||
toReturn.data["chatmessage"] = "new podcast from ";
|
|
||||||
|
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ namespace ttrss_co_client.tasks
|
|||||||
public override async Task<WorkOrder> ActOn(Headline headline, IEnumerable<Label> labelsWRTArticle)
|
public override async Task<WorkOrder> ActOn(Headline headline, IEnumerable<Label> labelsWRTArticle)
|
||||||
{
|
{
|
||||||
Console.WriteLine($" YT podcastify: {headline.link.ToString()}");
|
Console.WriteLine($" YT podcastify: {headline.link.ToString()}");
|
||||||
|
|
||||||
var myGuid = Guid.NewGuid().ToString();
|
var myGuid = Guid.NewGuid().ToString();
|
||||||
var toReturn = new WorkOrder()
|
var toReturn = new WorkOrder()
|
||||||
{
|
{
|
||||||
@ -29,7 +29,7 @@ namespace ttrss_co_client.tasks
|
|||||||
await TtrssClient.SetArticleLabel(titlingLabel.id, false, headline.id);
|
await TtrssClient.SetArticleLabel(titlingLabel.id, false, headline.id);
|
||||||
}
|
}
|
||||||
Console.WriteLine($"article {headline.id} - yt podcastifying; {podcastTitle}");
|
Console.WriteLine($"article {headline.id} - yt podcastifying; {podcastTitle}");
|
||||||
|
|
||||||
toReturn.Phase2TaskList[0] = "yt-dlp";
|
toReturn.Phase2TaskList[0] = "yt-dlp";
|
||||||
toReturn.data["ytdlp-link"] = headline.link.ToString();
|
toReturn.data["ytdlp-link"] = headline.link.ToString();
|
||||||
|
|
||||||
@ -44,12 +44,6 @@ namespace ttrss_co_client.tasks
|
|||||||
toReturn.Phase2TaskList[3] = "filemovePublish";
|
toReturn.Phase2TaskList[3] = "filemovePublish";
|
||||||
toReturn.data["publish-target"] = $"{Conf.OnDoneCopy}/Podcasts/{podcastTitle}/";
|
toReturn.data["publish-target"] = $"{Conf.OnDoneCopy}/Podcasts/{podcastTitle}/";
|
||||||
|
|
||||||
|
|
||||||
toReturn.Phase2TaskList[4] = "markread";
|
|
||||||
|
|
||||||
toReturn.Phase2TaskList[5] = "chatmessage";
|
|
||||||
toReturn.data["chatmessage"] = "new podcast (via YT) from ";
|
|
||||||
|
|
||||||
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);
|
||||||
Console.WriteLine($" {headline.title}: download trigger label removed");
|
Console.WriteLine($" {headline.title}: download trigger label removed");
|
||||||
|
|
||||||
|
@ -16,17 +16,10 @@ namespace ttrss_co_client.tasks
|
|||||||
{
|
{
|
||||||
Directory.CreateDirectory(targetDirectory);
|
Directory.CreateDirectory(targetDirectory);
|
||||||
}
|
}
|
||||||
|
File.Move(workOrder.data["path"], Path.Combine(workOrder.data["publish-target"], Path.GetFileName(workOrder.data["path"])), true);
|
||||||
var outputFilename = Path.Combine(workOrder.data["publish-target"], Path.GetFileName(workOrder.data["path"]));
|
|
||||||
foreach(char c in "'\":\\?")
|
|
||||||
{
|
|
||||||
outputFilename = outputFilename.Replace(c, ' ');
|
|
||||||
}
|
|
||||||
|
|
||||||
File.Move(workOrder.data["path"], outputFilename, true);
|
|
||||||
var article = (await TtrssClient.GetArticles(workOrder.articleId))?.FirstOrDefault();
|
var article = (await TtrssClient.GetArticles(workOrder.articleId))?.FirstOrDefault();
|
||||||
await TtrssClient.UpdateArticleNote($"{article.note}\n[{DateTime.Now.ToString("o")}] - copied", article.id);
|
await TtrssClient.UpdateArticleNote($"{article.note}\n[{DateTime.Now.ToString("o")}] - copied", article.id);
|
||||||
return new Tuple<TaskStatus, WorkOrder>(TaskStatus.ContinueNow, workOrder);
|
return new Tuple<TaskStatus, WorkOrder>(TaskStatus.Done, workOrder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,6 +9,7 @@ using ttrss_co_client.ttrss.datastructures;
|
|||||||
|
|
||||||
namespace ttrss_co_client.tasks
|
namespace ttrss_co_client.tasks
|
||||||
{
|
{
|
||||||
|
///<summary>Move to output</summary>
|
||||||
public class Sponsorblock : Phase2Task
|
public class Sponsorblock : Phase2Task
|
||||||
{
|
{
|
||||||
public override string TaskName => "sponsorblock";
|
public override string TaskName => "sponsorblock";
|
||||||
@ -66,7 +67,7 @@ namespace ttrss_co_client.tasks
|
|||||||
var extension = workOrder.data["path"].Substring(workOrder.data["path"].LastIndexOf('.'));
|
var extension = workOrder.data["path"].Substring(workOrder.data["path"].LastIndexOf('.'));
|
||||||
var intermediatePathBase = workOrder.data["path"].Substring(0, workOrder.data["path"].LastIndexOf('.'));
|
var intermediatePathBase = workOrder.data["path"].Substring(0, workOrder.data["path"].LastIndexOf('.'));
|
||||||
var conversionProcesses = new List<Tuple<Process, Tuple<int, string>>>();
|
var conversionProcesses = new List<Tuple<Process, Tuple<int, string>>>();
|
||||||
|
|
||||||
foreach(var junkSegment in segments.OrderBy(s => s.segment[0]))
|
foreach(var junkSegment in segments.OrderBy(s => s.segment[0]))
|
||||||
{
|
{
|
||||||
contentSegments.Add(new Tuple<double, double>(previousEdge, junkSegment.segment[0]));
|
contentSegments.Add(new Tuple<double, double>(previousEdge, junkSegment.segment[0]));
|
||||||
@ -112,7 +113,7 @@ namespace ttrss_co_client.tasks
|
|||||||
|
|
||||||
Console.WriteLine($"[{DateTime.Now.ToString("o")}] intermediate content segments stitched. Deleting originals.");
|
Console.WriteLine($"[{DateTime.Now.ToString("o")}] intermediate content segments stitched. Deleting originals.");
|
||||||
foreach(var intermediate in intermediates.Values)
|
foreach(var intermediate in intermediates.Values)
|
||||||
{
|
{
|
||||||
File.Delete(intermediate);
|
File.Delete(intermediate);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -11,7 +11,7 @@ namespace ttrss_co_client.tasks
|
|||||||
public override async Task<WorkOrder> ActOn(Headline headline, IEnumerable<Label> labelsWRTArticle)
|
public override async Task<WorkOrder> ActOn(Headline headline, IEnumerable<Label> labelsWRTArticle)
|
||||||
{
|
{
|
||||||
Console.WriteLine($" standard download: {headline.link.ToString()}");
|
Console.WriteLine($" standard download: {headline.link.ToString()}");
|
||||||
|
|
||||||
var myGuid = Guid.NewGuid().ToString();
|
var myGuid = Guid.NewGuid().ToString();
|
||||||
var toReturn = new WorkOrder()
|
var toReturn = new WorkOrder()
|
||||||
{
|
{
|
||||||
@ -20,7 +20,7 @@ namespace ttrss_co_client.tasks
|
|||||||
data = new Dictionary<string, string>(),
|
data = new Dictionary<string, string>(),
|
||||||
guid = Guid.Parse(myGuid)
|
guid = Guid.Parse(myGuid)
|
||||||
};
|
};
|
||||||
|
|
||||||
toReturn.Phase2TaskList[0] = "yt-dlp";
|
toReturn.Phase2TaskList[0] = "yt-dlp";
|
||||||
toReturn.data["ytdlp-link"] = headline.link.ToString();
|
toReturn.data["ytdlp-link"] = headline.link.ToString();
|
||||||
|
|
||||||
@ -35,11 +35,6 @@ namespace ttrss_co_client.tasks
|
|||||||
toReturn.Phase2TaskList[3] = "filemovePublish";
|
toReturn.Phase2TaskList[3] = "filemovePublish";
|
||||||
toReturn.data["publish-target"] = $"{Conf.OnDoneCopy}/recent episodes/";
|
toReturn.data["publish-target"] = $"{Conf.OnDoneCopy}/recent episodes/";
|
||||||
|
|
||||||
toReturn.Phase2TaskList[4] = "markread";
|
|
||||||
|
|
||||||
toReturn.Phase2TaskList[5] = "chatmessage";
|
|
||||||
toReturn.data["chatmessage"] = "new video from ";
|
|
||||||
|
|
||||||
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);
|
||||||
Console.WriteLine($" {headline.title}: download trigger label removed");
|
Console.WriteLine($" {headline.title}: download trigger label removed");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user