Add post_title to TikTok sync

- Request title field from TikTok API
- Truncate to 80 chars for clean display
- Send post_title in sync payload

Chronicler #76
This commit is contained in:
Claude
2026-04-10 22:18:14 +00:00
parent 21b6fa9788
commit 274edccf8a

View File

@@ -74,7 +74,7 @@ sync_videos() {
echo "Syncing video stats..."
RESPONSE=$(curl -s -X POST \
'https://open.tiktokapis.com/v2/video/list/?fields=id,view_count,like_count,comment_count,share_count' \
'https://open.tiktokapis.com/v2/video/list/?fields=id,title,view_count,like_count,comment_count,share_count' \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"max_count": 20}')
@@ -84,6 +84,8 @@ sync_videos() {
echo "$RESPONSE" | jq -c '.data.videos[]' | while read -r video; do
VID=$(echo "$video" | jq -r '.id')
# Get first 80 chars of title, escape quotes for JSON
TITLE=$(echo "$video" | jq -r '.title // "Untitled"' | head -c 80 | sed 's/"/\\"/g')
VIEWS=$(echo "$video" | jq -r '.view_count // 0')
LIKES=$(echo "$video" | jq -r '.like_count // 0')
COMMENTS=$(echo "$video" | jq -r '.comment_count // 0')
@@ -94,7 +96,7 @@ sync_videos() {
curl -s -X POST "$ARBITER_URL/sync" \
-H "Authorization: Bearer $ARBITER_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"platform\":\"tiktok\",\"platform_post_id\":\"$VID\",\"post_url\":\"$POST_URL\",\"metrics\":{\"views\":$VIEWS,\"likes\":$LIKES,\"comments\":$COMMENTS,\"shares\":$SHARES}}" > /dev/null
-d "{\"platform\":\"tiktok\",\"platform_post_id\":\"$VID\",\"post_title\":\"$TITLE\",\"post_url\":\"$POST_URL\",\"metrics\":{\"views\":$VIEWS,\"likes\":$LIKES,\"comments\":$COMMENTS,\"shares\":$SHARES}}" > /dev/null
echo " $VID: $VIEWS views, $LIKES likes"
done