Skip to content

Instantly share code, notes, and snippets.

@aikatsukamen
Last active July 3, 2022 04:51
Show Gist options
  • Select an option

  • Save aikatsukamen/0f6a89c45a040c45c33186af091701d1 to your computer and use it in GitHub Desktop.

Select an option

Save aikatsukamen/0f6a89c45a040c45c33186af091701d1 to your computer and use it in GitHub Desktop.
Twitcastingのアーカイブからチャットを取得
var list = [];
var events = [];
(async()=>{
let f = -600;
let t = 0;
while(t < 10315) {
f += 600;
t += 600;
const res = await fetch(`https://twitcasting.tv/c:bn_pictures/userajax.php?c=history&m=721567705&f=${f}&t=${t}&format=json`);
const json = await res.json();
list.push(json);
events.push(...json.history.events);
console.log(json.history.events.length);
}
})();
@aikatsukamen
Copy link
Author

c=チャンネル名
m=動画ID
f=動画の現在時間
t=取得する先のmax時間。f-t<=600であること。

1リクエストごとにこんな感じのデータが取れる

{
    "status": "ok",
    "replayerParams": {
        "fetchIntervalSec": 300,
        "retryIntervalSec": 5,
        "retryLimit": 3,
        "traceBackLimit": 50,
        "traceBackDurationSec": 7200
    },
    "history": {
        "events": [
            {
                "comment": {
                    "type": "comment",
                    "id": 24173986817,
                    "message": "きたあああああああああああ ",
                    "createdAt": 1645262121000,
                    "author": {
                        "id": "aoi_panda",
                        "name": "あおぱん",
                        "screenName": "aoi_panda",
                        "profileImage": "https://imagegw02.twitcasting.tv/image3s/pbs.twimg.com/profile_images/3286954168/3e738ecbeb35ec05eb5e4acd87d80e20_normal.jpeg",
                        "grade": 1
                    }
                },
                "timeMillis": 11374,
                "ver": "1.0"
            },
            {
                "comment": {
                    "type": "comment",
                    "id": 24173987764,
                    "message": "待機",
                    "createdAt": 1645262128000,
                    "author": {
                        "id": "date_sn",
                        "name": "だて",
                        "screenName": "date_sn",
                        "profileImage": "https://imagegw02.twitcasting.tv/image3s/pbs.twimg.com/profile_images/1377455912185516032/rk0dlpGn_normal.jpg",
                        "grade": 0
                    }
                },
                "timeMillis": 18266,
                "ver": "1.0"
            },
            {
                "comment": {
                    "type": "comment",
                    "id": 24173987898,
                    "message": "おあああああああ",
                    "createdAt": 1645262129000,
                    "author": {
                        "id": "c:green0625",
                        "name": "みどり",
                        "screenName": "c:green0625",
                        "profileImage": "https://ssl.twitcasting.tv/img/twitcas_bigger_2.png",
                        "grade": 0
                    }
                },
                "timeMillis": 19210,
                "ver": "1.0"
            },
            {
                "comment": {
                    "type": "comment",
                    "id": 24173988587,
                    "message": "きたわね",
                    "createdAt": 1645262134000,
                    "author": {
                        "id": "p_lolo",
                        "name": "ぷろろー",
                        "screenName": "p_lolo",
                        "profileImage": "https://imagegw02.twitcasting.tv/image3s/pbs.twimg.com/profile_images/1356252703102431242/6FKSb_jS_normal.jpg",
                        "grade": 0
                    }
                },
                "timeMillis": 24022,
                "ver": "1.0"
            },
            {
                "gift": {
                    "id": "gift::1288537307",
                    "type": "gift",
                    "message": "ワクワクが止まんないっ!",
                    "item": {
                        "name": "アイカツスターズ!",
                        "image": "https://s01.twitcasting.tv/img/cp/item_anime_aikatsu2022.png",
                        "detailImage": "https://twitcasting.tv/img/stamp/stamp_aikatsu2022_0.png",
                        "effectCommand": "stampitem(\"/img/stamp/stamp_aikatsu2022_0.png\",1,3000,\"https://imagegw02.twitcasting.tv/image3s/pbs.twimg.com/profile_images/1138810241527631878/b7r6E0gR_normal.png\")",
                        "showsSenderInfo": true
                    },
                    "sender": {
                        "id": "hashidam",
                        "name": "ハシダム",
                        "screenName": "HASHIDAM",
                        "profileImage": "https://imagegw02.twitcasting.tv/image3s/pbs.twimg.com/profile_images/1138810241527631878/b7r6E0gR_normal.png",
                        "grade": 0
                    },
                    "createdAt": 25200
                },
                "timeMillis": 25200,
                "ver": "1.0"
            },
            {
                "comment": {
                    "type": "comment",
                    "id": 24173989034,
                    "message": "待機",
                    "createdAt": 1645262137000,
                    "author": {
                        "id": "minasuyo",
                        "name": "すーなん🎩",
                        "screenName": "minasuyo",
                        "profileImage": "https://imagegw02.twitcasting.tv/image3s/pbs.twimg.com/profile_images/1386224936595857408/cpVpszwB_normal.jpg",
                        "grade": 0
                    }
                },
                "timeMillis": 27048,
                "ver": "1.0"
            },
            {
                "comment": {
                    "type": "comment",
                    "id": 24173989303,
                    "message": "アイカツ!",
                    "createdAt": 1645262139000,
                    "author": {
                        "id": "kom59150716",
                        "name": "コム",
                        "screenName": "Kom59150716",
                        "profileImage": "https://imagegw02.twitcasting.tv/image3s/pbs.twimg.com/profile_images/1363472384750100484/I9o7zri__normal.jpg",
                        "grade": 0
                    }
                },
                "timeMillis": 28900,
                "ver": "1.0"
            },
            {
                "comment": {
                    "type": "comment",
                    "id": 24173989334,
                    "message": "ごきげんようジャパン",
                    "createdAt": 1645262139000,
                    "author": {
                        "id": "kugagin",
                        "name": "🐬⚓くがぎん🐑🐈",
                        "screenName": "kugagin",
                        "profileImage": "https://imagegw02.twitcasting.tv/image3s/pbs.twimg.com/profile_images/1377443682215882752/Niny-9lu_normal.jpg",
                        "grade": 0
                    }
                },
                "timeMillis": 29061,
                "ver": "1.0"
            }
        ],
        "pastEvents": [],
        "updates": [],
        "states": []
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment