catch more twitter exceptions

This commit is contained in:
codl 2017-09-05 12:58:57 +02:00
parent 2ad076e63c
commit 4b44682827
No known key found for this signature in database
GPG Key ID: 6CD7C8891ED1233A
1 changed files with 19 additions and 19 deletions

View File

@ -124,26 +124,26 @@ def fetch_acc(account, cursor):
print("no twitter access, aborting")
return
user = t.account.verify_credentials()
db.session.merge(account_from_api_user_object(user))
kwargs = {
'user_id': account.twitter_id,
'count': 200,
'trim_user': True,
'tweet_mode': 'extended',
}
if cursor:
kwargs.update(cursor)
if 'max_id' not in kwargs:
most_recent_post = (
Post.query.order_by(db.desc(Post.created_at))
.filter(Post.author_id == account.id).first())
if most_recent_post:
kwargs['since_id'] = most_recent_post.twitter_id
try:
user = t.account.verify_credentials()
db.session.merge(account_from_api_user_object(user))
kwargs = {
'user_id': account.twitter_id,
'count': 200,
'trim_user': True,
'tweet_mode': 'extended',
}
if cursor:
kwargs.update(cursor)
if 'max_id' not in kwargs:
most_recent_post = (
Post.query.order_by(db.desc(Post.created_at))
.filter(Post.author_id == account.id).first())
if most_recent_post:
kwargs['since_id'] = most_recent_post.twitter_id
tweets = t.statuses.user_timeline(**kwargs)
except (TwitterError, URLError) as e:
handle_error(e)