Skip to content

Commit

Permalink
feat: add bookmark count (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
biowaffeln committed Apr 28, 2024
1 parent f8394df commit 9b57c85
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/timeline-v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export interface TimelineResultRaw {
}

export interface LegacyTweetRaw {
bookmark_count?: number;
conversation_id_str?: string;
created_at?: string;
favorite_count?: number;
Expand Down
1 change: 1 addition & 0 deletions src/timeline-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export function parseLegacyTweet(
const { photos, videos, sensitiveContent } = parseMediaGroups(media);

const tw: Tweet = {
bookmarkCount: tweet.bookmark_count,
conversationId: tweet.conversation_id_str,
id: tweet.id_str,
hashtags: hashtags
Expand Down
6 changes: 6 additions & 0 deletions src/tweets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ test('scraper can get tweet', async () => {
delete actual?.replies;
delete actual?.retweets;
delete actual?.views;
delete actual?.bookmarkCount;
expect(actual).toEqual(expected);
});

Expand Down Expand Up @@ -166,6 +167,7 @@ test('scraper can get tweet quotes without logging in', async () => {
delete quote?.quotedStatus?.replies;
delete quote?.quotedStatus?.retweets;
delete quote?.quotedStatus?.views;
delete quote?.quotedStatus?.bookmarkCount;
expect(quote?.quotedStatus).toEqual(expected);
});

Expand Down Expand Up @@ -207,6 +209,7 @@ test('scraper can get tweet quotes and replies', async () => {
delete quote?.quotedStatus?.replies;
delete quote?.quotedStatus?.retweets;
delete quote?.quotedStatus?.views;
delete quote?.quotedStatus?.bookmarkCount;
expect(quote?.quotedStatus).toEqual(expected);

const reply = await scraper.getTweet('1237111868445134850');
Expand All @@ -218,6 +221,7 @@ test('scraper can get tweet quotes and replies', async () => {
delete reply?.inReplyToStatus?.replies;
delete reply?.inReplyToStatus?.retweets;
delete reply?.inReplyToStatus?.views;
delete reply?.inReplyToStatus?.bookmarkCount;
expect(reply?.inReplyToStatus).toEqual(expected);
});

Expand Down Expand Up @@ -260,6 +264,7 @@ test('scraper can get retweet', async () => {
delete retweet?.retweetedStatus?.replies;
delete retweet?.retweetedStatus?.retweets;
delete retweet?.retweetedStatus?.views;
delete retweet?.retweetedStatus?.bookmarkCount;
expect(retweet?.retweetedStatus).toEqual(expected);
});

Expand Down Expand Up @@ -295,6 +300,7 @@ test('scraper can get tweet views', async () => {
delete actual?.replies;
delete actual?.retweets;
delete actual?.views;
delete actual?.bookmarkCount;
expect(actual).toEqual(expected);
});

Expand Down
1 change: 1 addition & 0 deletions src/tweets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export interface PlaceRaw {
* A parsed Tweet object.
*/
export interface Tweet {
bookmarkCount?: number;
conversationId?: string;
hashtags: string[];
html?: string;
Expand Down

0 comments on commit 9b57c85

Please sign in to comment.