From 1b9593599f68cedb5aa49487ac23077237ec7141 Mon Sep 17 00:00:00 2001 From: Ryu Shinmura Date: Tue, 23 Nov 2021 00:47:28 +0900 Subject: [PATCH 1/6] =?UTF-8?q?=E3=83=8B=E3=82=B3=E7=94=9F=E3=81=AE?= =?UTF-8?q?=E8=87=AA=E5=88=86=E8=87=AA=E8=BA=AB=E3=81=AE=E6=83=85=E5=A0=B1?= =?UTF-8?q?=E3=81=AE=E5=8F=96=E5=BE=97=E6=96=B9=E6=B3=95=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NicoSitePlugin2/Api.cs | 48 +++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/NicoSitePlugin2/Api.cs b/NicoSitePlugin2/Api.cs index c64c29e7..b1f331cb 100644 --- a/NicoSitePlugin2/Api.cs +++ b/NicoSitePlugin2/Api.cs @@ -68,43 +68,29 @@ public static async Task GetUserInfo(IDataSource server, CookieContain } public static async Task GetMyInfo(IDataSource server, CookieContainer cc) { - var url = "https://com.nicovideo.jp/community/co1034396"; + var url = "https://www.nicovideo.jp/my"; var html = await server.GetAsync(url, cc); - var match = Regex.Match(html, "user:\\s*({[^}]+?})"); + var match = Regex.Match(html, "data-common-header=\"(.+)\">"); if (!match.Success) { throw new SpecChangedException(html); } - var data = match.Groups[1].Value; - var myInfo = new MyInfo(); - var matchUserId = Regex.Match(data, "id\\s*:\\s*(\\d+)"); - if (matchUserId.Success) - { - myInfo.UserId = matchUserId.Groups[1].Value; - } - var matchNickname = Regex.Match(data, "nickname\\s*:\\s*'([^']+)'"); - if (matchNickname.Success) - { - myInfo.Nickname = matchNickname.Groups[1].Value; - } - var matchIcon = Regex.Match(data, "iconUrl\\s*:\\s*'([^']+)'"); - if (matchIcon.Success) - { - myInfo.IconUrl = matchIcon.Groups[1].Value; - } - var matchPremium = Regex.Match(data, "isPremium\\s*:\\s*(true|false)"); - if (matchPremium.Success) - { - myInfo.IsPremium = matchPremium.Groups[1].Value == "true"; - } - var matchLogin = Regex.Match(data, "isLogin\\s*:\\s*(true|false)"); - if (matchLogin.Success) - { - myInfo.IsLogin = matchLogin.Groups[1].Value == "true"; - } + var json = match.Groups[1].Value.Replace(""", "\""); + dynamic d = JsonConvert.DeserializeObject(json); + var isLogin = (bool)d.initConfig.user.isLogin; + var userId = (long)d.initConfig.user.id; + var isPremium = (bool)d.initConfig.user.isPremium; + var nickname = (string)d.initConfig.user.nickname; + var iconUrl = (string)d.initConfig.user.iconUrl; - - return myInfo; + return new MyInfo + { + IsLogin = isLogin, + Nickname = nickname, + IconUrl = iconUrl, + IsPremium = isPremium, + UserId = userId.ToString(), + }; } /// /// From 082a06d7e1518d66c70ce25f209a929980947e28 Mon Sep 17 00:00:00 2001 From: Ryu Shinmura Date: Tue, 23 Nov 2021 01:25:23 +0900 Subject: [PATCH 2/6] =?UTF-8?q?=E3=83=8B=E3=82=B3=E7=94=9F=E3=81=AE?= =?UTF-8?q?=E3=82=B3=E3=83=9F=E3=83=A5=E3=83=8B=E3=83=86=E3=82=A3=E3=81=AE?= =?UTF-8?q?=E9=85=8D=E4=BF=A1=E6=83=85=E5=A0=B1=E3=82=92=E5=8F=96=E5=BE=97?= =?UTF-8?q?=E3=81=99=E3=82=8BAPI=E3=81=AE=E4=BB=95=E6=A7=98=E5=A4=89?= =?UTF-8?q?=E6=9B=B4=E3=81=AB=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NicoSitePlugin2/Api.cs | 68 +++++++++++---------- NicoSitePlugin2/Low/CommunityLives.cs | 85 +-------------------------- 2 files changed, 39 insertions(+), 114 deletions(-) diff --git a/NicoSitePlugin2/Api.cs b/NicoSitePlugin2/Api.cs index b1f331cb..9d1d7b4a 100644 --- a/NicoSitePlugin2/Api.cs +++ b/NicoSitePlugin2/Api.cs @@ -3,6 +3,8 @@ using System.Net; using Newtonsoft.Json; using System; +using System.Collections.Generic; +using System.Linq; namespace NicoSitePlugin { @@ -38,33 +40,47 @@ public static async Task GetUserInfo(IDataSource server, CookieContain }; return userInfo; } - /// - /// - /// - /// - /// - /// co\d+ - /// - /// - /// - public static async Task GetCommunityLives(IDataSource server, CookieContainer cc, string communityId, int limit, int offset) + public static async Task GetCommunityLives(IDataSource server, CookieContainer cc, string communityId) { - var url = $"https://com.nicovideo.jp/api/v1/communities/{communityId.Substring(2)}/lives.json?limit={limit}&offset={offset}"; + //以下のAPIだとON_AIRだけ取れる。 + //https://com.nicovideo.jp/api/v1/communities/{communityIdWithoutCo}/lives/onair.json + //でも配信していないと + //{"meta":{"status":404,"error-code":"RESOURCE_NOT_FOUND","error-message":"このコミュニティは生放送中ではありません。"}} + //が返ってくる + + + var communityIdWithoutCo = communityId.Substring(2); + var url = $"https://com.nicovideo.jp/api/v1/communities/{communityIdWithoutCo}/lives.json"; var res = await server.GetAsync(url, cc); dynamic d = JsonConvert.DeserializeObject(res); - //{"meta":{"status":404,"error-code":"RESOURCE_NOT_FOUND","error-message":"対象のコミュニティが存在しません。"}} - //{"meta":{"status":404,"error-code":"RESOURCE_NOT_FOUND","error-message":"リソース communities の値の形式が不正です"}} - var status = (int)d.meta.status; - if (status == 200) + if(d.meta.status != 200) { - var obj = JsonConvert.DeserializeObject(res); - return obj.Data.Lives; - + throw new ApiGetCommunityLivesException(); } - else + var lives = new List(); + foreach(var liveDyn in d.data.lives) { - throw new ApiGetCommunityLivesException(); + var live = new CommunityLiveInfo + { + Description = (string)liveDyn.description, + LiveId = (string)liveDyn.id, + Status = (string)liveDyn.status, + Title = (string)liveDyn.title, + UserId = (long)liveDyn.user_id, + WatchUrl = (string)liveDyn.watch_url, + }; + lives.Add(live); } + return lives.ToArray(); + } + public class CommunityLiveInfo + { + public string LiveId { get; set; } + public string Title { get; set; } + public string Description { get; set; } + public string Status { get; set; } + public long UserId { get; set; } + public string WatchUrl { get; set; } } public static async Task GetMyInfo(IDataSource server, CookieContainer cc) { @@ -116,16 +132,8 @@ internal static async Task GetCurrentChannelLiveId(IDataSource dataSourc /// 配信中であればその配信のID、そうでなければnull internal static async Task GetCurrentCommunityLiveId(IDataSource dataSource, string communityId, CookieContainer cc) { - var lives = await GetCommunityLives(dataSource, cc, communityId, 1, 0); - if (lives.Length > 0 && lives[0].Status == "ON_AIR") - { - return lives[0].Id; - } - else - { - return null; - } - + var lives = await GetCommunityLives(dataSource, cc, communityId); + return lives.FirstOrDefault(a => a.Status == "ON_AIR")?.LiveId; } } } diff --git a/NicoSitePlugin2/Low/CommunityLives.cs b/NicoSitePlugin2/Low/CommunityLives.cs index 2a50d839..5f282702 100644 --- a/NicoSitePlugin2/Low/CommunityLives.cs +++ b/NicoSitePlugin2/Low/CommunityLives.cs @@ -1,84 +1 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace NicoSitePlugin2.Low.CommunityLives -{ - public class RootObject - { - [JsonProperty("meta")] - public Meta Meta { get; set; } - - [JsonProperty("data")] - public Data Data { get; set; } - } - - public class Data - { - [JsonProperty("total")] - public long Total { get; set; } - - [JsonProperty("lives")] - public Live[] Lives { get; set; } - } - - public class Live - { - [JsonProperty("id")] - public string Id { get; set; } - - [JsonProperty("title")] - public string Title { get; set; } - - [JsonProperty("description")] - public string Description { get; set; } - - [JsonProperty("status")] - public string Status { get; set; } - - [JsonProperty("user_id")] - public long UserId { get; set; } - - [JsonProperty("watch_url")] - public Uri WatchUrl { get; set; } - - [JsonProperty("features")] - public Features Features { get; set; } - - [JsonProperty("timeshift")] - public Timeshift Timeshift { get; set; } - - [JsonProperty("started_at")] - public string StartedAt { get; set; } - - [JsonProperty("finished_at", NullValueHandling = NullValueHandling.Ignore)] - public string FinishedAt { get; set; } - } - - public class Features - { - [JsonProperty("is_member_only")] - public bool IsMemberOnly { get; set; } - } - - public class Timeshift - { - [JsonProperty("enabled")] - public bool Enabled { get; set; } - - [JsonProperty("can_view", NullValueHandling = NullValueHandling.Ignore)] - public bool? CanView { get; set; } - - [JsonProperty("finished_at", NullValueHandling = NullValueHandling.Ignore)] - public string FinishedAt { get; set; } - } - - public class Meta - { - [JsonProperty("status")] - public long Status { get; set; } - } -} + \ No newline at end of file From 00f3e95dceaea0843f396ba8056f50829d49699f Mon Sep 17 00:00:00 2001 From: Ryu Shinmura Date: Tue, 23 Nov 2021 01:29:37 +0900 Subject: [PATCH 3/6] =?UTF-8?q?=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E7=95=AA=E5=8F=B7=E3=82=92=E3=82=A4=E3=83=B3=E3=82=AF?= =?UTF-8?q?=E3=83=AA=E3=83=A1=E3=83=B3=E3=83=88=200.6.14->0.6.15?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MultiCommentViewer/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MultiCommentViewer/Properties/AssemblyInfo.cs b/MultiCommentViewer/Properties/AssemblyInfo.cs index 73f1ffb1..1cbea287 100644 --- a/MultiCommentViewer/Properties/AssemblyInfo.cs +++ b/MultiCommentViewer/Properties/AssemblyInfo.cs @@ -3,4 +3,4 @@ [assembly: InternalsVisibleTo("MultiCommentViewerTests")] -[assembly: AssemblyVersion("0.6.14")] +[assembly: AssemblyVersion("0.6.15")] From 40c3b276f7eb06ec06f116867db6b1b957e5f389 Mon Sep 17 00:00:00 2001 From: Ryu Shinmura Date: Tue, 23 Nov 2021 03:58:15 +0900 Subject: [PATCH 4/6] =?UTF-8?q?YouTubeLive=E3=81=AE=E7=B5=B5=E6=96=87?= =?UTF-8?q?=E5=AD=97=E3=82=92=E6=A3=92=E8=AA=AD=E3=81=BF=E3=81=A1=E3=82=83?= =?UTF-8?q?=E3=82=93=E3=81=AB=E8=AA=AD=E3=81=BE=E3=81=9B=E3=82=8B=E9=9A=9B?= =?UTF-8?q?=E3=81=AE=E6=8C=99=E5=8B=95=E3=82=92=E4=BB=A5=E5=89=8D=E3=81=AE?= =?UTF-8?q?=E5=AE=9F=E8=A3=85=E3=81=AB=E8=BF=91=E3=81=A5=E3=81=91=E3=81=9F?= =?UTF-8?q?=E3=81=A4=E3=82=82=E3=82=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tiwtterで絵文字を読まなくなったという報告があったため対応した --- BouyomiPlugin/main.cs | 8 ++++++++ YouTubeLiveSitePlugin/Message.cs | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/BouyomiPlugin/main.cs b/BouyomiPlugin/main.cs index 6ed4bcf8..e560646f 100644 --- a/BouyomiPlugin/main.cs +++ b/BouyomiPlugin/main.cs @@ -40,6 +40,14 @@ public static string ToTextWithImageAlt(this IEnumerable parts) { s += image.Alt; } + else if(part is IMessageRemoteSvg remoteSvg) + { + s += remoteSvg.Alt; + } + else + { + + } } } return s; diff --git a/YouTubeLiveSitePlugin/Message.cs b/YouTubeLiveSitePlugin/Message.cs index ba07394f..d179115d 100644 --- a/YouTubeLiveSitePlugin/Message.cs +++ b/YouTubeLiveSitePlugin/Message.cs @@ -163,7 +163,7 @@ public static IMessagePart Parse(ryu_s.YouTubeLive.Message.IMessagePart a) return new Common.MessageSvgImage { Url = emoji.Url, - Alt = "", + Alt = emoji.EmojiId, Height = 24, Width = 24, }; From 5ce6f28b67c4967208b64733c3764cfea5895f58 Mon Sep 17 00:00:00 2001 From: Ryu Shinmura Date: Tue, 23 Nov 2021 03:59:42 +0900 Subject: [PATCH 5/6] =?UTF-8?q?=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E7=95=AA=E5=8F=B7=E3=82=92=E3=82=A4=E3=83=B3=E3=82=AF?= =?UTF-8?q?=E3=83=AA=E3=83=A1=E3=83=B3=E3=83=88=200.6.15->0.6.16?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MultiCommentViewer/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MultiCommentViewer/Properties/AssemblyInfo.cs b/MultiCommentViewer/Properties/AssemblyInfo.cs index 1cbea287..05aa3ca4 100644 --- a/MultiCommentViewer/Properties/AssemblyInfo.cs +++ b/MultiCommentViewer/Properties/AssemblyInfo.cs @@ -3,4 +3,4 @@ [assembly: InternalsVisibleTo("MultiCommentViewerTests")] -[assembly: AssemblyVersion("0.6.15")] +[assembly: AssemblyVersion("0.6.16")] From bfc13ae0b5aa5b46138b7d28ebed2dd0edbe3484 Mon Sep 17 00:00:00 2001 From: Sheeta Sakuramachi Date: Sat, 4 Jun 2022 00:36:54 +0900 Subject: [PATCH 6/6] =?UTF-8?q?184=E9=9D=9E=E8=A1=A8=E7=A4=BA=E8=A8=AD?= =?UTF-8?q?=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NicoSitePlugin2/Message/NicoMessageMetadata.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NicoSitePlugin2/Message/NicoMessageMetadata.cs b/NicoSitePlugin2/Message/NicoMessageMetadata.cs index 68c7dff2..a155d3e1 100644 --- a/NicoSitePlugin2/Message/NicoMessageMetadata.cs +++ b/NicoSitePlugin2/Message/NicoMessageMetadata.cs @@ -40,7 +40,7 @@ public virtual bool IsVisible { get { - if (IsNgUser || IsSiteNgUser) return false; + if (IsNgUser || IsSiteNgUser || (!_siteOptions.IsShow184 && Is184)) return false; //TODO:ConnectedとかDisconnectedの場合、表示するエラーレベルがError以下の場合にfalseにしたい return true;