Table of Contents

Class Spaces

Namespace
Twikit.Spaces
Assembly
Twikit.dll

X スペースのすべての操作の入り口(Spaces)。

public sealed class Spaces
Inheritance
Spaces
Inherited Members

Remarks

メタデータ / 検索 — GraphQL(AudioSpaceById、AudioSpaceSearch、BrowseSpaceTopics、...)。 ブロードキャストのライフサイクル — proxsee.pscp.tv(Periscope)v2 API。 コントロールプレーン(ミュート、設定、終了、承認 ...)— guest-cf.pscp.tv /api/v1(chatman)。 チャット — proxsee accessChat → chatapi v1(HTTP 履歴 + WebSocket)。 音声(発言・聴取)— Janus WebRTC videoroom。ピア接続は IPeerConnectionFactory の実装が必要です。

API キーは不要で、twikit の他の機能と同じ Cookie 認証のセッションを使います。

Constructors

Spaces(Client)

public Spaces(Client client)

Parameters

client Client

Properties

Chatman

chatman コントロールプレーン。

public ChatmanApi Chatman { get; }

Property Value

ChatmanApi

Proxsee

Periscope(proxsee)API。

public ProxseeApi Proxsee { get; }

Property Value

ProxseeApi

Methods

AddAdminAsync(string, string)

参加者を共同ホストにします。

public Task<JsonObject> AddAdminAsync(string spaceId, string userId)

Parameters

spaceId string
userId string

Returns

Task<JsonObject>

AddSharingAsync(string, string)

スペースにツイートを共有します。

public Task AddSharingAsync(string spaceId, string tweetId)

Parameters

spaceId string
tweetId string

Returns

Task

ApproveAsync(string, string?)

発言リクエストを承認します。spaceId を渡すと chatman の初期化も行います。

public Task ApproveAsync(string sessionUuid, string? spaceId = null)

Parameters

sessionUuid string
spaceId string

Returns

Task

AssociateTweetWithBroadcastAsync(string, string, bool)

ツイートをブロードキャストに関連付けます(proxsee associateTweetWithBroadcast)。

public Task<JsonObject> AssociateTweetWithBroadcastAsync(string spaceId, string tweetId, bool tweetExternal = false)

Parameters

spaceId string
tweetId string
tweetExternal bool

Returns

Task<JsonObject>

CancelScheduledSpaceAsync(string)

public Task CancelScheduledSpaceAsync(string broadcastId)

Parameters

broadcastId string

Returns

Task

CancelSpeakerRequestAsync(string, string)

保留中の発言リクエストを取り下げます。

public Task<JsonObject> CancelSpeakerRequestAsync(string spaceId, string sessionUuid)

Parameters

spaceId string
sessionUuid string

Returns

Task<JsonObject>

ChatAsync(string)

public Task<SpaceChat> ChatAsync(string spaceId)

Parameters

spaceId string

Returns

Task<SpaceChat>

ChatAsync(Space)

スペースのチャットセッション(履歴 + 任意の WebSocket)を取得します。

public Task<SpaceChat> ChatAsync(Space space)

Parameters

space Space

Returns

Task<SpaceChat>

Close()

内部の HTTP クライアントを閉じます。

public void Close()

CreateSpaceAsync(string, string, JsonArray?, int, int, bool, bool, long, JsonArray?, string, JsonObject?, bool, JsonObject?)

スペースを作成します。proxsee の createBroadcast レスポンス(broadcast.id、access_token、room_id、 stream_name、credential、webrtc_gw_url など)を返します。

public Task<JsonObject> CreateSpaceAsync(string title = "", string description = "", JsonArray? topics = null, int conversationControls = 2, int narrowCastSpaceType = 0, bool isSpaceAvailableForReplay = false, bool isSpaceAvailableForClipping = false, long scheduledStartTime = 0, JsonArray? languages = null, string region = "us-west-1", JsonObject? extraMetadata = null, bool autoPublish = true, JsonObject? publishExtra = null)

Parameters

title string

タイトル。

description string

説明。

topics JsonArray

トピック。

conversationControls int

発言できる相手(0=リクエスト/承認、1=フォロー中、2=全員)。

narrowCastSpaceType int

0=全員、1=従業員、2=サブスクライバー。

isSpaceAvailableForReplay bool

リプレイを残すか。

isSpaceAvailableForClipping bool

クリップを許可するか。

scheduledStartTime long

予約開始時刻(エポックミリ秒。10^12 未満は秒として扱い変換します)。

languages JsonArray

言語。

region string

リージョン。

extraMetadata JsonObject

追加のメタデータ。

autoPublish bool

作成後すぐに公開するか。

publishExtra JsonObject

publishBroadcast に追加するペイロード。

Returns

Task<JsonObject>

DeleteSharingAsync(string, string)

スペースからツイートの共有を削除します。

public Task DeleteSharingAsync(string spaceId, string sharingId)

Parameters

spaceId string
sharingId string

Returns

Task

EndSpaceAsync(string)

スペースを終了します。chatman で audiospace を終了し、proxsee でブロードキャストを落とします。 spaceId は proxsee の broadcast id(create_space の戻り値)または X のスペース ID。

public Task EndSpaceAsync(string spaceId)

Parameters

spaceId string

Returns

Task

GetCallStatusAsync(string)

call/status のスナップショット(guest_sessions、states、...)を取得します。

public Task<JsonObject> GetCallStatusAsync(string spaceId)

Parameters

spaceId string

Returns

Task<JsonObject>

GetScheduledSpacesAsync()

予約済みのスペースを一覧します(各要素は broadcast 情報: id、state='NOT_STARTED'、scheduled_start、media_key、...)。

public Task<List<JsonObject>> GetScheduledSpacesAsync()

Returns

Task<List<JsonObject>>

GetSpaceAsync(string, bool, bool)

13 文字の ID(または URL 全体)でスペースのメタデータを取得します。

public Task<Space> GetSpaceAsync(string spaceId, bool withReplays = true, bool withListeners = true)

Parameters

spaceId string
withReplays bool
withListeners bool

Returns

Task<Space>

GetSpaceByUrlAsync(string, bool, bool)

public Task<Space> GetSpaceByUrlAsync(string url, bool withReplays = true, bool withListeners = true)

Parameters

url string
withReplays bool
withListeners bool

Returns

Task<Space>

GetStreamAsync(string)

media_key からストリーム情報(HLS URL とチャットトークン)を取得します。

public Task<SpaceStream> GetStreamAsync(string mediaKey)

Parameters

mediaKey string

Returns

Task<SpaceStream>

HostAsync(JsonObject, object, IPeerConnectionFactory, IReadOnlyList<IceServer>?, JsonObject?)

public Task<SpaceVoiceSession> HostAsync(JsonObject created, object audioTrack, IPeerConnectionFactory peerConnectionFactory, IReadOnlyList<IceServer>? iceServers = null, JsonObject? publishExtra = null)

Parameters

created JsonObject

CreateSpaceAsync(string, string, JsonArray?, int, int, bool, bool, long, JsonArray?, string, JsonObject?, bool, JsonObject?) の戻り値。

audioTrack object

送信する音声トラック。

peerConnectionFactory IPeerConnectionFactory

ピア接続のファクトリ。

iceServers IReadOnlyList<IceServer>

ICE サーバー。

publishExtra JsonObject

publishBroadcast に追加するペイロード。

Returns

Task<SpaceVoiceSession>

JoinAsync(string, bool, bool, bool)

public Task<JsonObject> JoinAsync(string spaceId, bool asSpeaker = false, bool joinAsAdmin = false, bool shouldAutoJoin = true)

Parameters

spaceId string
asSpeaker bool
joinAsAdmin bool
shouldAutoJoin bool

Returns

Task<JsonObject>

JoinAsync(Space, bool, bool, bool)

スピーカーまたはリスナーとしてスペースに参加します。chatman audiospace/join の {session_uuid, can_auto_join, ...} を返します。

public Task<JsonObject> JoinAsync(Space space, bool asSpeaker = false, bool joinAsAdmin = false, bool shouldAutoJoin = true)

Parameters

space Space
asSpeaker bool
joinAsAdmin bool
shouldAutoJoin bool

Returns

Task<JsonObject>

ListenAsync(Space, IPeerConnectionFactory, Action<object>?, IReadOnlyList<IceServer>?, int)

リスナーとして参加し、WebRTC の受信セッションを開きます(IPeerConnectionFactory が必要)。 より簡単に聴くには StreamUrlAsync(Space) の HLS URL を ffmpeg などで再生してください。

public Task<SpaceVoiceSession> ListenAsync(Space space, IPeerConnectionFactory peerConnectionFactory, Action<object>? onAudioTrack = null, IReadOnlyList<IceServer>? iceServers = null, int attempts = 3)

Parameters

space Space
peerConnectionFactory IPeerConnectionFactory
onAudioTrack Action<object>
iceServers IReadOnlyList<IceServer>
attempts int

Returns

Task<SpaceVoiceSession>

LowerHandAsync(string, string)

public Task<JsonObject> LowerHandAsync(string spaceId, string sessionUuid)

Parameters

spaceId string
sessionUuid string

Returns

Task<JsonObject>

MuteSpaceAsync(string)

スペース全体をミュートします(ホストのみ)。

public Task<JsonObject> MuteSpaceAsync(string spaceId)

Parameters

spaceId string

Returns

Task<JsonObject>

MuteSpeakerAsync(string, string)

public Task<JsonObject> MuteSpeakerAsync(string spaceId, string sessionUuid)

Parameters

spaceId string
sessionUuid string

Returns

Task<JsonObject>

RaiseHandAsync(string, string)

public Task<JsonObject> RaiseHandAsync(string spaceId, string sessionUuid)

Parameters

spaceId string
sessionUuid string

Returns

Task<JsonObject>

RejectAsync(string, string?)

発言リクエストを却下します。

public Task RejectAsync(string sessionUuid, string? spaceId = null)

Parameters

sessionUuid string
spaceId string

Returns

Task

RemoveAdminAsync(string, string, string)

共同ホストを通常の参加者に戻します。

public Task<JsonObject> RemoveAdminAsync(string spaceId, string userId, string sessionUuid = "")

Parameters

spaceId string
userId string
sessionUuid string

Returns

Task<JsonObject>

RemoveParticipantAsync(string, IEnumerable<string>)

public Task<JsonObject> RemoveParticipantAsync(string spaceId, IEnumerable<string> userIds)

Parameters

spaceId string
userIds IEnumerable<string>

Returns

Task<JsonObject>

RequestToSpeakAsync(string)

public Task<string> RequestToSpeakAsync(string spaceId)

Parameters

spaceId string

Returns

Task<string>

RequestToSpeakAsync(Space)

リスナーとして参加したスペースで発言をリクエストします。ホストが ApproveAsync(string, string?) で承認する session_uuid を返します。

public Task<string> RequestToSpeakAsync(Space space)

Parameters

space Space

Returns

Task<string>

SearchAsync(string, string, bool)

スペースを検索します。filter は 'Top'、'Live'、'Upcoming'。 X の検索ペイロードには各スペースの rest_id しか無いため、既定では GetSpaceAsync(string, bool, bool) で 並列にメタデータを埋めます。ID だけでよければ hydrate を false に。

public Task<List<Space>> SearchAsync(string query, string filter = "Live", bool hydrate = true)

Parameters

query string
filter string
hydrate bool

Returns

Task<List<Space>>

SetSpaceSettingsAsync(string, int)

発言できる相手を変更します: 0=リクエスト/承認、1=フォロー中、2=全員。

public Task<JsonObject> SetSpaceSettingsAsync(string spaceId, int conversationControls)

Parameters

spaceId string
conversationControls int

Returns

Task<JsonObject>

SpeakAsync(Space, object, IPeerConnectionFactory, IReadOnlyList<IceServer>?, string?, bool, bool)

スピーカーとして参加し、WebRTC の publish セッションを開きます(IPeerConnectionFactory が必要)。

public Task<SpaceVoiceSession> SpeakAsync(Space space, object audioTrack, IPeerConnectionFactory peerConnectionFactory, IReadOnlyList<IceServer>? iceServers = null, string? sessionUuid = null, bool joinAsAdmin = false, bool shouldAutoJoin = true)

Parameters

space Space

スペース。

audioTrack object

送信する音声トラック(実装固有のオブジェクト)。

peerConnectionFactory IPeerConnectionFactory

ピア接続のファクトリ。

iceServers IReadOnlyList<IceServer>

ICE サーバー。既定は直接接続(X の TURN は約 60 秒で切れるため)。

sessionUuid string

既存の chatman セッションを再利用する場合の UUID(挙手が承認された後など)。

joinAsAdmin bool

管理者として参加するか。

shouldAutoJoin bool

自動参加するか。

Returns

Task<SpaceVoiceSession>

StreamLiveChatAsync(Space, string?, string?, bool, CancellationToken)

Web クライアントの HTTP ストリーム(/live-chat)によるライブチャット。解析済みの JSON イベント (userId、controlType、...)を列挙します。WebSocket は不要です。 replay を true にすると終了したスペースのチャットログ(replay=1)を cursor でページ送りしながら返します。

public IAsyncEnumerable<JsonObject> StreamLiveChatAsync(Space space, string? sessionId = null, string? cursor = null, bool replay = false, CancellationToken cancellationToken = default)

Parameters

space Space
sessionId string
cursor string
replay bool
cancellationToken CancellationToken

Returns

IAsyncEnumerable<JsonObject>

StreamUrlAsync(Space)

ライブ / リプレイのスペースの HLS m3u8 URL。

public Task<string?> StreamUrlAsync(Space space)

Parameters

space Space

Returns

Task<string>

SubscribeScheduledAsync(string)

public Task SubscribeScheduledAsync(string spaceId)

Parameters

spaceId string

Returns

Task

TopicsAsync()

スペースのトピック一覧を取得します。

public Task<List<JsonObject>> TopicsAsync()

Returns

Task<List<JsonObject>>

UnmuteSpaceAsync(string)

スペース全体のミュートを解除します(ホストのみ)。

public Task<JsonObject> UnmuteSpaceAsync(string spaceId)

Parameters

spaceId string

Returns

Task<JsonObject>

UnmuteSpeakerAsync(string, string)

public Task<JsonObject> UnmuteSpeakerAsync(string spaceId, string sessionUuid)

Parameters

spaceId string
sessionUuid string

Returns

Task<JsonObject>

UnsubscribeScheduledAsync(string)

public Task UnsubscribeScheduledAsync(string spaceId)

Parameters

spaceId string

Returns

Task

WaitForSpeakerAsync(string, string, double, double)

call/status をポーリングし、セッションがスピーカーになる(ホストが承認する)まで待ちます。 タイムアウト時は null。

public Task<JsonObject?> WaitForSpeakerAsync(string spaceId, string sessionUuid, double timeoutSeconds = 120, double intervalSeconds = 3)

Parameters

spaceId string
sessionUuid string
timeoutSeconds double
intervalSeconds double

Returns

Task<JsonObject>