micahflee / semiphemeral

Automatically delete your old tweets, except for the ones you want to keep

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AttributeError: 'Twitter' object has no attribute 'import_tweets'

moffat opened this issue · comments

It was really good to see the option of using the twitter archive to delete old tweets as explained here. While there are people reporting success using this new feature, I found this fails for me with:

/Desktop/semiphemeral-archive-import/semiphemeral/twitter.py", line 800, in import_dump
    self.import_tweets(
AttributeError: 'Twitter' object has no attribute 'import_tweets'

The offending code is:

for offset in range(0, len(tweets), 500):
                self.import_tweets(
                    parse_tweet(t) for t in tweets[offset : offset + 500]
                )

I don't see import_tweets defined anywhere, but maybe I'm misreading the code.

I've reported this in a different thread, thanks for opening the issue. Hoping for this to be resolved, I've noticed that without the imported tweets application usually returns only one tweet deleted per day and fetching doesn't seem to be working.

I used import_tweet_and_thread instead and I also had to replace parse_tweet(t) with Tweet(parse_tweet(t['tweet'])) to make it work.
But I'm basically learning python for this, so please check twice before actually doing any thing

No luck:

File "~/Desktop/semiphemeral-master/semiphemeral/twitter.py", line 224, in import_tweet_and_thread
if not tweet.already_saved(self.common.session):
AttributeError: 'generator' object has no attribute 'already_saved'

I see. I don't understand the nested range-offset loops so I replaced it with a standard for loop. I wasn't aware that it didn't work as it is, I just did it because I feel more comfortable with the for loop. Probably there's a more efficient way than a simple for loop. For me this works,

From:
for offset in range(0, len(tweets), 500):
self.import_tweets(
parse_tweet(t) for t in tweets[offset : offset + 500]
)
To:
for t in tweets:
self.import_tweet_and_thread(
Tweet(parse_tweet(t['tweet']))
)

Hi @jorsa76, thanks for your help. I think the range is there perhaps to avoid a range limit, but it's working now!

This is fixed with PR #101