handle some common tripping blocks
This commit is contained in:
parent
f4ac000d73
commit
3d61948ccf
44
Program.cs
44
Program.cs
@ -9,13 +9,14 @@ 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.ToLongDateString()}");
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
@ -42,15 +43,14 @@ namespace ttrss_co_client
|
|||||||
{
|
{
|
||||||
case "dl":
|
case "dl":
|
||||||
var stdDLResult = await standardDL(hl.link.ToString());
|
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)
|
if (stdDLResult.Item1 == true)
|
||||||
{
|
{
|
||||||
Console.WriteLine($" {hl.title} -> dl success, removing label");
|
Console.WriteLine($" {hl.title} -> dl success, removing label");
|
||||||
miscTasks.Add(
|
await ttrssClient.SetArticleLabel(
|
||||||
ttrssClient.SetArticleLabel(
|
|
||||||
labelsWRTFeed.First(l => l.caption == action.triggerlabelCaption).id,
|
labelsWRTFeed.First(l => l.caption == action.triggerlabelCaption).id,
|
||||||
false,
|
false,
|
||||||
hl.id));
|
hl.id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -62,18 +62,17 @@ 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);
|
||||||
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)
|
if (YTpodcastifyResult.Item1 == true)
|
||||||
{
|
{
|
||||||
Console.WriteLine($" {hl.title} -> podcastify (YT) success, removing labels");
|
Console.WriteLine($" {hl.title} -> podcastify (YT) success, removing labels");
|
||||||
miscTasks.Add(
|
await ttrssClient.SetArticleLabel(
|
||||||
ttrssClient.SetArticleLabel(
|
|
||||||
labelsWRTFeed.First(l => l.caption == action.triggerlabelCaption).id,
|
labelsWRTFeed.First(l => l.caption == action.triggerlabelCaption).id,
|
||||||
false,
|
false,
|
||||||
hl.id));
|
hl.id);
|
||||||
if (nameLabel != null)
|
if (nameLabel != null)
|
||||||
{
|
{
|
||||||
miscTasks.Add(ttrssClient.SetArticleLabel(nameLabel.id, false, hl.id));
|
await ttrssClient.SetArticleLabel(nameLabel.id, false, hl.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -87,18 +86,17 @@ 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);
|
||||||
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)
|
if (ATTpodcastifyResult.Item1 == true)
|
||||||
{
|
{
|
||||||
Console.WriteLine($" {hl.title} -> podcastify (att) success, removing labels");
|
Console.WriteLine($" {hl.title} -> podcastify (att) success, removing labels");
|
||||||
miscTasks.Add(
|
await ttrssClient.SetArticleLabel(
|
||||||
ttrssClient.SetArticleLabel(
|
|
||||||
labelsWRTFeed.First(l => l.caption == action.triggerlabelCaption).id,
|
labelsWRTFeed.First(l => l.caption == action.triggerlabelCaption).id,
|
||||||
false,
|
false,
|
||||||
hl.id));
|
hl.id);
|
||||||
if (nameLabel != null)
|
if (nameLabel != null)
|
||||||
{
|
{
|
||||||
miscTasks.Add(ttrssClient.SetArticleLabel(nameLabel.id, false, hl.id));
|
await ttrssClient.SetArticleLabel(nameLabel.id, false, hl.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -110,15 +108,14 @@ 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));
|
await ttrssClient.UpdateArticleNote(noteString, hl.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Console.WriteLine($"awaiting remaining download tasks");
|
Console.WriteLine($"logging out");
|
||||||
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");
|
||||||
|
|
||||||
@ -132,9 +129,16 @@ namespace ttrss_co_client
|
|||||||
{
|
{
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(moveTarget));
|
Directory.CreateDirectory(Path.GetDirectoryName(moveTarget));
|
||||||
}
|
}
|
||||||
|
if(File.Exists(moveTarget))
|
||||||
|
{
|
||||||
|
Console.WriteLine("file already exists, abandoning");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
File.Move(f, moveTarget);
|
File.Move(f, moveTarget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Console.WriteLine($"done for real");
|
Console.WriteLine($"done for real");
|
||||||
}
|
}
|
||||||
static Configuration Configure(string configurationPath = "appsettings.json")
|
static Configuration Configure(string configurationPath = "appsettings.json")
|
||||||
@ -215,7 +219,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();
|
||||||
@ -253,7 +257,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))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user