micahflee / semiphemeral

Automatically delete your old tweets, except for the ones you want to keep
MIT License
884 stars 85 forks source link

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

Closed moffat closed 2 years ago

moffat commented 2 years ago

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.

ctrlBIRDdelete commented 2 years ago

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.

jorsa76 commented 2 years ago

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

moffat commented 2 years ago

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'

jorsa76 commented 2 years ago

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'])) )

moffat commented 2 years ago

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

kees commented 2 years ago

This is fixed with PR #101