Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

「B-LIVE」というサイトに対応いたしました。 #224

Open
wants to merge 27 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
96dbbc0
Merge branch 'release'
ryu-s Nov 16, 2021
1b95935
ニコ生の自分自身の情報の取得方法を修正
ryu-s Nov 22, 2021
082a06d
ニコ生のコミュニティの配信情報を取得するAPIの仕様変更に対応
ryu-s Nov 22, 2021
00f3e95
バージョン番号をインクリメント 0.6.14->0.6.15
ryu-s Nov 22, 2021
40c3b27
YouTubeLiveの絵文字を棒読みちゃんに読ませる際の挙動を以前の実装に近づけたつもり
ryu-s Nov 22, 2021
5ce6f28
バージョン番号をインクリメント 0.6.15->0.6.16
ryu-s Nov 22, 2021
57164e7
Merge branch 'develop'
ryu-s Dec 12, 2021
172884f
Merge branch 'release'
ryu-s Feb 2, 2022
3640947
Merge branch 'release'
ryu-s May 3, 2022
dd06171
Merge branch 'release'
ryu-s Jun 26, 2022
55fc102
Merge branch 'release'
ryu-s Dec 7, 2022
dd00c24
Merge branch 'release'
ryu-s Feb 1, 2023
feaa8c3
Merge branch 'release'
ryu-s Feb 2, 2023
1b6661d
Merge branch 'release'
ryu-s Feb 15, 2023
665dd32
Merge branch 'release'
ryu-s Feb 24, 2023
3206e79
Merge branch 'release'
ryu-s Mar 6, 2023
22d08ee
Merge branch 'release'
ryu-s May 18, 2023
fcdec0b
Merge branch 'release'
ryu-s Jul 29, 2023
dfac771
Merge branch 'release'
ryu-s Sep 9, 2023
0518633
Merge branch 'release'
ryu-s Sep 10, 2023
b5e497f
OpenrecからBLiveにコピー
suzaku001 Sep 13, 2024
c508ace
WebSocketでコメントを受信できるように変更
suzaku001 Oct 20, 2024
13dfd41
B-LIVEの棒読みちゃん連携を追加
suzaku001 Oct 20, 2024
bcfa764
ブラックリスト周りの機能を削除
suzaku001 Oct 21, 2024
ffee7a8
コメント投稿のロジックを削除
suzaku001 Oct 21, 2024
9284c72
未使用コードの削除
suzaku001 Oct 21, 2024
9512548
オプションで不要な項目を削除
suzaku001 Oct 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions BLiveIF/BLiveIF.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net462</TargetFramework>
<LangVersion>8.0</LangVersion>
<Configurations>Release;Beta;Alpha;Debug</Configurations>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<WarningLevel>4</WarningLevel>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Beta|AnyCPU'">
<OutputPath>bin\Beta\</OutputPath>
<DefineConstants>TRACE;BETA</DefineConstants>
<WarningLevel>4</WarningLevel>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Alpha|AnyCPU'">
<DefineConstants>TRACE;DEBUG;ALPHA</DefineConstants>
<WarningLevel>4</WarningLevel>
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>DEBUG;TRACE</DefineConstants>
<WarningLevel>4</WarningLevel>
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\ISitePlugin\SitePlugin.csproj" />
</ItemGroup>
</Project>
70 changes: 70 additions & 0 deletions BLiveIF/Message.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using SitePlugin;
using System;
using System.Collections.Generic;

namespace BLiveSitePlugin
{
public enum BLiveMessageType
{
Unknown,
Comment,
//Item,
Stamp,
Yell,
Connected,
Disconnected,
}


public interface IBLiveMessage : ISiteMessage
{
BLiveMessageType BLiveMessageType { get; }
}
public interface IBLiveConnected : IBLiveMessage
{
string Text { get; }
}
public interface IBLiveDisconnected : IBLiveMessage
{
string Text { get; }
}
public interface IBLiveComment : IBLiveMessage
{
IEnumerable<IMessagePart> NameItems { get; }
IEnumerable<IMessagePart> MessageItems { get; }
string Id { get; }
DateTime PostTime { get; }
string UserId { get; }
}
public interface IBLiveStamp : IBLiveMessage
{
IMessageImage Stamp { get; }
string Message { get; }
IEnumerable<IMessagePart> NameItems { get; set; }
IMessageImage UserIcon { get; }
DateTime PostTime { get; }
string Id { get; }
}
public interface IBLiveYell : IBLiveMessage
{
string YellPoints { get; }
string Message { get; }
IEnumerable<IMessagePart> NameItems { get; }
IMessageImage UserIcon { get; }
DateTime PostTime { get; }
string Id { get; }
}
//public interface IBLiveItem : IBLiveMessage
//{
// string ItemName { get; }
// int ItemCount { get; }
// //string Comment { get; }
// long Id { get; }
// //string UserName { get; }
// string UserPath { get; }
// long UserId { get; }
// string AccountName { get; }
// long PostedAt { get; }
// string UserIconUrl { get; }
//}
}
1 change: 1 addition & 0 deletions BLiveIF/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

135 changes: 135 additions & 0 deletions BLiveSitePlugin/API.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
using Codeplex.Data;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace BLiveSitePlugin.Low.BanList
{
public class Item
{
public string banned_user_id { get; set; }
}

public class Data
{
public List<Item> items { get; set; }
}

public class RootObject
{
public int status { get; set; }
public Data data { get; set; }
}
}
namespace BLiveSitePlugin
{
class Me
{
public string DisplayName { get; set; }
public string UserId { get; set; }
}
static class API
{
public static async Task<Me> GetMeAsync(IDataSource server, CookieContainer cc)
{
var me = new Me();
var url = "https://live.carol-i.com";
var res = await server.GetAsync(url, cc);
var match0 = Regex.Match(res, "<div class=\"name\">([^<]*)</div>");
if (match0.Success)
{
var displayName = match0.Groups[1].Value;
me.DisplayName = displayName;
}
var match1 = Regex.Match(res, "<div class=\"name\">([^<]*)</div>");
if (match1.Success)
{
me.UserId = match1.Groups[1].Value;
}
return me;
}
public static async Task<MovieInfo> GetMovieInfo(IDataSource dataSource, string liveId, CookieContainer cc)
{
//https://public.blive.tv/external/api/v5/movies/pC8n3HQX5gh
var url = "https://public.blive.tv/external/api/v5/movies/" + liveId;
var ret = await dataSource.GetAsync(url, cc);
var obj = Tools.Deserialize<Low.External.Movies.RootObject>(ret);
return new MovieInfo(obj);
}
public static async Task<Low.External.Movies.RootObject[]> GetChannelMovies(IDataSource dataSource, string channelId)
{
//https://public.blive.tv/external/api/v5/movies?channel_id=rainbow6jp
var url = "https://public.blive.tv/external/api/v5/movies?channel_id=" + channelId;
var ret = await dataSource.GetAsync(url);
var obj = Tools.Deserialize<Low.External.Movies.RootObject[]>(ret);
return obj;
}
public static async Task<Low.Movies.RootObject[]> GetMovies(IDataSource dataSource, string channelId)
{
var url = $"https://public.blive.tv/external/api/v5/movies?channel_id={channelId}&sort=onair_status";
var res = await dataSource.GetAsync(url);
var obj = Tools.Deserialize<Low.Movies.RootObject[]>(res);
return obj;
}
public static async Task<(Low.Chats.RootObject[], string raw)> GetChats(IDataSource dataSource, string liveId, DateTime toCreatedAt, CookieContainer cc)
{
//https://public.blive.tv/external/api/v5/movies/9PgmVnlqtMz/chats?to_created_at=2018-07-24T19:32:50.395Z
var url = "https://public.blive.tv/external/api/v5/movies/" + liveId + "/chats?to_created_at=" + toCreatedAt.ToString("yyyy-MM-ddTHH:mm:ss.fffZ");
var res = await dataSource.GetAsync(url, cc);
var obj = Tools.Deserialize<Low.Chats.RootObject[]>(res);
return (obj, res);
}
}
}
namespace BLiveSitePlugin.Low
{
public class WebsocketContext2
{
public string sid { get; set; }
public List<string> upgrades { get; set; }
public int pingInterval { get; set; }
public int pingTimeout { get; set; }
}
public class Item
{
public string user_id { get; set; }
public string user_name { get; set; }
public string user_type { get; set; }
public string user_key { get; set; }
public int user_rank { get; set; }
public string user_icon { get; set; }
public string room_id { get; set; }
public string chat_id { get; set; }
public string message { get; set; }
public string item { get; set; }
public int supporter_rank { get; set; }
public int is_creaters { get; set; }
public string golds { get; set; }
public string cre_dt { get; set; }
public int is_fresh { get; set; }
public int is_warned { get; set; }
public int has_banned_word { get; set; }
public int is_moderator { get; set; }
public int is_premium { get; set; }
public int is_premium_hidden { get; set; }
public string user_color { get; set; }
public string display_dt { get; set; }
public string del_flg { get; set; }
public string quality_type { get; set; }
}
public class Data
{
public List<Item> items { get; set; }
}

public class ChatList
{
public int status { get; set; }
public Data data { get; set; }
}
}
23 changes: 23 additions & 0 deletions BLiveSitePlugin/BLiveCommentData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using SitePlugin;

namespace BLiveSitePlugin
{
class BLiveCommentData : IBLiveCommentData
{
public bool IsYell => !string.IsNullOrEmpty(YellPoints);
public string YellPoints { get; set; }
public string Message { get; set; }
public string Id { get; set; }
public string UserId { get; set; }
public DateTime PostTime { get; set; }
public string UserKey { get; set; }
public string UserType { get; set; }
public IMessageImage Stamp { get; set; }
public string Name { get; set; }
public List<IMessagePart> NameIcons { get; set; }
public TimeSpan Elapsed { get; set; }
public string UserIconUrl { get; set; }
}
}
111 changes: 111 additions & 0 deletions BLiveSitePlugin/BLiveCommentViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Common;
using SitePlugin;

namespace BLiveSitePlugin
{
public interface IBLiveCommentViewModel : ICommentViewModel
{
string PostDate { get; }
string Elapsed { get; }
bool IsStamp { get; }
bool IsYell { get; }
}
class BLiveCommentViewModel : CommentViewModelBase, IBLiveCommentViewModel
{
public override MessageType MessageType { get; protected set; }
private ICommentOptions _options;
private readonly IBLiveSiteOptions _siteOptions;

public string PostDate { get; }
public string Elapsed { get; }
public override string UserId { get; }
public bool IsStamp { get; }
public bool IsYell { get; }
public BLiveCommentViewModel(IBLiveCommentData commentData, ICommentOptions options, IBLiveSiteOptions siteOptions, ICommentProvider commentProvider, bool isFirstComment, IUser user)
: base(options, user, commentProvider, isFirstComment)
{
MessageType = MessageType.Comment;
_options = options;
_siteOptions = siteOptions;
UserId = commentData.UserId;
Id = commentData.Id;
PostDate = commentData.PostTime.ToString("HH:mm:ss");
var elapsed = commentData.Elapsed;
Elapsed = Tools.ElapsedToString(elapsed);
IsStamp = commentData.Stamp != null;
IsYell = commentData.IsYell;
if (!string.IsNullOrEmpty(commentData.UserIconUrl))
{
Thumbnail = new MessageImage { Url = commentData.UserIconUrl };
}
if (siteOptions.IsAutoSetNickname)
{
var nick = ExtractNickname(commentData.Message);
if (!string.IsNullOrEmpty(nick))
{
user.Nickname = nick;
}
}
//Name
{
var nameItems = new List<IMessagePart>();
nameItems.Add(MessagePartFactory.CreateMessageText(commentData.Name));
nameItems.AddRange(commentData.NameIcons);
NameItemsInternal = nameItems;
}
//Message
{
var messageItems = new List<IMessagePart>();
if (commentData.IsYell)
{
MessageType = MessageType.BroadcastInfo;
messageItems.Add(MessagePartFactory.CreateMessageText("エールポイント:" + commentData.YellPoints + Environment.NewLine));
}
messageItems.Add(MessagePartFactory.CreateMessageText(commentData.Message));
if (commentData.Stamp != null)
{
MessageType = MessageType.BroadcastInfo;
messageItems.Add(commentData.Stamp);
}
MessageItems = messageItems;
}
Init();
}
protected virtual void PlaySound(string filePath)
{
var player = new System.Media.SoundPlayer(filePath);
player.Play();
}
public override async Task AfterCommentAdded()
{
await Task.Yield();
try
{
if (IsStamp)
{
if (_siteOptions.IsPlayStampMusic && !string.IsNullOrEmpty(_siteOptions.StampMusicFilePath))
{
PlaySound(_siteOptions.StampMusicFilePath);
}
}
if (IsYell)
{
if (_siteOptions.IsPlayYellMusic && !string.IsNullOrEmpty(_siteOptions.YellMusicFilePath))
{
PlaySound(_siteOptions.YellMusicFilePath);
}
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
}
}
Loading