/// <summary> /// (非公開API) /// </summary> /// <param name="live_id"></param> /// <param name="n"></param> /// <param name="lastCommentId"></param> public static async Task <(List <LowObject.Comment> LowComments, int Cnum, string raw)> GetListUpdate(IDataServer dataSource, string broadcaster, long live_id, int cnum, long lastCommentId, CookieContainer cc) { var url = $"http://twitcasting.tv/{broadcaster}/userajax.php?c=listupdate&m={live_id}&n={cnum}&k={lastCommentId}"; var str = await dataSource.GetAsync(url, cc); if (str == "[]") { return(new List <LowObject.Comment>(), cnum, str); } var obj = Tools.Deserialize <LowObject.ListUpdate>(str); var comments = obj.comment; var newCnum = obj.cnum; return(comments, newCnum, str); }
public static async Task <Dictionary <long, GiftItem> > GetGiftDict(IDataServer server) { var url = "https://cloudac.mildom.com/nonolive/gappserv/gift/find"; var headers = new Dictionary <string, string> { }; var res = await server.GetAsync(url, headers); var obj = Tools.Deserialize <Low.gift_find.RootObject>(res); var dict = new Dictionary <long, GiftItem>(); foreach (var item in obj.Body.Models) { dict.Add(item.GiftId, new GiftItem(item)); } foreach (var item in obj.Body.Pack) { dict.Add(item.GiftId, new GiftItem(item)); } return(dict); }
public static async Task <(IStreamChecker, string raw)> GetStreamChecker(IDataServer dataServer, string broadcasterId, string lastItemId) { if (string.IsNullOrEmpty(lastItemId)) { lastItemId = "-1"; } var url = $"https://twitcasting.tv/streamchecker.php?u={broadcasterId}&v=999&islive=1&lastitemid={lastItemId}"; var str = await dataServer.GetAsync(url); IStreamChecker s; try { s = LowObject.StreamChecker2.ParseStreamChcker(str); } catch (Exception ex) { throw new ParseException(str, ex); } return(s, str); }
/// <summary> /// /// </summary> /// <param name="server"></param> /// <param name="cc"></param> /// <returns></returns> public static async Task <long[]> GetBlockList(IDataServer server, List <Cookie> cookies) { string accessToken = null; foreach (var cookie in cookies) { if (cookie.Name == "linelive") { accessToken = cookie.Value; } } if (string.IsNullOrEmpty(accessToken)) { //未ログイン。どうせ情報を取得できないから諦める。 return(null); } var url = "https://live-api.line-apps.com/app/setting/blocklist/bulk"; var headers = new Dictionary <string, string>() { { "X-CastService-WebClient-AccessToken", accessToken }, }; var cc = Tools.CreateCookieContainer(cookies); var res = await server.GetAsync(url, headers, cc); //{"blockedUserIds":[1983766],"apistatusCode":200,"status":200} //{"blockedUserIds":[316787,1983766],"apistatusCode":200,"status":200} var d = Codeplex.Data.DynamicJson.Parse(res); if (d.status == 200) { return((long[])d.blockedUserIds); } else { return(null); } }
public static async Task <List <Message> > GetLiveComments(IDataServer server, string liveId) { var url = "https://www.mirrativ.com/api/live/live_comments?live_id=" + liveId; var res = await server.GetAsync(url, null); var obj = Tools.Deserialize <Low.LiveComments.RootObject>(res); var list = new List <Message>(); foreach (var c in obj.Comments) { list.Add(new Message { Comment = c.CommentComment, CreatedAt = long.Parse(c.CreatedAt), Id = c.Id, Type = MessageType.Comment, UserId = c.UserId, Username = c.UserName, }); } //時系列的に降順になっているから昇順に直す list.Reverse(); return(list); }
/// <summary> /// /// </summary> /// <param name="dataSource"></param> /// <param name="broadcaster"></param> /// <returns></returns> /// <exception cref="System.Net.Http.HttpRequestException"></exception> /// <exception cref="InvalidBroadcasterIdException"></exception> public static async Task <(LowObject.LiveContext, string raw)> GetLiveContext(IDataServer dataSource, string broadcaster, CookieContainer cc) { var url = "http://twitcasting.tv/" + broadcaster; var userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36"; var str = await dataSource.GetAsync(url, userAgent, cc); var context = new LowObject.LiveContext(); { var match0 = Regex.Match(str, "data-cnum=\"(?<cnum>[\\d]+)\""); if (match0.Success) { context.MovieCnum = int.Parse(match0.Groups["cnum"].Value); } else { var match0_2 = Regex.Match(str, "var movie_cnum = (?<cnum>[\\d]+);"); if (match0_2.Success) { context.MovieCnum = int.Parse(match0_2.Groups["cnum"].Value); } else { throw new InvalidBroadcasterIdException(broadcaster); } } } { var match1 = Regex.Match(str, "data-movie-id=\"(\\d+)\""); if (match1.Success) { context.MovieId = long.Parse(match1.Groups[1].Value); } else { var match1_2 = Regex.Match(str, "var movieid = \"(\\d+)\""); if (match1_2.Success) { context.MovieId = long.Parse(match1_2.Groups[1].Value); } else { throw new InvalidBroadcasterIdException(broadcaster); } } } { var match = Regex.Match(str, "data-audience-id=\"([^\"]+)\""); if (match.Success) { var audienceId = match.Groups[1].Value; context.AudienceId = audienceId; } else { var match_2 = Regex.Match(str, "a href=\"/([^\"/]+)/notification"); if (match_2.Success) { var audienceId = match_2.Groups[1].Value; context.AudienceId = audienceId; } else { context.AudienceId = null; } } } return(context, str); }