def construct(self, json_file): total = len(json_file) for i in range(total): # Source collecting shot_id = json_file[i]['id'] user_id = json_file[i]['user']['id'] shot_image_url = json_file[i]['images']['normal'] # if shot_image_url is None: # shot_image_url = json_file[i]['images']['normal'] avatar_url = json_file[i]['user']['avatar_url'] shot_description = json_file[i]['description'] user_name = json_file[i]['user']['name'] view = json_file[i]['views_count'] like = json_file[i]['likes_count'] comment = json_file[i]['comments_count'] tags = json_file[i]['tags'] # animated flag flag = json_file[i]['animated'] # Record Building new_shot = Shot(shot_id) new_shot.load_description(shot_description) new_shot.load_image_url(shot_image_url) new_shot.load_popularity(view, like, comment) new_shot.load_tags(tags) new_author = Author(user_id) new_author.load_avatar_url(avatar_url) new_author.load_name(user_name) new_shot.add_author(new_author) if flag is False: self.shots[shot_id] = new_shot self.logger.info("Shot id: {} is decoded.".format(shot_id)) else: self.logger.info("Shot id: {} is omitted.".format(shot_id))