Giter Site home page Giter Site logo

Comments (11)

d60 avatar d60 commented on June 5, 2024 1

Hi, @ashutoshsaboo

Added Tweet.thread in version 1.5.7.

Example:

>>> tweet = client.get_tweet_by_id('1779883783321272691')
>>> tweet.thread
[<Tweet id="1779910037533536356">, <Tweet id="1779910453306560552">]

from twikit.

ashutoshsaboo avatar ashutoshsaboo commented on June 5, 2024

Woah! That was super quick! 🚀 So any tweet that I query by, even if that's not the first tweet in the thread, will this still give all the tweets in the original thread in sequential order? @d60

from twikit.

d60 avatar d60 commented on June 5, 2024

@ashutoshsaboo
tweet.thread only includes tweets that are below that tweet. If you want to retrieve tweets above it, you need to use tweet.reply_to. So, to get all tweets in the thread, it would be like this:

t = client.get_tweet_by_id('123456789')
thread = [*t.reply_to, t, *t.thread]

from twikit.

ashutoshsaboo avatar ashutoshsaboo commented on June 5, 2024

Great this works perfectly! thanks!
One small edge case i found for t.thread maybe you can return an empty list when no thread exists and it's a single tweet? It returns NoneType currently and that needs unnecessary handling with the iterable. I think you are doing that already for t.reply_to as well, so would be good to do it for t.thread as well? Possible to do this small change? @d60

One small offtopic but relevant ask, is it possible to vend out the source links in the tweets as well? Like when someone links to a page in a tweet, generally they are auto shortened by t.co prefix links, I'm wondering if there's a way to get the original source links for the same? I think for images and videos you vend out t.media which helps for the same, can something similar be also done for links? If i recall correctly, this was possible to get via the twitter apis. Given this is accessing source directly, should also be possible ideally?

from twikit.

d60 avatar d60 commented on June 5, 2024

@ashutoshsaboo
Indeed, it would be better to have Tweet.thread return an empty list instead of None. I'll make that change in the next update.
And you can use Tweet.urls to get the original URLs.

>>> tweet = client.get_tweet_by_id('1780709582958100825')

>>> print(tweet.text)
Whether youre planning a drive or already on the road, were making it easier to find information about electric vehicle charging stations. Learn morehttps://t.co/mdVCGnYY2V
>>> print(tweet.urls)
[{'display_url': 'goo.gle/3U0OcPe', 'expanded_url': 'https://goo.gle/3U0OcPe', 'url': 'https://t.co/mdVCGnYY2V', 'indices': [154, 177]}]

from twikit.

ashutoshsaboo avatar ashutoshsaboo commented on June 5, 2024

Ohh i couldn't see in the Tweet class here about urls attribute, which is why was confused - https://twikit.readthedocs.io/en/latest/_modules/twikit/tweet.html#Tweet . I see it now as part of the constructor, but didn't see in the docs, hence couldn't spot it earlier. Should be a quick fix to add to the docs. @d60

This looks perfect but!

from twikit.

ashutoshsaboo avatar ashutoshsaboo commented on June 5, 2024

Hey @d60 , i just noticed for long tweets such as these - https://twitter.com/EFarraro/status/1669480575542116353 - tweet.text seems to be only partial and not the entire text? Is there some bug causing that?

I believe browsing long tweets has no constraint even if your account in non verified - so ideally given this is accessing source it should ideally work? Any idea you might have on how to go about for getting content for such tweets?

from twikit.

d60 avatar d60 commented on June 5, 2024

@ashutoshsaboo You can retrieve the full text of a tweet using Tweet.full_text.

from twikit.

ashutoshsaboo avatar ashutoshsaboo commented on June 5, 2024

@d60 problem is that full_text doesn't have the t.co media urls in place like t.text has looks like. Also I saw for short tweets, t.full_text is also many times empty, and only t.text contains the text. Only for longer tweets looks like t.full_text has the text, not otherwise (atleast from my limited testing).

Can this be made uniform to vend out valid t.full_text in all cases (i don't know if there's any additional network requests you need to make for getting full_text, but if it's a short tweet, and no extra content maybe just return t.text for t.full_text as well?), and to also have the t.co media/url links in place in full_text as well, just like it is the case in t.text? @d60

Without that, it's kind of challenging to access the entire tweet in a unified manner.

from twikit.

ashutoshsaboo avatar ashutoshsaboo commented on June 5, 2024

Any idea about the above? Can you help @d60

from twikit.

d60 avatar d60 commented on June 5, 2024

@ashutoshsaboo
Hi, sorry for the delay.

I've released Version 1.5.11, and as you suggested, I've made adjustments to Tweet.full_text and Tweet.urls. Now, Tweet.full_text will contain Tweet.text even for short tweets. Additionally, Tweet.urls will include all URLs within the tweet.

from twikit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.