move claude-marketplace to ai-proj-helper
This commit is contained in:
51
plugins/feishu-plugin/check_manual_images.py
Normal file
51
plugins/feishu-plugin/check_manual_images.py
Normal file
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env python3
|
||||
"""检查文档中的图片块状态"""
|
||||
|
||||
import requests
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
ZHIYUN_APP_ID = "cli_a9f29dca82b9dbef"
|
||||
ZHIYUN_APP_SECRET = "sDfhjG7QT1S4gfHiMVYSygmPQPN1R2Ho"
|
||||
BASE_URL = "https://open.feishu.cn/open-apis"
|
||||
DOCUMENT_ID = "Eqt2dpcpToVDxExFmhicqFa9nJf"
|
||||
|
||||
def get_token():
|
||||
url = f"{BASE_URL}/auth/v3/tenant_access_token/internal"
|
||||
response = requests.post(url, json={
|
||||
"app_id": ZHIYUN_APP_ID,
|
||||
"app_secret": ZHIYUN_APP_SECRET
|
||||
})
|
||||
return response.json()["tenant_access_token"]
|
||||
|
||||
def main():
|
||||
token = get_token()
|
||||
headers = {"Authorization": f"Bearer {token}"}
|
||||
|
||||
url = f"{BASE_URL}/docx/v1/documents/{DOCUMENT_ID}/blocks"
|
||||
response = requests.get(url, headers=headers)
|
||||
data = response.json()
|
||||
|
||||
if data.get("code") != 0:
|
||||
print(f"获取失败: {data}")
|
||||
return
|
||||
|
||||
blocks = data["data"].get("items", [])
|
||||
print(f"文档共有 {len(blocks)} 个块\n")
|
||||
|
||||
image_count = 0
|
||||
for block in blocks:
|
||||
if block.get("block_type") == 27:
|
||||
image_count += 1
|
||||
image_data = block.get("image", {})
|
||||
token_value = image_data.get("token", "")
|
||||
print(f"图片块 #{image_count}:")
|
||||
print(f" block_id: {block.get('block_id')}")
|
||||
print(f" token: {token_value if token_value else '(空)'}")
|
||||
print(f" width: {image_data.get('width')}, height: {image_data.get('height')}")
|
||||
print()
|
||||
|
||||
if image_count == 0:
|
||||
print("文档中没有图片块")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user