Compare commits

...

2 Commits

View File

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