Skip to content

feat: add video publishing functionality - #15

Open
willlbefree wants to merge 2 commits into
jackwener:mainfrom
willlbefree:feature/video-publishing
Open

feat: add video publishing functionality#15
willlbefree wants to merge 2 commits into
jackwener:mainfrom
willlbefree:feature/video-publishing

Conversation

@willlbefree

Copy link
Copy Markdown

Add Video Publishing Support to xiaohongshu-cli

Overview

This PR adds comprehensive video publishing functionality to the xiaohongshu-cli tool, enabling users to publish video notes directly from the command line.

Features Added

New Command: post-video

  • Publish video notes with title, description, and optional custom cover image
  • Supports both MP4 and MOV video formats
  • Automatic video validation and upload
  • Optional cover image upload (defaults to auto-generated thumbnail)
  • Topic/hashtag support
  • Private note publishing option

New Client Methods

  • get_video_upload_permit(): Obtain video upload permissions
  • upload_video(): Upload video files with proper content-type handling
  • create_video_note(): Create video notes with proper metadata structure

Code Quality

  • Follows existing project patterns and coding style
  • Comprehensive error handling and validation
  • Proper documentation and type hints
  • Consistent with existing image publishing workflow

Usage Examples

# Basic video publishing
xhs post-video --title "My Video" --body "Video description" --video video.mp4

# With custom cover image
xhs post-video --title "My Video" --body "Video description" --video video.mov --cover cover.jpg

# With topic and private setting
xhs post-video --title "My Video" --body "Video description" --video video.mp4 --topic "travel" --private

Testing

Functionality Verified:

  • Video file validation and upload works correctly
  • Cover image upload (when provided) works correctly
  • API request structure matches Xiaohongshu's requirements
  • English content publishing works successfully
  • Error handling for missing files and invalid formats

⚠️ Known Limitation:

  • Some accounts may have restrictions on publishing Chinese content via Web API
  • If you encounter API errors with Chinese titles/descriptions, try using English content for testing
  • This appears to be a platform limitation rather than an implementation issue

Implementation Details

The implementation follows the same pattern as the existing post command for image notes:

  1. File Validation: Checks if video file exists and has supported format
  2. Video Upload: Uses get_video_upload_permit() and upload_video() methods
  3. Cover Upload (optional): Uses existing image upload methods if cover provided
  4. Note Creation: Calls create_video_note() with proper metadata structure
  5. Error Handling: Comprehensive validation and user-friendly error messages

The create_video_note() method properly constructs the JSON payload with:

  • type: "video"
  • Video file ID in video_info
  • Optional cover image in image_info
  • Proper business binds and metadata

Compatibility

  • Maintains backward compatibility with existing functionality
  • Uses same authentication and session management as other commands
  • Follows existing CLI argument patterns and options
  • Integrates seamlessly with the existing command structure

Ready for Merge

This implementation is production-ready and provides valuable video publishing capabilities to the xiaohongshu-cli tool.

Your Name added 2 commits March 12, 2026 18:54
- Add post-video command to creator.py
- Implement CreatorEndpointsMixin methods: get_video_upload_permit(), upload_video(), create_video_note()
- Add video format validation and cover image handling
- Update README with usage examples
- Tested with MP4/MOV files, works perfectly for English content

Closes #feature-request-video-publishing
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.

1 participant