Skip to content

feat(youtube): add comment and comments adapters#31

Merged
nashsu merged 1 commit intonashsu:mainfrom
kevdogg102396-afk:feat/youtube-comment-and-read
Apr 8, 2026
Merged

feat(youtube): add comment and comments adapters#31
nashsu merged 1 commit intonashsu:mainfrom
kevdogg102396-afk:feat/youtube-comment-and-read

Conversation

@kevdogg102396-afk
Copy link
Copy Markdown
Contributor

Summary

  • Adds youtube comment adapter - post comments on YouTube videos via InnerTube API
  • Adds youtube comments adapter - read comments from YouTube videos

How it works

YouTube doesn't expose a simple comment API. These adapters use a 3-step InnerTube flow:

  1. Call /youtubei/v1/next with videoId → find the comment section continuation token
  2. Call /next again with that continuation → load the comment section data
  3. For commenting: extract createCommentParams and POST to /youtubei/v1/comment/create_comment
  4. For reading: parse commentEntityPayload from frameworkUpdates.entityBatchUpdate.mutations

Usage

# Post a comment
opencli-rs youtube comment "Great video!" "dQw4w9WgXcQ"

# Read comments
opencli-rs youtube comments "dQw4w9WgXcQ" --limit 20

Technical details

  • SAPISIDHASH authentication (uses logged-in Chrome session cookies)
  • Handles YouTube's new commentViewModel / entityBatchUpdate data structure
  • Video ID extraction from full URLs and shorts
  • Proper error handling for disabled comments, auth issues, etc.

Test plan

  • Tested youtube comment - successfully posted comments on multiple videos
  • Tested youtube comments - reads author, text, likes, timestamps
  • Tested with video IDs and full URLs
  • Tested error cases (disabled comments, not logged in)

🤖 Generated with Claude Code

Add two new YouTube adapters:
- `youtube comment` - Post comments on videos via InnerTube API
- `youtube comments` - Read comments from videos

Uses a 3-step InnerTube flow:
1. /next with videoId to get comment section continuation token
2. /next with continuation to load comment section + extract createCommentParams
3. /comment/create_comment to post (or parse mutations for reading)

Handles SAPISIDHASH auth, video ID extraction from URLs, and YouTube's
new commentViewModel/entityBatchUpdate data structure.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@nashsu nashsu merged commit c160eb4 into nashsu:main Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants