Skip to content

Commit

Permalink
fixup! Render reddit links as bookmark-of
Browse files Browse the repository at this point in the history
  • Loading branch information
jamietanna committed Oct 13, 2020
1 parent 03210d9 commit 7e79b71
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion granary/reddit.py
Expand Up @@ -139,14 +139,18 @@ def praw_to_object(self, thing, type):
if type == 'submission':
obj['title'] = getattr(thing, 'title', None)
obj['content'] = getattr(thing, 'selftext', None)
obj['bookmark-of'] = getattr(thing, 'url', None)
obj['objectType'] = 'note'
obj['tags'] = [
{'objectType': 'article',
'url': t,
'displayName': t,
} for t in util.extract_links(getattr(thing, 'selftext', None))
]

if getattr(thing, 'url', None):
obj['objectType'] = 'bookmark'
obj['targetUrl'] = getattr(thing, 'url')

elif type == 'comment':
obj['content'] = getattr(thing, 'body_html', None)
obj['objectType'] = 'comment'
Expand Down
4 changes: 2 additions & 2 deletions granary/tests/test_reddit.py
Expand Up @@ -172,9 +172,9 @@ def parent(self):
'username': 'bonkerfield'
},
'title': '[P] GPT-2 + BERT reddit replier. I built a system that generates replies by taking output from GPT-2 and using BERT models to select the most realistic replies. People on r/artificial replied to it as if it were a person.',
'bookmark-of': 'https://reddit.com/ezv3f2',
'targetUrl': 'https://reddit.com/ezv3f2',
'id': 'tag:reddit.com:ezv3f2',
'objectType': 'note',
'objectType': 'bookmark',
'published': '2020-02-06T16:51:59Z',
'to': [{'alias': '@public', 'objectType': 'group'}],
'url': 'https://reddit.com/r/MachineLearning/comments/ezv3f2/p_gpt2_bert_reddit_replier_i_built_a_system_that/'},
Expand Down

0 comments on commit 7e79b71

Please sign in to comment.