Compare commits

..

No commits in common. "b04e870cd85be36be4c40921c5129097127e5163" and "f4ac000d73aa8cf97f6d7163a87b5e79cb302a71" have entirely different histories.

View File

@ -9,14 +9,13 @@ namespace ttrss_co_client
static async Task Main(string[] args) static async Task Main(string[] args)
{ {
var conf = Configure(); var conf = Configure();
Console.WriteLine($"{DateTime.Now.ToLongTimeString()}");
var ttrssClient = new ttrss.ApiClient(conf.BaseURI); var ttrssClient = new ttrss.ApiClient(conf.BaseURI);
await ttrssClient.Login(conf.Username, conf.Password); await ttrssClient.Login(conf.Username, conf.Password);
var loggedin = await ttrssClient.IsLoggedIn(); var loggedin = await ttrssClient.IsLoggedIn();
Console.WriteLine($"logged in: {loggedin}"); Console.WriteLine($"logged in: {loggedin}");
var miscTasks = new List<Task>();
var unreadFeeds = await ttrssClient.GetFeeds(cat_id: -3, unread_only: true); var unreadFeeds = await ttrssClient.GetFeeds(cat_id: -3, unread_only: true);
foreach (var uf in unreadFeeds) foreach (var uf in unreadFeeds)
{ {
@ -43,14 +42,15 @@ namespace ttrss_co_client
{ {
case "dl": case "dl":
var stdDLResult = await standardDL(hl.link.ToString()); var stdDLResult = await standardDL(hl.link.ToString());
await ttrssClient.UpdateArticleNote($"{noteString}[{DateTime.Now.ToLongTimeString()}] - {stdDLResult.Item2}", hl.id); miscTasks.Add(ttrssClient.UpdateArticleNote($"{noteString}[{DateTime.Now.ToLongTimeString()}] - {stdDLResult.Item2}", hl.id));
if (stdDLResult.Item1 == true) if (stdDLResult.Item1 == true)
{ {
Console.WriteLine($" {hl.title} -> dl success, removing label"); Console.WriteLine($" {hl.title} -> dl success, removing label");
await ttrssClient.SetArticleLabel( miscTasks.Add(
labelsWRTFeed.First(l => l.caption == action.triggerlabelCaption).id, ttrssClient.SetArticleLabel(
false, labelsWRTFeed.First(l => l.caption == action.triggerlabelCaption).id,
hl.id); false,
hl.id));
} }
else else
{ {
@ -62,17 +62,18 @@ namespace ttrss_co_client
podcastName = nameLabel?.caption.Substring(conf.PodcastTitlePrefix.Length) podcastName = nameLabel?.caption.Substring(conf.PodcastTitlePrefix.Length)
?? hl.feed_title; ?? hl.feed_title;
var YTpodcastifyResult = await podcastifyYT(hl.link.ToString(), podcastName); var YTpodcastifyResult = await podcastifyYT(hl.link.ToString(), podcastName);
await ttrssClient.UpdateArticleNote($"{noteString}[{DateTime.Now.ToLongTimeString()}] - {YTpodcastifyResult.Item2}", hl.id); miscTasks.Add(ttrssClient.UpdateArticleNote($"{noteString}[{DateTime.Now.ToLongTimeString()}] - {YTpodcastifyResult.Item2}", hl.id));
if (YTpodcastifyResult.Item1 == true) if (YTpodcastifyResult.Item1 == true)
{ {
Console.WriteLine($" {hl.title} -> podcastify (YT) success, removing labels"); Console.WriteLine($" {hl.title} -> podcastify (YT) success, removing labels");
await ttrssClient.SetArticleLabel( miscTasks.Add(
labelsWRTFeed.First(l => l.caption == action.triggerlabelCaption).id, ttrssClient.SetArticleLabel(
false, labelsWRTFeed.First(l => l.caption == action.triggerlabelCaption).id,
hl.id); false,
hl.id));
if (nameLabel != null) if (nameLabel != null)
{ {
await ttrssClient.SetArticleLabel(nameLabel.id, false, hl.id); miscTasks.Add(ttrssClient.SetArticleLabel(nameLabel.id, false, hl.id));
} }
} }
else else
@ -86,17 +87,18 @@ namespace ttrss_co_client
?? hl.feed_title; ?? hl.feed_title;
var attachmentLink = hl.attachments.Select(a => a.content_url)?.FirstOrDefault(); var attachmentLink = hl.attachments.Select(a => a.content_url)?.FirstOrDefault();
var ATTpodcastifyResult = await podcastifyAttachment(attachmentLink.ToString(), podcastName, hl.title); var ATTpodcastifyResult = await podcastifyAttachment(attachmentLink.ToString(), podcastName, hl.title);
await ttrssClient.UpdateArticleNote($"{noteString}[{DateTime.Now.ToLongTimeString()}] - {ATTpodcastifyResult.Item2}", hl.id); miscTasks.Add(ttrssClient.UpdateArticleNote($"{noteString}[{DateTime.Now.ToLongTimeString()}] - {ATTpodcastifyResult.Item2}", hl.id));
if (ATTpodcastifyResult.Item1 == true) if (ATTpodcastifyResult.Item1 == true)
{ {
Console.WriteLine($" {hl.title} -> podcastify (att) success, removing labels"); Console.WriteLine($" {hl.title} -> podcastify (att) success, removing labels");
await ttrssClient.SetArticleLabel( miscTasks.Add(
labelsWRTFeed.First(l => l.caption == action.triggerlabelCaption).id, ttrssClient.SetArticleLabel(
false, labelsWRTFeed.First(l => l.caption == action.triggerlabelCaption).id,
hl.id); false,
hl.id));
if (nameLabel != null) if (nameLabel != null)
{ {
await ttrssClient.SetArticleLabel(nameLabel.id, false, hl.id); miscTasks.Add(ttrssClient.SetArticleLabel(nameLabel.id, false, hl.id));
} }
} }
else else
@ -108,13 +110,15 @@ namespace ttrss_co_client
noteString += $"[{DateTime.Now.ToLongTimeString()}] - feed configured but action not recognized"; noteString += $"[{DateTime.Now.ToLongTimeString()}] - feed configured but action not recognized";
break; break;
} }
miscTasks.Add(ttrssClient.UpdateArticleNote(noteString, hl.id));
} }
} }
} }
} }
Console.WriteLine($"logging out"); Console.WriteLine($"awaiting remaining download tasks");
Task.WaitAll(miscTasks.ToArray());
await ttrssClient.Logout(); await ttrssClient.Logout();
Console.WriteLine($"done, moving files from temporary location"); Console.WriteLine($"done, moving files from temporary location");
@ -128,14 +132,7 @@ namespace ttrss_co_client
{ {
Directory.CreateDirectory(Path.GetDirectoryName(moveTarget)); Directory.CreateDirectory(Path.GetDirectoryName(moveTarget));
} }
if(File.Exists(moveTarget)) File.Move(f, moveTarget);
{
Console.WriteLine("file already exists, abandoning");
}
else
{
File.Move(f, moveTarget);
}
} }
} }
Console.WriteLine($"done for real"); Console.WriteLine($"done for real");
@ -218,7 +215,7 @@ namespace ttrss_co_client
var ytdl = new YoutubeDLSharp.YoutubeDL(); var ytdl = new YoutubeDLSharp.YoutubeDL();
ytdl.YoutubeDLPath = "yt-dlp"; ytdl.YoutubeDLPath = "yt-dlp";
ytdl.FFmpegPath = "ffmpeg"; ytdl.FFmpegPath = "ffmpeg";
ytdl.OutputFolder = $"./tmp/Podcasts/{podcastName}"; ytdl.OutputFolder = $"./tmp/podcasts/{podcastName}";
ytdl.OutputFileTemplate = "%(upload_date)s - %(title)s - [%(id)s].%(ext)s"; ytdl.OutputFileTemplate = "%(upload_date)s - %(title)s - [%(id)s].%(ext)s";
var sw = new Stopwatch(); var sw = new Stopwatch();
sw.Start(); sw.Start();
@ -256,7 +253,7 @@ namespace ttrss_co_client
try try
{ {
var extensionUpstream = attachmentLink.Substring(attachmentLink.LastIndexOf('.')); var extensionUpstream = attachmentLink.Substring(attachmentLink.LastIndexOf('.'));
var containingDirectory = $"./tmp/Podcasts/{podcastName}/"; var containingDirectory = $"./tmp/podcasts/{podcastName}/";
var outputFilename = $"{containingDirectory}{episodeTitle}{extensionUpstream}"; var outputFilename = $"{containingDirectory}{episodeTitle}{extensionUpstream}";
if(!Directory.Exists(containingDirectory)) if(!Directory.Exists(containingDirectory))
{ {