2012年5月12日土曜日

ニコニコ静画のお題と漫画のAPI



  1. お題の一覧取得

http://seiga.nicovideo.jp/theme/list/{カテゴリタイプ}/?page={ページ番号}&sort={ソート種別}

[カテゴリタイプ]
all:総合
genre_ent:エンターテイメント・ニュース・スポーツ・音楽
ent:エンターテイメント
news:ニュース
sports:スポーツ
music:音楽
genre_culture:アニメ・ゲーム・漫画
anime:アニメ
game:ゲーム
comic:漫画
genre_life:生活
animal:動物
cook:料理
vehicle:乗り物
view:風景
nature:自然
genre_other:描いてみた・モバイル・ニコニコ生放送・テスト・その他
draw:描いてみた
mobile:モバイル
live:ニコニコ生放送
test:テスト
other:その他
genre_adult:R-18ジャンル
r18:R-18

[ページ番号]
1から

[ソート種別]
comment_created:コメントの新しい順
comment_created_a:コメントの古い順
res_created:画像の新しい順
res_created_a:画像の古い順
theme_created:作成の新しい順
theme_created_a:作成の古い順
theme_mylist:マイリスト登録の多い順
theme_mylist_a:マイリスト登録の少ない順
theme_speed:勢いの速い順
theme_speed_a:勢いの遅い順
theme_view:再生数の多い順
theme_view_a:再生数の少ない順
res_count:画像投稿数の多い順
res_count_a:画像投稿数の少ない順
comment_count:コメントの多い順
comment_count_a:コメントの少ない順

ログイン不要です。
/bbs/sgxxxxx/を検出し、お題番号の抽出でいけると思います。
動画履歴が含まれているので、http://seiga.nicovideo.jp/my/historyから動画履歴情報を
取得して、除外するといいと思います。
動画履歴情報はCookieに関連付けられているので、Cookieのクリア後、取得のほうが
スマートですね。


  1. お題情報取得


http://seiga.nicovideo.jp/api/theme/info?id={静画番号}

[静画番号]
静画番号の数値の部分だけです。
sg11111なら11111ですね。

レスポンスは下記のような感じ
<?xml version="1.0" encoding="UTF-8"?>
<response>
<theme>
<id>33674</id>
<title>第七回MMD静止画選手権 本選 第3投稿会場</title>
<res_count>56</res_count>
<comment_count>115</comment_count>
<view_count>1231</view_count>
<mylist_count>25</mylist_count>
<speed>57</speed>
<status>0</status>
<bgm_id />
<import_flag>0</import_flag>
<delete_flag>0</delete_flag>
<campaign_name />
<theme_type>0</theme_type>
<content />
<command>shita</command>
<created>2012-05-11 22:51:52</created>
<updated>2012-05-12 20:00:50</updated>
<image_id>2044438</image_id>
<tag_list>
<tag>
<target_id>33674</target_id>
<tag_id>6</tag_id>
<lock_status>1</lock_status>
<created>2009-11-14 15:08:07</created>
<updated>2009-11-14 15:08:07</updated>
<id>6</id>
<name>描いてみた</name>
<normalize>描イテミタ</normalize>
<normalize_tag_id>6</normalize_tag_id>
<manga_count>0</manga_count>
</tag>
<tag>
                         ・
                         ・
                         ・
</tag>
</tag_list>
<thumbnail_url>http://lohas.nicoseiga.jp/thumb/2044438s</thumbnail_url>
<image_count>56</image_count>
<description />
</theme>
</response>


  1. 静画一覧取得(お題)

http://seiga.nicovideo.jp/api/theme/data?theme%5Fid={静画番号}

[静画番号]
静画番号の数値の部分だけです。
sg11111なら11111ですね。

レスポンスは下記のような感じ
<?xml version="1.0" encoding="UTF-8"?>
<response>
<image_list>
<image>
<id>2044438</id>
<number>1</number>
<res_id>1092373</res_id>
<comment_count>3</comment_count>
<image_id>2044438</image_id>
<delete_flag>0</delete_flag>
<delete_type>0</delete_type>
<comment_id>9110019</comment_id>
<comment_user_id>1293397</comment_user_id>
<user_name />
<user_hash>d+moNaUJgaU4Hhqwv0Vy+8+xd6k</user_hash>
<anonymous_flag>1</anonymous_flag>
<content />
<command>shita</command>
<comment_number>1</comment_number>
<type>2</type>
<send_from>0</send_from>
<ip_address>180.2.40.154</ip_address>
<comment_delete_flag>0</comment_delete_flag>
<comment_status>0</comment_status>
</image>
<image>
                  ・
                  ・
                  ・
</image>
</image_list>
<comment_list>
<comment>
<comment_id>9110019</comment_id>
<id>9110019</id>
<image_id>2044438</image_id>
<res_id>1092373</res_id>
<content />
<command>shita</command>
<created>2012-05-11 22:51:52</created>
<frame>-1</frame>
<user_hash>d+moNaUJgaU4Hhqwv0Vy+8+xd6k</user_hash>
<anonymous_flag>1</anonymous_flag>
</comment>
<comment>
                  ・
                  ・
                  ・
</comment>
</comment_list>
</response>


  1. 漫画一覧取得

[総合]
http://seiga.nicovideo.jp/manga/list?page={ページ}&sort={ソート方法}
[カテゴリ指定]
http://seiga.nicovideo.jp/manga/list?page={ページ}&sort={ソート方法}&category={カテゴリ}
[公式]
http://seiga.nicovideo.jp/manga/list?page={ページ}&official=1&sort={ソート方法}

{ソート方法}
manga_updated:更新が新しい順
manga_updated_a:更新が古い順
manga_created:投稿が新しい順
manga_created_a:投稿が古い順
manga_view:再生数が多い順
manga_view_a:再生数が少ない順

{ページ}
1から

{カテゴリ}
shonen:少年マンガ
seinen:青年マンガ
shojo:少女マンガ
yonkoma:4コママンガ
other:その他マンガ
fan:ファンコミック

comic/29を取り出し、漫画番号(<-だと29)を取得したらいいと思います。


  1. 漫画のエピソード情報取得

http://seiga.nicovideo.jp/rss/manga/{漫画番号}

RSS形式です。

レスポンスは下記
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>真の勇者はしゃべらない - ニコニコ静画(漫画)</title>
    <link>http://seiga.nicovideo.jp/manga/613</link>
    <description><![CDATA[真の勇者はしゃべらない の更新情報です]]></description>
    <pubDate>Sat, 12 May 2012 21:10:24 +0900</pubDate>
    <language>ja</language>
    <copyright>(c) niwango, inc. All rights reserved.</copyright>
   
      <item>
        <title>真の勇者はしゃべらない 第1話「我輩は勇者である。台詞はもうない。」</title>
        <link>http://seiga.nicovideo.jp/watch/mg31432</link>
        <description><![CDATA[
          <p class="nicoseiga-thumbnail">
            <img src="http://lohas.nicoseiga.jp/thumb/1921262q" border="0" />
          </p>
          <p class="nicoseiga-description">魔王がいる世界。この世界では毎年くじによって勇者が決められる。
勇者になったものは一年間勇者として魔王を討伐しにいかなくてはならないのだが、今まで倒すことができなかった。
今年は少年が勇者に選ばれた。少年は魔王を倒すことができるのか?(一部編集しました)</p>
          <p class="nicoseiga-info"><small>
            <strong class="nico-info-date">2012年04月01日 17:58 投稿</strong>
          </small></p>
        ]]></description>
        <guid isPermaLink="false">efdf562ce2fb0ad460fd8e9d33e57f57</guid>
        <pubDate>Sun, 01 Apr 2012 17:58:38 +0900</pubDate>
      </item>
      <item>
       ・
       ・
       ・
      </item>
 
  </channel>
</rss>


  1. 静画一覧取得(漫画)

http://seiga.nicovideo.jp/api/theme/data?theme%5Fid={漫画番号}

[漫画番号]
漫画番号の数値の部分だけです。
mg11111なら11111ですね。


レスポンスは下記
<?xml version="1.0" encoding="UTF-8"?>
<response>
<image_count>53</image_count>
<image_list>
<image>
<id>1921156</id>
<se_id />
<bgm_id>3832</bgm_id>
<bgm_loop>0</bgm_loop>
<duration>80</duration>
<thread>2705</thread>
<leaf>4</leaf>
<width>2048</width>
<height>1536</height>
<cache_time />
<bgm_path>/sound/bgm/30132c/3832</bgm_path>
<balloon>
<image_id>1921156</image_id>
<x>490</x>
<y>6</y>
<w>128</w>
<h>225</h>
<is_auto>1</is_auto>
</balloon>
</image>
<image>
         ・
         ・
         ・
</image>
</image_list>
<comment_list>
<comment />
</comment_list>
<threads>
<thread>
<id>2705</id>
<url>http://msg01.seiga.nicovideo.jp:80/</url>
</thread>
</threads>
</response>


  1. 漫画コメント

http://msg01.seiga.nicovideo.jp/api/thread?thread={threadid}&version=20090904&res_from=-1000

[threadid]
静画一覧取得(漫画)で取得できるthread

レスポンスは下記
<packet>
<thread resultcode="0" thread="2705" last_res="84" ticket="0x17837480" revision="1" server_time="1336826321"/>
<leaf thread="2705" leaf="1" count="2"/>
<leaf thread="2705" leaf="3" count="2"/>



<leaf thread="2705" leaf="51" count="5"/>
<leaf thread="2705" leaf="52" count="6"/>
<view_counter video="0" id="mg31432"/>
<chat thread="2705" no="1" vpos="11437" date="1333271513" mail="184" user_id="lsjMy2AAWvZ2KrbFT6UlukxuFm0" anonymity="1" leaf="1">um</chat>
<chat thread="2705" no="2" vpos="67812" date="1333271543" mail="184" user_id="lsjMy2AAWvZ2KrbFT6UlukxuFm0" anonymity="1" leaf="11">BGMいいね</chat>



<chat thread="2705" no="83" vpos="269187" date="1336790348" mail="184" user_id="5q4BsOtcITXPdG3-ukLCGuvDaw0" anonymity="1" leaf="44">w</chat>
<chat thread="2705" no="84" vpos="295375" date="1336790365" mail="184" user_id="5q4BsOtcITXPdG3-ukLCGuvDaw0" anonymity="1" leaf="49">いやはなすがふつうだろ</chat>
</packet>

2012年5月5日土曜日

ニコニコ静画のAPI一覧

原宿版でしか使えないかもしれませんが、静画のAPIを調べてみました。
  1. タグ検索
タグ付け動画の連続再生時に使用するAPIが使えそうです。

http://seiga.nicovideo.jp/api/tagslide/data?page=[ページ数]&query=[タグ文字列]

[ページ数]は1からです。

レスポンスは下記です。


<response>

<image_count>838</image_count>

<image_list>

<image>

<id>2021276</id>

<user_id>769290</user_id>

<title>春に。</title>

<description>「みんな―――誰だって、綺麗に花を咲かせたがってるんです。」</description>

<comment_count>0</comment_count>

<view_count>12</view_count>

<clip_count>0</clip_count>

<source_name>Wさくら2.jpg</source_name>

<source_url/>

<category>1</category>

<genre>200</genre>

<category_tag_id>50</category_tag_id>

<image_type>1</image_type>

<illust_type>0</illust_type>

<anonymous_flag>0</anonymous_flag>

<public_status>0</public_status>

<inspection_status>1</inspection_status>

<mobile_flag>0</mobile_flag>

<delete_flag>0</delete_flag>

<delete_type>0</delete_type>

<summary/>

<cache_time/>

<last_info_updated/>

<last_comment_created/>

<last_clip_registered/>

<created>2012-05-04 18:08:32</created>

<updated>2012-05-04 21:42:14</updated>

<width>1280</width>

<height>1280</height>

<filesize>805260</filesize>

<hash>7cbc619b24b55af95575f7f47d4316e9cc2bee0c</hash>

<extension>jpeg</extension>

<animation_flag>0</animation_flag>

<last_replaced/>

<point_weight>100</point_weight>

<operation_adult_flag>0</operation_adult_flag>

<adult_level>0</adult_level>

<gro_level>0</gro_level>

<nickname>ふせ</nickname>
</image>

<image>
</image>
</image_list>

<comment_list>

<comment>

<comment_id>9002663</comment_id>

<id>9002663</id>

<image_id>2021008</image_id>

<res_id>0</res_id>

<content>あ~、いいっすね~</content>

<command/>

<created>2012-05-04 16:49:14</created>

<frame>-1</frame>

<user_hash>7HYVq9sRcLb/BmXJdZvDkMa7828</user_hash>

<anonymous_flag>1</anonymous_flag>
</comment>

<comment>



</comment>
</comment_list>
</response>

動画情報のほかにコメントも取得できますね。


  • ユーザID検索
http://seiga.nicovideo.jp/api/user/data?id=[ユーザID]

レスポンスはタグ検索と同じ

http://ext.seiga.nicovideo.jp/api/illust/blogparts?mode=user&key=[ユーザID]

レスポンスは下記。


<response>
<base_url>http://seiga.nicovideo.jp/</base_url>
<icon_url>http://seiga.nicovideo.jp/user/illust/10244556</icon_url>
<image_url>http://lohas.nicoseiga.jp/</image_url>
<image_list>
<image>
<id>2018397</id>
<cache_time/>
<title>自演その3</title>
<nickname>刃天</nickname>
</image>
<image>
</image>
</image_list>
</response>
  • 静画の画像データ
サムネイル
http://lohas.nicoseiga.jp/thumb/[動画番号]
http://lohas.nicoseiga.jp/img/[動画番号]

動画番号は頭の2文字の英字を除いた後ろの数字だけです。
末尾にそれぞれ下記のように文字をつけるとサイズを指定できます。
l : 大サイズ(800*600以下)
m : 中サイズ(320*240以下)
s : 小サイズ(96*72以下)

元動画
http://seiga.nicovideo.jp/image/source?id=[動画番号]

  • 新着RSS

  • 統計ベースの静画一覧
http://seiga.nicovideo.jp/illust/list/[下記参照]

image_created : 投稿の新しい順
image_created_a : 投稿の古い順
comment_created : コメントの新しい順
comment_created_a : コメントの古い順
clip_created : クリップ追加が新しい順
clip_created_a : クリップ追加が古い順
image_view : 閲覧数の多い順
image_view_a : 閲覧数の少ない順
comment_count : コメントの多い順
comment_count_a : コメントの少ない順
clip_count : クリップの多い順
clip_count_a : クリップの少ない順

取得されるのはHTMLベースですので、サムネイルのURL(http://lohas.nicoseiga.jp/thumb/[xxxxxxx]q?)を抽出すればいいと思います。

  • ランキング
http://ext.seiga.nicovideo.jp/api/illust/blogparts?mode=ranking&key=[①]%2c[②]

①期間

fresh : 新着
hourly : 毎時
daily : デイリー
weekly : 週間
monthly : 月間 
 total : 合計

②対象

all : カテゴリ合算
g_creation : 創作
original : オリジナル
portrait : 似顔絵
g_fanart : ファンアート
anime : アニメ
game : ゲーム
character : キャラクター
g_popular : 殿堂入り
toho : 東方
vocaloid : VOCALOID
r15 : R-15


  • 公開クリップ情報取得
http://ext.seiga.nicovideo.jp/api/illust/blogparts?mode=clip&key=[クリップ番号]


お題と漫画のほうはまた今度。。。