2018-06-12 12:03:49 +02:00
|
|
|
from toot.utils import format_content
|
|
|
|
|
|
|
|
|
|
|
|
def parse_status(status):
|
|
|
|
_status = status.get('reblog') or status
|
|
|
|
account = parse_account(_status['account'])
|
|
|
|
content = list(format_content(_status['content']))
|
|
|
|
spoiler_text = list(format_content(_status['spoiler_text'])) if _status['spoiler_text'] else []
|
|
|
|
|
|
|
|
created_at = status['created_at'][:19].split('T')
|
|
|
|
boosted_by = parse_account(status['account']) if status['reblog'] else None
|
|
|
|
|
|
|
|
return {
|
|
|
|
'account': account,
|
|
|
|
'boosted_by': boosted_by,
|
|
|
|
'created_at': created_at,
|
|
|
|
'content': content,
|
2019-02-13 21:05:23 +01:00
|
|
|
'favourited': status.get('favourited'),
|
2019-01-07 10:13:29 +01:00
|
|
|
'favourites_count': _status['favourites_count'],
|
2019-01-03 16:55:49 +01:00
|
|
|
'id': status['id'],
|
2019-01-07 10:12:05 +01:00
|
|
|
'in_reply_to_id': _status.get('in_reply_to_id'),
|
2018-06-12 12:03:49 +02:00
|
|
|
'media_attachments': _status['media_attachments'],
|
|
|
|
'url': _status['url'],
|
2019-01-24 10:15:15 +01:00
|
|
|
'reblogged': status.get('reblogged'),
|
2019-01-07 10:13:29 +01:00
|
|
|
'reblogs_count': _status['reblogs_count'],
|
|
|
|
'replies_count': _status.get('replies_count', 0),
|
2018-06-12 12:03:49 +02:00
|
|
|
'spoiler_text': spoiler_text,
|
|
|
|
'sensitive': _status['sensitive'],
|
|
|
|
'show_sensitive': False,
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def parse_account(account):
|
|
|
|
return {
|
|
|
|
'id': account['id'],
|
|
|
|
'acct': account['acct'],
|
|
|
|
'display_name': account['display_name'],
|
|
|
|
}
|