Skip to content

Commit

Permalink
Fix crashes on AV cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
Xwilarg committed Sep 22, 2024
1 parent b3c3c91 commit 14a4ccf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Sanara/Module/Command/Impl/Doujin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,12 @@ public async Task AdultVideoAsync(IContext ctx)
// Get main page
var targetUrl = query == null ? "https://missav.com/dm506/en/release" : $"https://missav.com/en/search/{HttpUtility.UrlEncode(query)}";
var html = web.Load(targetUrl);
var page = int.Parse(html.DocumentNode.SelectSingleNode("//nav[contains(@class, 'mt-6')]").ChildNodes[1].SelectSingleNode("form").SelectSingleNode("div").ChildNodes[1].InnerHtml[2..]);
var conVideos = html.DocumentNode.SelectSingleNode("//nav[contains(@class, 'mt-6')]");
if (conVideos == null)
{
throw new CommandFailed("There is no video matching your search");
}
var page = int.Parse(conVideos.ChildNodes[1].SelectSingleNode("form").SelectSingleNode("div").ChildNodes[1].InnerHtml[2..]);

// Get random page
html = web.Load($"{targetUrl}?page={rand.Next(0, page)}");
Expand All @@ -181,6 +186,7 @@ public async Task AdultVideoAsync(IContext ctx)
var name = html.DocumentNode.SelectSingleNode("//h1[contains(@class, 'lg:text-lg')]").InnerHtml;
var description = HttpUtility.HtmlDecode(info.ChildNodes[1].ChildNodes[1].ChildNodes[1].InnerHtml);
var tags = info.ChildNodes[1].ChildNodes[5].ChildNodes[7].SelectNodes("a").Select(x => x.InnerHtml);
if (name.Length > 256) name = name[..255] + "";

var embed = new EmbedBuilder()
.WithColor(Color.Blue)
Expand Down

0 comments on commit 14a4ccf

Please sign in to comment.