internal async Task <string> GetChannelIdFromUserId(IYouTubeLiveServer server, string userId) { var url = "https://www.youtube.com/user/" + userId; var html = await server.GetAsync(url); var match = Regex.Match(html, "<meta property=\"og:url\" content=\"https://www.youtube.com/channel/([^\"]+)\">"); if (match.Success) { var channelId = match.Groups[1].Value; return(channelId); } throw new ParseException(html); }
internal async Task <(string channelId, string reason)> TryGetChannelIdFromCustomChannel(IYouTubeLiveServer server, string input) { var match1 = _regexCustomChannel.Match(input); if (match1.Success) { var userId = match1.Groups[1].Value; var html = await server.GetAsync($"https://www.youtube.com/c/{userId}"); var match2 = Regex.Match(html, "property=\"og:url\" content=\"https://www\\.youtube\\.com/channel/(?<channelid>[^/\"?]+)\">"); if (match2.Success) { var channelId = match2.Groups["channelid"].Value; return(channelId, null); } } return(null, ""); }