tytd-extensions/ReturnYTDislikes/Class1.cs

43 lines
1.1 KiB
C#
Raw Permalink Normal View History

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TYTD;
using System.Net;
using Newtonsoft.Json;
namespace ReturnYTDislikes
{
public class ReturnDislikes : Api
{
public override void OnStart()
{
DownloadInfoStart += ReturnDislikes_DownloadInfoStart;
}
public override IEnumerable<KeyValuePair<string, string>> GetUrls()
{
return new List<KeyValuePair<string, string>>();
}
private void ReturnDislikes_DownloadInfoStart(object sender, DownloadInfoStartEventArgs e)
{
using(var wc = new WebClient())
{
try
{
e.Video.Dislikes = JsonConvert.DeserializeObject<dislike>(wc.DownloadString($"https://returnyoutubedislikeapi.com/votes?videoId={e.Video.Id}")).dislikes;
}catch(Exception ex)
{
_ = ex;
}
}
}
public class dislike
{
public long dislikes { get; set; }
}
}
}