Compare commits
No commits in common. "3816c29612ef7b67c56a9cffcac4b866087bc014" and "dbb342302e18da9ac9ab139994b53906ce95b9da" have entirely different histories.
3816c29612
...
dbb342302e
31
Program.cs
31
Program.cs
@ -30,16 +30,15 @@ namespace ttrss_co_client
|
|||||||
labelsWRTFeed.Where(l => l.@checked).Select(l => l.caption).Contains(fa.triggerlabelCaption))?.ToList();
|
labelsWRTFeed.Where(l => l.@checked).Select(l => l.caption).Contains(fa.triggerlabelCaption))?.ToList();
|
||||||
if (actionsForFeed != null && actionsForFeed.Any())
|
if (actionsForFeed != null && actionsForFeed.Any())
|
||||||
{
|
{
|
||||||
var sponsorCheck = await SponsorCheck(hl);
|
if(!(await SponsorCheck(hl)))
|
||||||
if(!sponsorCheck.Item1)
|
|
||||||
{
|
{
|
||||||
await ttrssClient.UpdateArticleNote($"{hl.note}\n[{DateTime.Now.ToLongTimeString()}] sponsorcheck: {sponsorCheck.Item2}", hl.id);
|
await ttrssClient.UpdateArticleNote($"{hl.note}\n[{DateTime.Now.ToLongTimeString()}] waiting for sponsorblock", hl.id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
foreach (var action in actionsForFeed)
|
foreach (var action in actionsForFeed)
|
||||||
{
|
{
|
||||||
Console.WriteLine($" {hl.title} -> action: {action.command}");
|
Console.WriteLine($" {hl.title} -> action: {action.command}");
|
||||||
var noteString = $"{hl.note}\n[{DateTime.Now.ToLongTimeString()}] sponsorcheck: {sponsorCheck.Item2}";
|
var noteString = hl.note;
|
||||||
ttrss.datastructures.Label nameLabel;
|
ttrss.datastructures.Label nameLabel;
|
||||||
string podcastName;
|
string podcastName;
|
||||||
if (!string.IsNullOrWhiteSpace(noteString))
|
if (!string.IsNullOrWhiteSpace(noteString))
|
||||||
@ -296,11 +295,12 @@ namespace ttrss_co_client
|
|||||||
return new Tuple<bool, string>(false, $"{e.ToString()}: {e.Message}.\n{e.StackTrace}");
|
return new Tuple<bool, string>(false, $"{e.ToString()}: {e.Message}.\n{e.StackTrace}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static async Task<Tuple<bool, string>> SponsorCheck(ttrss.datastructures.Headline hl)
|
public static async Task<bool> 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");
|
//sponsorblock, sadly, only exists for youtube
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
var match = Regex.Match(hl.link.Query, "v=([^&]+)(&|$)");
|
var match = Regex.Match(hl.link.Query, "v=([^&]+)(&|$)");
|
||||||
var videoId = match.Groups?[1].Value;
|
var videoId = match.Groups?[1].Value;
|
||||||
@ -314,27 +314,18 @@ namespace ttrss_co_client
|
|||||||
updateTimestamp = updateTimestamp.AddSeconds(hl.updated).ToLocalTime();
|
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");
|
Console.WriteLine($"updated {updateTimestamp} (more than 45 minutes ago), going to give up waiting for sponsorblock");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return new Tuple<bool, string>(false, "none found, waiting");
|
Console.WriteLine($"going to wait a bit for segments to show up.");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
try
|
return true;
|
||||||
{
|
|
||||||
var segments = JsonConvert.DeserializeObject<IEnumerable<sponsorblock.Segment>>(await sponsorblockcheck.Content.ReadAsStringAsync());
|
|
||||||
if(segments.Count() > 1)
|
|
||||||
{
|
|
||||||
return new Tuple<bool, string>(true, $"{segments.Count()} segments");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return new Tuple<bool, string>(false, $"no segments");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace ttrss_co_client.sponsorblock
|
|
||||||
{
|
|
||||||
public class Segment
|
|
||||||
{
|
|
||||||
public string category { get; set; }
|
|
||||||
public string actionType { get; set; }
|
|
||||||
public double[] segment { get; set; } //start time, end time
|
|
||||||
public string UUID { get; set; }
|
|
||||||
public double videoDuration { get; set; } //yes, this is repeated in each segment
|
|
||||||
public int locked { get; set; }
|
|
||||||
public int votes { get; set; }
|
|
||||||
public string description { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user