j-fbriere / squawker

An open-source privacy oriented Twitter/X client
MIT License
801 stars 16 forks source link

Display Top tweets instead of latest when searching hashtag #231

Closed Teskann closed 3 months ago

Teskann commented 4 months ago

Describe the problem

Hi, thanks for developing this amazing app.

Something good you could add to Squawker is an option to display Top tweets instead of latest tweets when you search something or click on any trending topic.

Usually, most of the recent tweets are not interesting and sometimes not even related to the reason why the topic is trending.

Describe the solution

There are 2 tabs in the search view to show either people or tweets.

My suggestion is the following: add a third tab to display top tweets as well. I think it should be the default tab when you search.

This is a feature provided in the official X app. I don't know about Twitter APIs but I would be surprised if they don't provide this.

Cheers,

TheHCJ commented 4 months ago

I think this is possible, we just need someone to code it (I'll be happy to code it when I have some free time)

j-fbriere commented 4 months ago

I have done some research and I didn't find a Twitter/X API query or the appropriate option of the currently implemented Twitter/X API queries in Squawker that will return the most popular tweets instead of the latest.

I'll have to analyze what kind of requests Twitter/X is making in this case.

@Teskann You say that it is available in the Twitter/X app. I don't use the app. Is it also available on the Twitter/X WEB site? If so, could you show me?

TheHCJ commented 4 months ago

Yes, it is available on the website

This is the request made for Top Tweets for the trending query Amrabat

URL Query https://twitter.com/i/api/graphql/-KWrbTBsPifMuLUqqDiU_A/SearchTimeline?variables=%7B%22rawQuery%22%3A%22Amrabat%22%2C%22count%22%3A40%2C%22cursor%22%3A%22DAADDAABCgABGHc3t7WX0C8KAAIYdzeV0Ndx3gAIAAIAAAABCAADAAAAAAgABAAAAAAKAAUYdze4_wAnEAoABhh3N7j-_9jwAAA%22%2C%22querySource%22%3A%22trend_click%22%2C%22product%22%3A%22Latest%22%7D&features=%7B%22responsive_web_graphql_exclude_directive_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Afalse%2C%22creator_subscriptions_tweet_preview_api_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%2C%22responsive_web_graphql_skip_user_profile_image_extensions_enabled%22%3Afalse%2C%22c9s_tweet_anatomy_moderator_badge_enabled%22%3Atrue%2C%22tweetypie_unmention_optimization_enabled%22%3Atrue%2C%22responsive_web_edit_tweet_api_enabled%22%3Atrue%2C%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3Atrue%2C%22view_counts_everywhere_api_enabled%22%3Atrue%2C%22longform_notetweets_consumption_enabled%22%3Atrue%2C%22responsive_web_twitter_article_tweet_consumption_enabled%22%3Atrue%2C%22tweet_awards_web_tipping_enabled%22%3Afalse%2C%22freedom_of_speech_not_reach_fetch_enabled%22%3Atrue%2C%22standardized_nudges_misinfo%22%3Atrue%2C%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3Atrue%2C%22rweb_video_timestamps_enabled%22%3Atrue%2C%22longform_notetweets_rich_text_read_enabled%22%3Atrue%2C%22longform_notetweets_inline_media_enabled%22%3Atrue%2C%22responsive_web_enhance_cards_enabled%22%3Afalse%7D

@j-fbriere are you wanting to tackle this issue?

j-fbriere commented 4 months ago

I see. It's the "querySource": "trend_click" in the "variables" node of the query. Thank you very much for the info. I will implement the feature because I have time to do it.

TheHCJ commented 4 months ago

Ok, thank you for your time on this issue

Teskann commented 4 months ago

Hi @j-fbriere thanks for your reply. I don't think it's about the "querySource":"trend_click". This one might just tell twitter we accessed the data through a click on the trending list.

It rather comes from "product" which is "Latest" in the example above. Indeed, when you search top tweets, this variable becomes "Top". This can also take the value "Media", "People" and "Lists" following what you can see on this screenshot from X website:

image

Every time you click on another tab, several request are send including one looking like the one @mrhcjones shared. The only difference is this "product" variable.

NB: I used this website to decode URL queries so they are more readable: https://www.utilities-online.info/urlencode

j-fbriere commented 4 months ago

@Teskann Than you for the information. In its search page, currently Squawker uses "product": "People" to search users and "product": "Latest" to search tweets. If I understand correctly the third type of search, the search of trending tweets, should use "product": "Top". I will try it.

NB. I use https://www.urldecoder.io/ to decode URL queries.

Teskann commented 4 months ago

Thanks again. Good luck !

j-fbriere commented 3 months ago

Version v3.7.7 implements this feature. You'll find the trend search on the third tab of the search screen.