From 774063fb5a46633a1984900734b7300ecb1bfb4f Mon Sep 17 00:00:00 2001 From: Zed Date: Sat, 20 May 2023 00:52:55 +0200 Subject: [PATCH 1/3] Fix pinned "TweetPreviewDisplay" crash --- src/parser.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parser.nim b/src/parser.nim index fe2fe5b..78f9bca 100644 --- a/src/parser.nim +++ b/src/parser.nim @@ -384,7 +384,7 @@ proc parseGraphTweet(js: JsonNode): Tweet = return Tweet(available: false) case js{"__typename"}.getStr - of "TweetUnavailable": + of "TweetUnavailable", "TweetPreviewDisplay": return Tweet(available: false) of "TweetTombstone": return Tweet( From b516ec367b41fad1185e3e408230cd61e24e2ea2 Mon Sep 17 00:00:00 2001 From: Zed Date: Sat, 20 May 2023 00:59:34 +0200 Subject: [PATCH 2/3] Remove outdated tweet from card test --- tests/test_card.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/test_card.py b/tests/test_card.py index 78fe79c..696b9d5 100644 --- a/tests/test_card.py +++ b/tests/test_card.py @@ -35,11 +35,6 @@ no_thumb = [ 'A sample of a Qt app written using mostly nim. Contribute to sinkingsugar/nimqt-example development by creating an account on GitHub.', 'github.com'], - ['mobile_test/status/490378953744318464', - 'Nantasket Beach', - 'Explore this photo titled Nantasket Beach by Ben Sandofsky (@sandofsky) on 500px', - '500px.com'], - ['nim_lang/status/1082989146040340480', 'Nim in 2018: A short recap', 'Posted by u/miran1 - 36 votes and 46 comments', From e3b3b38a2d43a83b5fc2239ab41e864ee686fb2f Mon Sep 17 00:00:00 2001 From: Zed Date: Sat, 20 May 2023 02:10:37 +0200 Subject: [PATCH 3/3] Add proper tombstone for subscriber tweets --- src/consts.nim | 18 +++++++++++------- src/parser.nim | 13 ++++++------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/consts.nim b/src/consts.nim index 27e82f9..f22581f 100644 --- a/src/consts.nim +++ b/src/consts.nim @@ -11,13 +11,13 @@ const userSearch* = api / "1.1/users/search.json" graphql = api / "graphql" - graphUser* = graphql / "8mPfHBetXOg-EHAyeVxUoA/UserByScreenName" - graphUserById* = graphql / "nI8WydSd-X-lQIVo6bdktQ/UserByRestId" - graphUserTweets* = graphql / "9rys0A7w1EyqVd2ME0QCJg/UserTweets" - graphUserTweetsAndReplies* = graphql / "ehMCHF3Mkgjsfz_aImqOsg/UserTweetsAndReplies" - graphUserMedia* = graphql / "MA_EP2a21zpzNWKRkaPBMg/UserMedia" - graphTweet* = graphql / "6I7Hm635Q6ftv69L8VrSeQ/TweetDetail" - graphTweetResult* = graphql / "rt-rHeSJ-2H9O9gxWQcPcg/TweetResultByRestId" + graphUser* = graphql / "pVrmNaXcxPjisIvKtLDMEA/UserByScreenName" + graphUserById* = graphql / "1YAM811Q8Ry4XyPpJclURQ/UserByRestId" + graphUserTweets* = graphql / "WzJjibAcDa-oCjCcLOotcg/UserTweets" + graphUserTweetsAndReplies* = graphql / "fn9oRltM1N4thkh5CVusPg/UserTweetsAndReplies" + graphUserMedia* = graphql / "qQoeS7szGavsi8-ehD2AWg/UserMedia" + graphTweet* = graphql / "miKSMGb2R1SewIJv2-ablQ/TweetDetail" + graphTweetResult* = graphql / "0kc0a_7TTr3dvweZlMslsQ/TweetResultByRestId" graphSearchTimeline* = graphql / "gkjsKepM6gl_HmFWoWKfgg/SearchTimeline" graphListById* = graphql / "iTpgCtbdxrsJfyx0cFjHqg/ListByRestId" graphListBySlug* = graphql / "-kmqNvm5Y-cVrfvBy6docg/ListBySlug" @@ -50,10 +50,13 @@ const gqlFeatures* = """{ "blue_business_profile_image_shape_enabled": false, + "creator_subscriptions_tweet_preview_api_enabled": true, "freedom_of_speech_not_reach_fetch_enabled": false, "graphql_is_translatable_rweb_tweet_is_translatable_enabled": false, + "highlights_tweets_tab_ui_enabled": false, "interactive_text_enabled": false, "longform_notetweets_consumption_enabled": true, + "longform_notetweets_inline_media_enabled": false, "longform_notetweets_richtext_consumption_enabled": true, "longform_notetweets_rich_text_read_enabled": false, "responsive_web_edit_tweet_api_enabled": false, @@ -63,6 +66,7 @@ const "responsive_web_graphql_timeline_navigation_enabled": false, "responsive_web_text_conversations_enabled": false, "responsive_web_twitter_blue_verified_badge_is_enabled": true, + "rweb_lists_timeline_redesign_enabled": true, "spaces_2022_h2_clipping": true, "spaces_2022_h2_spaces_communities": true, "standardized_nudges_misinfo": false, diff --git a/src/parser.nim b/src/parser.nim index 78f9bca..5ec21e4 100644 --- a/src/parser.nim +++ b/src/parser.nim @@ -381,16 +381,15 @@ proc parsePhotoRail*(js: JsonNode): PhotoRail = proc parseGraphTweet(js: JsonNode): Tweet = if js.kind == JNull: - return Tweet(available: false) + return Tweet() case js{"__typename"}.getStr - of "TweetUnavailable", "TweetPreviewDisplay": - return Tweet(available: false) + of "TweetUnavailable": + return Tweet() of "TweetTombstone": - return Tweet( - available: false, - text: js{"tombstone", "text"}.getTombstone - ) + return Tweet(text: js{"tombstone", "text"}.getTombstone) + of "TweetPreviewDisplay": + return Tweet(text: "You're unable to view this Tweet because it's only available to the Subscribers of the account owner.") of "TweetWithVisibilityResults": return parseGraphTweet(js{"tweet"})