oh wait, i didn't believe it when it said it was broken

This commit is contained in:
Adam R Grey 2023-04-06 16:01:26 -04:00
parent 3816c29612
commit 9628a7b8b9

View File

@ -31,7 +31,7 @@ namespace ttrss_co_client
if (actionsForFeed != null && actionsForFeed.Any())
{
var sponsorCheck = await SponsorCheck(hl);
if(!sponsorCheck.Item1)
if (!sponsorCheck.Item1)
{
await ttrssClient.UpdateArticleNote($"{hl.note}\n[{DateTime.Now.ToLongTimeString()}] sponsorcheck: {sponsorCheck.Item2}", hl.id);
continue;
@ -135,7 +135,7 @@ namespace ttrss_co_client
{
Directory.CreateDirectory(Path.GetDirectoryName(moveTarget));
}
if(File.Exists(moveTarget))
if (File.Exists(moveTarget))
{
Console.WriteLine("file already exists, abandoning");
}
@ -265,7 +265,7 @@ namespace ttrss_co_client
var extensionUpstream = attachmentLink.Substring(attachmentLink.LastIndexOf('.'));
var containingDirectory = $"./tmp/Podcasts/{podcastName}/";
var outputFilename = $"{containingDirectory}{episodeTitle}{extensionUpstream}";
if(!Directory.Exists(containingDirectory))
if (!Directory.Exists(containingDirectory))
{
Directory.CreateDirectory(containingDirectory);
}
@ -298,7 +298,7 @@ namespace ttrss_co_client
}
private static async Task<Tuple<bool, string>> SponsorCheck(ttrss.datastructures.Headline hl)
{
if(!hl.link.Host.EndsWith("youtube.com"))
if (!hl.link.Host.EndsWith("youtube.com"))
{
return new Tuple<bool, string>(true, "sponsorblock, sadly, only exists for youtube");
}
@ -307,12 +307,12 @@ namespace ttrss_co_client
var c = new HttpClient();
var sponsorblockcheck = await c.GetAsync($"https://sponsor.ajay.app/api/skipSegments?videoID={videoId}&category=sponsor&category=selfpromo&category=interaciton&category=intro&category=outro&category=preview");
if(sponsorblockcheck.StatusCode == System.Net.HttpStatusCode.NotFound)
if (sponsorblockcheck.StatusCode == System.Net.HttpStatusCode.NotFound)
{
Console.WriteLine($"sponsorblock reports that {videoId} has no entries (yet)");
var updateTimestamp = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
updateTimestamp = updateTimestamp.AddSeconds(hl.updated).ToLocalTime();
if(DateTime.Now - updateTimestamp > TimeSpan.FromMinutes(45))
if (DateTime.Now - updateTimestamp > TimeSpan.FromMinutes(45))
{
return new Tuple<bool, string>(true, $"updated {updateTimestamp} (more than 45 minutes ago), going to give up waiting for sponsorblock");
}
@ -326,7 +326,7 @@ namespace ttrss_co_client
try
{
var segments = JsonConvert.DeserializeObject<IEnumerable<sponsorblock.Segment>>(await sponsorblockcheck.Content.ReadAsStringAsync());
if(segments.Count() > 1)
if (segments.Count() > 1)
{
return new Tuple<bool, string>(true, $"{segments.Count()} segments");
}
@ -335,6 +335,10 @@ namespace ttrss_co_client
return new Tuple<bool, string>(false, $"no segments");
}
}
catch (Exception e)
{
return new Tuple<bool, string>(false, $"{e.ToString()} - {e.Message}");
}
}
}
}