Example #1
0
    def read_comments(self):
        c_list = {}
        comments = []

        # comment_history = self.account.comment_history(limit=self.limit)
        # query = Query(start_author=self.username, limit=self.limit)
        # comment_history = Discussions_by_comments(query)
        comment_history = self.get_comments()

        days_done = False
        for c in comment_history:
            if c.permlink in c_list:
                continue
            if c.is_comment() and c.author == self.username:
                sc = SteemComment(comment=c)
                days_done = self.days is not None and not in_recent_n_days(c, self.days)
                if days_done:
                    break
                else:
                    if self.receiver is None or len(self.receiver) == 0 \
                        or c.parent_author == self.receiver:
                        c = sc.refresh()
                        sc.log()
                        c_list[c.permlink] = 1
                        comments.append(c)

        print ('{} comments are fetched'.format(len(comments)))
        return comments
Example #2
0
    def read_posts(self, start=0):
        c_list = {}
        posts = []

        if self.limit:
            blogs = self.account.get_blog(start_entry_id=start, limit=self.limit)
        else:
            blogs = self.account.blog_history(start=start, limit=self.limit, reblogs=False)

        days_done = False
        for c in blogs:
            if c.permlink in c_list:
                continue
            if not c.is_comment() and c.author == self.username:
                sc = SteemComment(comment=c)
                tags = sc.get_tags()
                if self.tag is None or self.tag in tags:
                    if self.keyword is None or self.keyword in c.title:
                        days_done = self.days is not None and not in_recent_n_days(c, self.days)
                        if days_done:
                            break
                        else:
                            c = sc.refresh()
                            sc.log()
                            c_list[c.permlink] = 1
                            posts.append(c)

        print ('{} posts are fetched'.format(len(posts)))
        return posts
Example #3
0
    def read_posts(self, start=0):
        if not self.exists:
            return []

        c_list = {}
        posts = []

        if self.reblog:
            blogs = self.account.history_reverse(only_ops=["custom_json"])
        elif self.limit:
            blogs = self.account.get_blog(start_entry_id=start,
                                          limit=self.limit)
        else:
            blogs = self.account.blog_history(start=start,
                                              limit=self.limit,
                                              reblogs=self.reblog)

        days_done = False
        for c in blogs:
            if self.reblog:
                if c['id'] == "follow":
                    json_data = json.loads(c['json'])
                    if len(json_data) > 0 and json_data[0] == "reblog":
                        info = json_data[1]
                        authorperm = "@{}/{}".format(info["author"],
                                                     info["permlink"])
                        timestamp = c["timestamp"]
                        c = Comment(authorperm)
                        c["reblogged"] = timestamp
                    else:
                        continue
                else:
                    continue
            if c.authorperm in c_list:
                continue
            if not c.is_comment():
                if ((not self.reblog) and c.author == self.username) or (
                        self.reblog and c.author != self.username):
                    sc = SteemComment(comment=c)
                    tags = sc.get_tags()
                    if self.tag is None or self.tag in tags:
                        if self.keyword is None or self.keyword in c.title:
                            days_done = self.days is not None and not in_recent_n_days(
                                c, self.days, self.reblog)
                            if days_done:
                                break
                            else:
                                c = sc.refresh()
                                sc.log()
                                c_list[c.authorperm] = 1
                                posts.append(c)

        print('{} posts are fetched'.format(len(posts)))
        return posts
Example #4
0
 def print_post(ops):
     c = SteemComment(ops=ops)
     if not c.get_comment().is_comment():
         c.log()