From 76d2b8dde9b62265fa2a12d074dd6f16e861fa99 Mon Sep 17 00:00:00 2001 From: Michael Lazar Date: Wed, 9 Dec 2015 18:30:44 -0800 Subject: [PATCH 1/2] Added support for hidden scores. --- rtv/content.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/rtv/content.py b/rtv/content.py index 54394a5..0ee5eaf 100644 --- a/rtv/content.py +++ b/rtv/content.py @@ -104,7 +104,8 @@ class Content(object): data['type'] = 'Comment' data['body'] = comment.body data['created'] = cls.humanize_timestamp(comment.created_utc) - data['score'] = '{0} pts'.format(comment.score) + data['score'] = '{0} pts'.format( + '-' if comment.score_hidden else comment.score) data['author'] = name data['is_author'] = (name == sub_name) data['flair'] = flair @@ -140,32 +141,29 @@ class Content(object): data['text'] = sub.selftext data['created'] = cls.humanize_timestamp(sub.created_utc) data['comments'] = '{0} comments'.format(sub.num_comments) - data['score'] = '{0} pts'.format(sub.score) + data['score'] = '{0} pts'.format( + '-' if sub.hide_score else comment.score) data['author'] = name data['permalink'] = sub.permalink data['subreddit'] = six.text_type(sub.subreddit) - data['flair'] = flair + data['flair'] = '[{0}]'.format(flair.strip(' []')) if flair else '' data['url_full'] = sub.url data['likes'] = sub.likes data['gold'] = sub.gilded > 0 data['nsfw'] = sub.over_18 data['index'] = None # This is filled in later by the method caller - if data['flair'] and not data['flair'].startswith('['): - data['flair'] = u'[{0}]'.format(data['flair'].strip()) - - url_full = data['url_full'] - if data['permalink'].split('/r/')[-1] == url_full.split('/r/')[-1]: - data['url_type'] = 'selfpost' + if sub.url.split('/r/')[-1] == sub.permalink.split('/r/')[-1]: data['url'] = 'self.{0}'.format(data['subreddit']) - elif reddit_link.match(url_full): - data['url_type'] = 'x-post' + data['url_type'] = 'selfpost' + elif reddit_link.match(sub.url): # Strip the subreddit name from the permalink to avoid having # submission.subreddit.url make a separate API call - data['url'] = 'self.{0}'.format(url_full.split('/')[4]) + data['url'] = 'self.{0}'.format(sub.url.split('/')[4]) + data['url_type'] = 'x-post' else: + data['url'] = sub.url data['url_type'] = 'external' - data['url'] = url_full return data From 2650472c77f1965f07c1d79a47c20509c825d58d Mon Sep 17 00:00:00 2001 From: Michael Lazar Date: Wed, 9 Dec 2015 21:58:32 -0800 Subject: [PATCH 2/2] Fixed typo. --- rtv/content.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rtv/content.py b/rtv/content.py index 0ee5eaf..f172986 100644 --- a/rtv/content.py +++ b/rtv/content.py @@ -142,7 +142,7 @@ class Content(object): data['created'] = cls.humanize_timestamp(sub.created_utc) data['comments'] = '{0} comments'.format(sub.num_comments) data['score'] = '{0} pts'.format( - '-' if sub.hide_score else comment.score) + '-' if sub.hide_score else sub.score) data['author'] = name data['permalink'] = sub.permalink data['subreddit'] = six.text_type(sub.subreddit)