Beispiel #1
0
def post_links():
    session = Session()
    data = json.loads(request.data)

    for link in data['links']:
        post = Post.get_or_create(session, link['reddit_id'])
        subreddit = Subreddit.get_or_create(session, link['sub_name'])
        user = User.get_or_create(session, link['authorname'])

        post.subreddit_id   = subreddit.id
        post.author_id      = user.id

        post.domain = link['domain']
        post.title  = link['title']
        post.url    = link['url']
        post.score  = link['score']
        post.downs  = link['downs']
        post.ups    = link['ups']

        post.is_self = link['is_self']
        post.over_18 = link['over_18']
        post.thumbnail = link['thumbnail']
        post.created = float(link['created'])
        post.scraped_time = Util.now()

        session.add(post)

    session.commit()
    session.close()
    return jsonify({'received':True})
Beispiel #2
0
    def update_from_praw(self, p):
        self.reddit_id  = Util.plain_id(p.id)

        self.gilded = bool(p.gilded)
        self.edited = float(p.edited)

        self.body   = p.body
        self.ups    = p.ups
        self.downs  = p.downs

        self.created        = p.created
        self.created_utc    = p.created_utc
        self.scraped_time   = Util.now()
Beispiel #3
0
    def update_from_praw(self, p):
        self.reddit_id  = p.id
        self.name       = p.name

        self.created        = p.created
        self.created_utc    = p.created_utc
        self.scraped_time   = Util.now()

        self.link_karma     = p.link_karma
        self.comment_karma  = p.comment_karma

        self.over_18    = p.over_18
        self.is_gold    = p.is_gold
        self.is_mod     = p.is_mod
        self.has_verified_email = p.has_verified_email
Beispiel #4
0
    def update_from_json(self, j):
        self.reddit_id  = j['id']
        self.name       = j['name']

        self.created        = j['created']
        self.created_utc    = j['created_utc']
        self.scraped_time   = Util.now()

        self.link_karma     = j['link_karma']
        self.comment_karma  = j['comment_karma']

        self.over_18    = j['over_18']
        self.is_gold    = j['is_gold']
        self.is_mod     = j['is_mod']
        self.has_verified_email = j['has_verified_email']
Beispiel #5
0
    def update_from_praw(self, p):
        self.header_img = p.header_img
        self.header_title = p.header_title
        self.title = p.title
        self.display_name = p.display_name

        self.name = p.name
        self.url = p.url.lower().strip()

        self.reddit_id = Util.plain_id(p.id)

        self.description = p.description
        self.description_html = p.description_html
        self.public_description = p.public_description

        self.created = p.created
        self.created_utc = p.created_utc
        self.scraped_time = Util.now()

        self.accounts_active = p.accounts_active
        self.subscribers = p.subscribers
        self.over18 = bool(p.over18)
Beispiel #6
0
    def update_from_praw(self, p):
        self.domain = p.domain
        self.url    = p.url.lower().strip()
        self.permalink = p.permalink

        self.selftext_html  = p.selftext_html
        self.selftext       = p.selftext
        self.title          = p.title
        self.thumbnail      = p.thumbnail

        self.edited         = float(p.edited)
        self.reddit_id      = p.id

        self.score  = p.score
        self.downs  = p.downs
        self.ups    = p.ups

        self.over_18        = p.over_18
        self.is_self        = p.is_self
        self.num_comments   = p.num_comments

        self.created        = p.created
        self.created_utc    = p.created_utc
        self.scraped_time   = Util.now()
Beispiel #7
0
 def touch(self):
     self.scraped_time = Util.now()