Skip to content

Commit fbb4606

Browse files
committed
ニコ生の放送IDのみでコメントを取得できなくなっていた不具合を修正 #174
1 parent 6edadc2 commit fbb4606

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

NicoSitePlugin2/IInput.cs

+15
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,21 @@ public CommunityUrl(string communityId)
3232
CommunityId = communityId;
3333
}
3434
}
35+
class LiveId : IInput
36+
{
37+
/// <summary>
38+
/// lv\d+
39+
/// </summary>
40+
public string Raw { get; }
41+
/// <summary>
42+
///
43+
/// </summary>
44+
/// <param name="liveId">lv\d+</param>
45+
public LiveId(string liveId)
46+
{
47+
Raw = liveId;
48+
}
49+
}
3550
class InvalidInput : IInput
3651
{
3752
public InvalidInput(string raw)

NicoSitePlugin2/TestCommentProvider.cs

+4
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ public async Task ConnectInternalAsync(IInput input, IBrowserProfile browserProf
135135
{
136136
vid = await GetCommunityLiveId(communityUrl, cc);
137137
}
138+
else if(input is LiveId liveId)
139+
{
140+
vid = liveId.Raw;
141+
}
138142
else
139143
{
140144
throw new InvalidOperationException("bug");

NicoSitePlugin2/Tools.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ public static IInput ParseInput(string input)
2121
var communityId = ExtractCommunityIdFromUrl(input);
2222
return new CommunityUrl(communityId);
2323
}
24+
else if (IsLiveId(input))
25+
{
26+
return new LiveId(input);
27+
}
2428
else
2529
{
2630
return new InvalidInput(input);
@@ -61,7 +65,10 @@ public static string ExtractLiveIdFromLivePageUrl(string input)
6165
if (!match.Success) return null;
6266
return match.Groups[1].Value;
6367
}
64-
68+
public static bool IsLiveId(string input)
69+
{
70+
return Regex.IsMatch(input, "lv\\d+");
71+
}
6572
internal static string ExtractLiveId(string str)
6673
{
6774
var match = Regex.Match(str, "(lv\\d+)");

0 commit comments

Comments
 (0)