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)
{
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)
{
@ -43,14 +42,15 @@ namespace ttrss_co_client
{
case "dl":
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)
{
Console.WriteLine($" {hl.title} -> dl success, removing label");
await ttrssClient.SetArticleLabel(
miscTasks.Add(
ttrssClient.SetArticleLabel(
labelsWRTFeed.First(l => l.caption == action.triggerlabelCaption).id,
false,
hl.id);
hl.id));
}
else
{
@ -62,17 +62,18 @@ namespace ttrss_co_client
podcastName = nameLabel?.caption.Substring(conf.PodcastTitlePrefix.Length)
?? hl.feed_title;
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)
{
Console.WriteLine($" {hl.title} -> podcastify (YT) success, removing labels");
await ttrssClient.SetArticleLabel(
miscTasks.Add(
ttrssClient.SetArticleLabel(
labelsWRTFeed.First(l => l.caption == action.triggerlabelCaption).id,
false,
hl.id);
hl.id));
if (nameLabel != null)
{
await ttrssClient.SetArticleLabel(nameLabel.id, false, hl.id);
miscTasks.Add(ttrssClient.SetArticleLabel(nameLabel.id, false, hl.id));
}
}
else
@ -86,17 +87,18 @@ 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);
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)
{
Console.WriteLine($" {hl.title} -> podcastify (att) success, removing labels");
await ttrssClient.SetArticleLabel(
miscTasks.Add(
ttrssClient.SetArticleLabel(
labelsWRTFeed.First(l => l.caption == action.triggerlabelCaption).id,
false,
hl.id);
hl.id));
if (nameLabel != null)
{
await ttrssClient.SetArticleLabel(nameLabel.id, false, hl.id);
miscTasks.Add(ttrssClient.SetArticleLabel(nameLabel.id, false, hl.id));
}
}
else
@ -108,13 +110,15 @@ namespace ttrss_co_client
noteString += $"[{DateTime.Now.ToLongTimeString()}] - feed configured but action not recognized";
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();
Console.WriteLine($"done, moving files from temporary location");
@ -128,16 +132,9 @@ namespace ttrss_co_client
{
Directory.CreateDirectory(Path.GetDirectoryName(moveTarget));
}
if(File.Exists(moveTarget))
{
Console.WriteLine("file already exists, abandoning");
}
else
{
File.Move(f, moveTarget);
}
}
}
Console.WriteLine($"done for real");
}
static Configuration Configure(string configurationPath = "appsettings.json")
@ -218,7 +215,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();
@ -256,7 +253,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))
{