Skip to content

Instantly share code, notes, and snippets.

@gpsnmeajp
Last active May 18, 2023 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gpsnmeajp/ebf69830d439fb74878c4a2d460dcd5b to your computer and use it in GitHub Desktop.
Save gpsnmeajp/ebf69830d439fb74878c4a2d460dcd5b to your computer and use it in GitHub Desktop.
Blueskyで指定アカウントのblobの一覧を表示するHTMLファイルを出力する
/*
npm init -y
"type": "module",をpackage.jsonに追記
node .\index.js
とかすればいいと思う
blobの数だけアクセスするので注意。本来はCDN経由でアクセスするなりする必要がある。
CC0
*/
import fs from 'fs'
// 所属サーバー
const xrpc_url = "https://bsky.social/xrpc/"
// 取得したい対象のHandle
const handle = "gpsnmeajp.achetaria.com"
async function run () {
console.log("didを取得中..." + xrpc_url + " : "+ handle)
const did = await fetch(xrpc_url+"com.atproto.identity.resolveHandle?handle="+handle,{cache: "no-store"}).then(response => response.json());
console.log("blob listを取得中..." + did["did"])
const blob_list = await fetch(xrpc_url+"com.atproto.sync.listBlobs?did="+did["did"],{cache: "no-store"}).then(response => response.json());
console.log("出力中...")
let outputs = ""
for(const cid of blob_list["cids"]){
outputs += '<img loading="lazy" src="https://bsky.social/xrpc/com.atproto.sync.getBlob?did=' + did["did"] + '&cid=' + cid + '"/><br>\n'
}
fs.writeFileSync('output.htm', outputs);
console.log("完了")
}
run().catch((err) => {
console.error(err)
process.exit(1)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment