Skip to content

Commit

Permalink
Merge pull request #9 from kingbootoshi/media-and-engagement
Browse files Browse the repository at this point in the history
FULL TWITTER AUTONOMY: Adding video media uploads, quote tweets (w/ media support), re-tweets, follows & likes
  • Loading branch information
lalalune authored Nov 28, 2024
2 parents 2695e10 + b6948ee commit dfca604
Show file tree
Hide file tree
Showing 9 changed files with 1,147 additions and 29 deletions.
Binary file added .DS_Store
Binary file not shown.
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ const followerResults = await scraper.fetchProfileFollowers('12345', 100);

// Fetch a page of who a user is following
const followingResults = await scraper.fetchProfileFollowing('12345', 100);

// Follow a user
const followUserResults = await scraper.followUser('elonmusk');
```

### Trends
Expand Down Expand Up @@ -205,4 +208,65 @@ const latestTweet = await scraper.getLatestTweet('TwitterDev');

// Get a specific tweet by ID
const tweet = await scraper.getTweet('1234567890123456789');

// Send a tweet
const sendTweetResults = await scraper.sendTweet('Hello world!');

// Send a quote tweet - Media files are optional
const sendQuoteTweetResults = await scraper.sendQuoteTweet('Hello world!', '1234567890123456789', ['mediaFile1', 'mediaFile2']);

// Retweet a tweet
const retweetResults = await scraper.retweet('1234567890123456789');

// Like a tweet
const likeTweetResults = await scraper.likeTweet('1234567890123456789');
```

## Sending Tweets with Media

### Media Handling
The scraper requires media files to be processed into a specific format before sending:
- Media must be converted to Buffer format
- Each media file needs its MIME type specified
- This helps the scraper distinguish between image and video processing models

### Basic Tweet with Media
```ts
// Example: Sending a tweet with media attachments
const mediaData = [
{
data: fs.readFileSync('path/to/image.jpg'),
mediaType: 'image/jpeg'
},
{
data: fs.readFileSync('path/to/video.mp4'),
mediaType: 'video/mp4'
}
];

await scraper.sendTweet('Hello world!', undefined, mediaData);
```

### Supported Media Types
```ts
// Image formats and their MIME types
const imageTypes = {
'.jpg': 'image/jpeg',
'.jpeg': 'image/jpeg',
'.png': 'image/png',
'.gif': 'image/gif'
};

// Video format
const videoTypes = {
'.mp4': 'video/mp4'
};
```


### Media Upload Limitations
- Maximum 4 images per tweet
- Only 1 video per tweet
- Maximum video file size: 512MB
- Supported image formats: JPG, PNG, GIF
- Supported video format: MP4
Loading

0 comments on commit dfca604

Please sign in to comment.