Commit a84e7491 authored by 钟尚武's avatar 钟尚武

Merge branch 'feature/weibo' into 'test'

微博数据入库

See merge request alpha/saturn!101
parents 40e2dfa4 73481de5
...@@ -15,7 +15,7 @@ from engine.logger import info_logger, error_logger, logging_exception ...@@ -15,7 +15,7 @@ from engine.logger import info_logger, error_logger, logging_exception
IMAGE_SUFFIX = '-w' IMAGE_SUFFIX = '-w'
FILE_PATH = '/Users/zhongshangwu/workspace/gengmei/like/saturn/api/management/commands/' FILE_PATH = '/Users/zhongshangwu/workspace/gengmei/like/saturn/weibo/'
# TODO # TODO
# 1. 图片裁剪上传 # 1. 图片裁剪上传
...@@ -72,10 +72,7 @@ class Command(BaseCommand): ...@@ -72,10 +72,7 @@ class Command(BaseCommand):
def get_json_data_from_dir(self, is_topic=None, is_pictorial=None): def get_json_data_from_dir(self, is_topic=None, is_pictorial=None):
# 获取目录文件数据 # 获取目录文件数据
ret = [] ret = []
if is_topic: file_path = FILE_PATH
file_path = FILE_PATH + 'topic/'
if is_pictorial:
file_path = FILE_PATH + 'pictorial/'
filenames = [] filenames = []
for _, _, names in os.walk(file_path): for _, _, names in os.walk(file_path):
filenames = names filenames = names
...@@ -141,7 +138,7 @@ class Command(BaseCommand): ...@@ -141,7 +138,7 @@ class Command(BaseCommand):
return comment, replies return comment, replies
images = [] images = []
if not comment["images"]: if not comment["images"] and len(reply) > 1:
normal_images = set(reply[0]["images"]) normal_images = set(reply[0]["images"])
for info in reply[1:]: for info in reply[1:]:
...@@ -213,7 +210,7 @@ class Command(BaseCommand): ...@@ -213,7 +210,7 @@ class Command(BaseCommand):
if not comment: if not comment:
continue continue
if comment["images"]: # -> to topic if comment["images"] and len(self.stats[weibo_id]["topics"]) < 50: # -> to topic
images = self.image_info(comment.pop('images')) images = self.image_info(comment.pop('images'))
topic = { topic = {
# 'id': pictorial_id + str(idx), # 'id': pictorial_id + str(idx),
...@@ -244,7 +241,6 @@ class Command(BaseCommand): ...@@ -244,7 +241,6 @@ class Command(BaseCommand):
else: # -> to pictorial comment else: # -> to pictorial comment
top_comments_obj = rpc_invoker['venus/community/crawl/replys'](data=[comment], platform=platform, pictorial_id=pictorial_id).unwrap() top_comments_obj = rpc_invoker['venus/community/crawl/replys'](data=[comment], platform=platform, pictorial_id=pictorial_id).unwrap()
if not top_comments_obj.get("reply_ids"): if not top_comments_obj.get("reply_ids"):
self.top_pictorial_error_comments.append(comment) self.top_pictorial_error_comments.append(comment)
else: else:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment