from atproto import Client, models
import sys
# 投稿するデータを読み込む(TSV 1行)
file_name = sys.argv[1]
with open(file_name) as f:
s = f.read()
(header, title, description, uri, img_fn) = s.split('\t')
# 投稿の準備
client = Client(base_url='https://bsky.social')
client.login(login='kinseli.bsky.social', password='[アプリパスワード]')
# リンクカードで使う画像をアップ
img_path = '/home/USER/bluesky/img/' + img_fn
with open(img_path, 'rb') as f:
img_data = f.read()
thumb = client.upload_blob(img_data)
# リンクカード
embed_external = models.AppBskyEmbedExternal.Main(
external = models.AppBskyEmbedExternal.External(
title = title,
description = description,
uri = uri,
thumb = thumb.blob,
)
)
# 投稿する
client.send_post(header, embed = embed_external)
(「アプリパスワード」はこちらで取得できます。)