3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ニコニコチャンネルツールの生放送周りのAPIメモ

Posted at

チャンネルツールが使える人なんて一部だと思うのですがせっかく解析というか確認したので共有してみます。ちなみにNECOSenで使用しています。怒られたら消します。

各APIは該当するチャンネルの管理者権限がなければ取得することが出来ません。たぶん。
なので本当にほとんどの人には関係のないものです。気をつけてネ。

汎用的なもの

ベースURL: https://public.api.nicovideo.jp/v1/channel/channeltool/channels/{channelId}
{channelId} はチャンネルIDの数字のみ

チャンネルの情報の取得

GET .json

{
  "meta": {
    "status": 200
  },
  "data": {
    "channel": {
      "id": 2631252,
      "name": "NECOSen 東方",
      "description": "24時間好きな動画をリクエストして楽しみながら、コメントでコミュニケーションを取ったり、災害が発生した際に防災情報をすぐに確認することが出来るチャンネルです。",
      "isFree": false,
      "screenName": "neco-sen",
      "ownerName": "株式会社Gletec",
      "price": 324,
      "bodyPrice": 300,
      "url": "https://ch.nicovideo.jp/neco-sen",
      "thumbnailUrl": "https://secure-dcdn.cdn.nimg.jp/comch/channel-icon/128x128/ch2631252.jpg?1495308001",
      "thumbnailSmallUrl": "https://secure-dcdn.cdn.nimg.jp/comch/channel-icon/64x64/ch2631252.jpg?1495308001",
      "canAdmit": true,
      "isAdult": false,
      "isOpen": true,
      "detail": {
        "isPublic": true,
        "isHidden": false,
        "category": {
          "id": 13,
          "name": "音楽"
        },
        "openTime": "2017-08-07T13:00:00+09:00",
        "closeTime": null,
        "isPermittedCreationOfPpv": true,
        "blomagaChannelType": "BLOMAGA_CHANNEL",
        "mangaChannelType": "NON_MANGA_CHANNEL",
        "matomeBlogChannelType": "NON_MATOME_BLOG_CHANNEL",
        "createTime": "2017-04-24T11:32:54+09:00",
        "updateTime": "2017-05-21T04:20:01+09:00"
      }
    }
  }
}

GetPlayerStatus感パネェ…

チャンネルのペナルティ情報の取得

GET /penalty/lives/status.json

{
  "meta": {
    "status": 200
  },
  "data": {
    "channel": {
      "channelId": 2631252,
      "contentsPenaltyLevel": 0
    }
  }
}

生放送周り

おそらく現状httpsに対応していません。

必須のHeader

生放送周りのAPIは x-niconico-session にCookieでおなじみの user_session が必要です。たぶん。

生放送枠の取得

GET http://channel.live2.nicovideo.jp/channel/api/v1/programs

GETパラメタ

名前 値例 説明
channelId ch2631252 チャンネルID。chを含む
year_month 201907 年月の指定(yyyyMM)
time_type future 取得する生放送の種類
future: これから放送
past: 過去の放送
present: 現在放送中
offset 0 オフセット
limit 0 取得制限、0使用可
order_asc true 昇順ソートを行うかどうか
(時間順にソートするか)

レスポンス例

用意するのが面倒だったのでデシリアライズ用のC#のコードをどうぞ


	public class ChannelPrograms
	{
		[JsonPropertyName("meta")]
		public NicoApiMeta Meta { get; set; }

		[JsonPropertyName("data")]
		public ChannelProgramsData Data { get; set; }
	}

	public class ChannelProgramsData
	{
		[JsonPropertyName("list")]
		public ChannelProgram[] List { get; set; }

		[JsonPropertyName("total")]
		public int? Total { get; set; }
	}

	public class ChannelProgram
	{
		[JsonPropertyName("id")]
		public string Id { get; set; }

		[JsonPropertyName("title")]
		public string Title { get; set; }

		[JsonPropertyName("beginTime")]
		public DateTime BeginTime { get; set; }

		[JsonPropertyName("endTime")]
		public DateTime EndTime { get; set; }

		[JsonPropertyName("thumbnailUrl")]
		public string ThumbnailUrl { get; set; }

		[JsonPropertyName("isThumbnailResizable")]
		public bool IsThumbnailResizable { get; set; }

		[JsonPropertyName("isMemberOnly")]
		public bool IsMemberOnly { get; set; }

		[JsonPropertyName("isPayProgram")]
		public bool IsPayProgram { get; set; }

		[JsonPropertyName("isTimeshiftEnabled")]
		public bool IsTimeshiftEnabled { get; set; }

		[JsonPropertyName("trialWatch")]
		public object TrialWatch { get; set; }
	}

NicoApiMeta は上にもある meta と同じです。

ニコ生のメンテナンス情報を取得する

GET http://channel.live2.nicovideo.jp/channel/api/v1/channels/{channelId}/maintenances
{channelId} はチャンネルID。 chを含みます

レスポンス例

{
  "meta": {
    "status": 200,
    "errorCode": "OK"
  },
  "data": [
    {
      "beginTime": "2019-09-10T01:30:00+09:00",
      "endTime": "2019-09-10T08:30:00+09:00"
    }, {
      "beginTime": "2019-09-18T06:00:00+09:00",
      "endTime": "2019-09-18T08:30:00+09:00"
    }
  ]
}

枠を取得する

POST http://channel.live2.nicovideo.jp/channel/api/v1/programs

コンテンツ(Json)

こちらも用意するのが面倒だったのでC#のシリアライズ用のクラスをどうぞ。

	public class RegistrationProgram
	{
		/// <summary>
		/// タイトル
		/// </summary>
		[JsonPropertyName("title")]
		public string Title { get; set; }

		/// <summary>
		/// 番組説明文
		/// </summary>
		[JsonPropertyName("description")]
		public string Description { get; set; }

		/// <summary>
		/// サムネイルへのURL 必ずドワンゴのCDNへのURLではなければならない
		/// </summary>
		[JsonPropertyName("thumbnailUrl")]
		public string ThumbnailUrl { get; set; }

		/// <summary>
		/// カテゴリ
		/// </summary>
		[JsonPropertyName("category")]
		public string Category { get; set; }

		/// <summary>
		/// タグ
		/// </summary>
		[JsonPropertyName("tags")]
		public Tag[] Tags { get; set; }

		/// <summary>
		/// オーナー以外がタグを編集できないようにするか
		/// </summary>
		[JsonPropertyName("isTagOwnerLock")]
		public bool IsTagOwnerLock { get; set; }

		/// <summary>
		/// 日本国内限定放送にするか
		/// </summary>
		[JsonPropertyName("isDomesticOnly")]
		public bool IsDomesticOnly { get; set; }

		/// <summary>
		/// ニコニ広告
		/// </summary>
		[JsonPropertyName("isUadEnabled")]
		public bool IsUadEnabled { get; set; }

		/// <summary>
		/// 市場
		/// </summary>
		[JsonPropertyName("isIchibaEnabled")]
		public bool IsIchibaEnabled { get; set; }

		/// <summary>
		/// クオリティ
		/// <para><code>6Mbps720p</code> とか</para>
		/// </summary>
		[JsonPropertyName("maxQuality")]
		public string MaxQuality { get; set; }

		/// <summary>
		/// JASRAC許諾なんちゃら
		/// </summary>
		[JsonPropertyName("rightsItems")]
		public object[] RightsItems { get; set; }

		/// <summary>
		/// 会員限定?
		/// </summary>
		[JsonPropertyName("isMemberOnly")]
		public bool IsMemberOnly { get; set; }

		/// <summary>
		/// 配信の長さ おそらく30分刻み
		/// </summary>
		[JsonPropertyName("durationMinutes")]
		public int DurationMinutes { get; set; }

		/// <summary>
		/// 予約の開始時間
		/// </summary>
		[JsonPropertyName("reservationBeginTime")]
		public DateTime ReservationBeginTime { get; set; }

		/// <summary>
		/// タイムシフト
		/// </summary>
		[JsonPropertyName("isTimeshiftEnabled")]
		public bool IsTimeshiftEnabled { get; set; }

		/// <summary>
		/// クリエイターなんちゃらかんちゃら
		/// </summary>
		[JsonPropertyName("isPayProgram")]
		public bool IsPayProgram { get; set; }

		/// <summary>
		/// 配信者しか配信を見れなくする??
		/// </summary>
		[JsonPropertyName("isPublisherOnly")]
		public bool IsPublisherOnly { get; set; }

		/// <summary>
		/// チャンネルID
		/// </summary>
		[JsonPropertyName("channelId")]
		public string ChannelId { get; set; }
	}

	public class Tag
	{
		/// <summary>
		/// タグ名
		/// </summary>
		[JsonPropertyName("label")]
		public string Label { get; set; }

		/// <summary>
		/// タグロック
		/// </summary>
		[JsonPropertyName("isLocked")]
		public bool IsLocked { get; set; }
	}

画像のURLは過去の生放送のサムネイルのURLとか使うと通ります。
どういうシステムなんだろう…。

レスポンス例

{
  "meta": {
    "status": 201,
    "errorCode": "CREATED"
  },
  "data": {
    "id": "lv番号"
  }
}

lv番号 の部分には作成された枠のIDが入ります。

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?