internal async Task <string> GetChannelIdFromUserId(IYouTubeLibeServer 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); }
/// <summary> /// /// </summary> /// <param name="vid"></param> /// <param name="liveChatHtml"></param> /// <returns></returns> /// <exception cref="ReloadException"></exception> private async Task <string> GetLiveChatHtml(string vid) { string liveChatHtml; try { //live_chatを取得する。この中にこれから必要なytInitialDataとytcfgがある var liveChatUrl = $"https://www.youtube.com/live_chat?v={vid}&is_popout=1"; liveChatHtml = await _server.GetAsync(liveChatUrl, _cc); } catch (Exception ex) { throw new ReloadException(ex); } return(liveChatHtml); }
internal async Task <(string channelId, string reason)> TryGetChannelIdFromCustomChannel(IYouTubeLibeServer 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, ""); }