Skip to content

Commit

Permalink
Merge pull request #180 from ShunnMatsumura/add-bookmark-count-to-tweet
Browse files Browse the repository at this point in the history
Add bookmarkedCount field to Tweet model constructor
  • Loading branch information
vladkens authored Jun 29, 2024
2 parents f0b9ba7 + 6ad9c0e commit 09d035c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/mocked-data/_issue_28_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@
},
"source": "<a href=\"http://twitter.com/download/iphone\" rel=\"nofollow\">Twitter for iPhone</a>",
"legacy": {
"bookmark_count": 0,
"bookmarked": false,
"created_at": "Tue May 16 09:49:50 +0000 2023",
"conversation_id_str": "1658409412799737856",
"display_text_range": [
Expand Down Expand Up @@ -236,6 +238,8 @@
},
"source": "<a href=\"http://twitter.com/download/android\" rel=\"nofollow\">Twitter for Android</a>",
"legacy": {
"bookmark_count": 0,
"bookmarked": false,
"created_at": "Tue May 16 09:41:01 +0000 2023",
"conversation_id_str": "1658407192859492355",
"display_text_range": [
Expand Down Expand Up @@ -709,6 +713,8 @@
},
"source": "<a href=\"https://mobile.twitter.com\" rel=\"nofollow\">Twitter Web App</a>",
"legacy": {
"bookmark_count": 0,
"bookmarked": false,
"created_at": "Thu Jul 06 19:22:59 +0000 2023",
"conversation_id_str": "1676995076461821958",
"display_text_range": [
Expand Down Expand Up @@ -758,6 +764,8 @@
}
},
"legacy": {
"bookmark_count": 0,
"bookmarked": false,
"created_at": "Thu Jul 06 19:32:52 +0000 2023",
"conversation_id_str": "1677037919880507392",
"display_text_range": [
Expand Down
8 changes: 8 additions & 0 deletions tests/mocked-data/_issue_28_2.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@
},
"source": "<a href=\"http://twitter.com/download/android\" rel=\"nofollow\">Twitter for Android</a>",
"legacy": {
"bookmark_count": 0,
"bookmarked": false,
"created_at": "Tue May 16 09:41:01 +0000 2023",
"conversation_id_str": "1658407192859492355",
"display_text_range": [
Expand Down Expand Up @@ -451,6 +453,8 @@
}
},
"legacy": {
"bookmark_count": 0,
"bookmarked": false,
"created_at": "Tue May 16 10:38:37 +0000 2023",
"conversation_id_str": "1658421690001502208",
"display_text_range": [
Expand Down Expand Up @@ -674,6 +678,8 @@
},
"source": "<a href=\"http://twitter.com/download/iphone\" rel=\"nofollow\">Twitter for iPhone</a>",
"legacy": {
"bookmark_count": 0,
"bookmarked": false,
"created_at": "Wed Jul 05 21:00:17 +0000 2023",
"conversation_id_str": "1676697529461743622",
"display_text_range": [
Expand Down Expand Up @@ -825,6 +831,8 @@
}
},
"legacy": {
"bookmark_count": 0,
"bookmarked": false,
"created_at": "Thu Jul 06 09:43:43 +0000 2023",
"conversation_id_str": "1676889656225411072",
"display_text_range": [
Expand Down
2 changes: 2 additions & 0 deletions tests/mocked-data/manual_tweet_with_video_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@
},
"source": "<a href=\"https://mobile.twitter.com\" rel=\"nofollow\">Twitter Web App</a>",
"legacy": {
"bookmark_count": 3167,
"bookmarked": false,
"created_at": "Wed Jun 21 13:21:20 +0000 2023",
"conversation_id_str": "1671508600538161153",
"display_text_range": [0, 84],
Expand Down
2 changes: 2 additions & 0 deletions tests/mocked-data/manual_tweet_with_video_2.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@
},
"source": "<a href=\"http://twitter.com/download/iphone\" rel=\"nofollow\">Twitter for iPhone</a>",
"legacy": {
"bookmark_count": 0,
"bookmarked": false,
"created_at": "Thu Jun 22 05:34:45 +0000 2023",
"conversation_id_str": "1671753569412820992",
"display_text_range": [0, 42],
Expand Down
2 changes: 2 additions & 0 deletions twscrape/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ class Tweet(JSONTrait):
retweetCount: int
likeCount: int
quoteCount: int
bookmarkedCount: int
conversationId: int
conversationIdStr: str
hashtags: list[str]
Expand Down Expand Up @@ -225,6 +226,7 @@ def parse(obj: dict, res: dict):
retweetCount=obj["retweet_count"],
likeCount=obj["favorite_count"],
quoteCount=obj["quote_count"],
bookmarkedCount=obj["bookmark_count"],
conversationId=int(obj["conversation_id_str"]),
conversationIdStr=obj["conversation_id_str"],
hashtags=[x["text"] for x in get_or(obj, "entities.hashtags", [])],
Expand Down

0 comments on commit 09d035c

Please sign in to comment.