minimaxir / download-tweets-ai-text-gen

Python script to download public Tweets from a given Twitter account into a format suitable for AI text generation.
MIT License
219 stars 41 forks source link

IndexError: list index out of range #23

Open RalphORama opened 4 years ago

RalphORama commented 4 years ago

Happens when running

python download_tweets.py bikinibabelover

Output:

Retrieving tweets for @bikinibabelover...
Oldest Tweet:   1%|▌                                                                                    | 40/5771 [00:13<31:58,  2.99it/s]
Traceback (most recent call last):
  File "download_tweets.py", line 161, in <module>
    fire.Fire(download_tweets)
  File "/home/ralph/.virtualenvs/tweet_downloader/lib/python3.6/site-packages/fire/core.py", line 138, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "/home/ralph/.virtualenvs/tweet_downloader/lib/python3.6/site-packages/fire/core.py", line 468, in _Fire
    target=component.__name__)
  File "/home/ralph/.virtualenvs/tweet_downloader/lib/python3.6/site-packages/fire/core.py", line 672, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "download_tweets.py", line 152, in download_tweets
    tweet_data[-1].datetime / 1000.0
IndexError: list index out of range
Oldest Tweet:   1%|▌                                                                                    | 40/5771 [00:13<32:05,  2.98it/s]
sdelgadoc commented 4 years ago

The good news is that I was able to fix the bug you identified in the referenced pull request.

The bad news is that, for some reason the twint library won't collect tweets consistently from the account you're interested in. So, you won't get the error, but you won't likely get any tweets either.

You can run the code below to reproduce the issue with twint not collecting any tweets on the account.

import twint

c = twint.Config()
c.Username = "bikinibabelover"

twint.run.Search(c)