Esempio n. 1
0
    def read_posts(self):
        posts = {}
        votes = self.get_votes(self.account, up=self.upvote)
        for v in votes:
            # filter votes with 7 days
            # dt = datetime.strptime(v['time'], "%Y-%m-%dT%H:%M:%S")
            dt = datetime.strptime(v['last_update'], "%Y-%m-%dT%H:%M:%S")
            dt = dt.replace(tzinfo=timezone.utc)
            if not in_recent_days(dt, self.days):
                continue

            # get post data
            # authorperm = v['authorperm']
            authorperm = "@{}/{}".format(v['author'], v['permlink'])
            if not authorperm in posts:
                c = SteemComment(author_perm=authorperm)
                if not self.within_nth_day(c, self.days):
                    continue
                posts[authorperm] = {
                    "author": c.get_comment().author,
                    "permlink": v['permlink'],
                    "authorperm": authorperm,
                    "voters": [],
                    "percents": [],
                    "created": c.get_comment()['created']
                }
            # get voters and percentage
            posts[authorperm]['voters'].append(v['voter'])
            # posts[authorperm]['percents'].append(v['percent'])
            posts[authorperm]['percents'].append(v['vote_percent'])
        res = list(posts.values())
        res.sort(key=lambda post: post['created'])
        return res
Esempio n. 2
0
def in_recent_n_days(post, n, reblog=False):
    key = "reblogged" if reblog else "created"
    if isinstance(post[key], str):
        created = datetime.strptime(
            post[key], '%Y-%m-%dT%H:%M:%S').replace(tzinfo=pytz.UTC)
    else:
        created = post[key]
    return in_recent_days(created, n)
Esempio n. 3
0
def in_recent_n_days(post, n):
    return in_recent_days(post['created'], n)
Esempio n. 4
0
 def _is_recent(self, account, days):
     return in_recent_days(account.birthday(), days)
Esempio n. 5
0
 def is_recent(self, post, days):
     return in_recent_days(post['created'], days)