def _add_author(self, name=None, link_karma=None, comment_karma=None, is_employee=0, is_mod=0, is_gold=0, author_osn_id=None): author = Author() reddit_author = RedditAuthor() author.name = name author.author_screen_name = author.name author.author_guid = compute_author_guid_by_author_name(author.name) author.domain = 'reddit' author.author_osn_id = author_osn_id author.author_full_name = name author.url = 'https://www.reddit.com/user/' + name reddit_author.name = author.name reddit_author.author_guid = author.author_guid reddit_author.comments_count = None reddit_author.comment_karma = comment_karma reddit_author.link_karma = link_karma reddit_author.is_gold = is_gold reddit_author.is_moderator = is_mod reddit_author.is_employee = is_employee self._db.add_authors([author]) self._db.add_reddit_authors([reddit_author])
def _create_author_by_row(self, record_dict): author = Author() author_osn_id = self._convert_to_unicode_value(record_dict["tumblog_id"]) author.author_osn_id = author_osn_id author.name = author_osn_id author.domain = self._domain author.author_guid = compute_author_guid_by_author_name(author.name) tumblr_blog_name = self._convert_to_unicode_value(record_dict["tumblr_blog_name"]) author.author_screen_name = tumblr_blog_name author.description = self._convert_to_unicode_value(record_dict["tumblr_blog_description"]) created_time_epoch = self._convert_to_unicode_value(record_dict["created_time_epoch"]) if created_time_epoch is not None: datetime, str_datetime = convert_epoch_timestamp_to_datetime(created_time_epoch) author.created_at = str_datetime else: author.created_at = self._set_start_date() author.url = self._convert_to_unicode_value(record_dict["tumblr_blog_url"]) author.protected = get_boolean_value(record_dict["is_private"]) author.time_zone = self._convert_to_unicode_value(record_dict["timezone"]) author.language = self._convert_to_unicode_value(record_dict["language"]) is_private = record_dict["is_private"] if is_private == "TRUE": author.protected = 1 else: author.protected = 0 return author
def _convert_reddit_author_to_author(self, redditor): author = Author() author.name = getattr(redditor, 'name', '') author.author_screen_name = author.name author.author_guid = compute_author_guid_by_author_name(author.name) author.domain = u'reddit' author.created_at = datetime.fromtimestamp(getattr(redditor, 'created_utc', 0)) author.author_osn_id = getattr(redditor, 'id', '') author.author_full_name = getattr(redditor, 'fullname', '') author.url = u'https://www.reddit.com/user/' + redditor.name return author
def _json_user_to_db_author_converter(self, user, domain='Instagram_author'): author = Author() author.name = user['username'] author.author_screen_name = author.name author.author_guid = compute_author_guid_by_author_name(author.name) author.domain = domain author.author_type = domain author.author_osn_id = user['id'] author.author_full_name = user['full_name'] author.description = user.setdefault('biography', None) author.url = 'https://www.instagram.com/' + author.author_screen_name author.profile_image_url = user['profile_pic_url'] return author
def commenter_to_author(self, commenter, photo_id): author = Author() author.name = str(commenter['authorname']) author.author_screen_name = str(commenter['path_alias']) author.author_full_name = str(commenter.get('realname', "")) author.url = str(commenter['permalink']) author.domain = str(photo_id) author.created_at = str(commenter["datecreate"]) author.author_osn_id = str(commenter['author']) author.author_guid = compute_author_guid_by_author_name( author.author_osn_id) author.author_type = 'comment' return author
def _create_author_by_citation(self, reblogged_from_metadata): author = Author() parent_post_blog_id = reblogged_from_metadata["parent_post_blog_id"] author.author_osn_id = parent_post_blog_id author.name = parent_post_blog_id author.author_guid = compute_author_guid_by_author_name(author.name) parent_post_blog_name = self._convert_to_unicode_value(reblogged_from_metadata["parent_post_blog_name"]) author.author_screen_name = parent_post_blog_name author.url = self._convert_to_unicode_value(reblogged_from_metadata["parent_post_short_url"]) author.domain = self._domain return author
def updateAuthorsData(self): list_to_add = [] for dic in self._author_prop_dict: try: author = Author() author.name = dic['author'] author.domain = unicode('Microblog') author.author_osn_id = dic['author_osn_id'] author.author_guid = dic['author_guid'] author.followers_count = dic['followers_count'] author.location = dic['location'] author.favourites_count = dic['favorite'] author.description = dic['description'] author.url = dic['url'] list_to_add.append(author) except (ValueError, TypeError, KeyError) as e: logging.warn("Failed to add author: {0} - {1}".format(author.name, e)) self._db.update_authors(list_to_add)