Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add bookmark count #82

Merged
merged 1 commit into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading