Commit 53c7af78 authored by litaolemo's avatar litaolemo

update

parent 98d8a309
......@@ -8,6 +8,9 @@ import json
import datetime
import time
import sys
import six
from maintenance.func_send_email_with_file import send_file_email
from typing import Dict, List
from crawler.gm_upload.gm_upload import upload, upload_file
......@@ -318,11 +321,15 @@ def write_data_into_mysql(res_data):
if not data.get("qiniu_img_list"):
return None
tractate_id = 0
if data["platform"] == "weibo":
platform_value = 11
elif data["platform"] == "douban":
platform_value = 12
try:
sql_query = """insert into api_tractate
(user_id,content,is_online,status,platform,content_level,is_excellent,create_time,last_modified,user_del,low_quality,low_quality_deal,platform_id,pgc_type,title)
values ({user_id},'{content}',{is_online},{status},{platform},{content_level},{is_excellent},'{create_time}','{last_modified}',{user_del},{low_quality},{low_quality_deal},'{platform_id}',{pgc_type},'{title}');""".format(
user_id=random.choice(user_id_list), content=data["content"], is_online=0, status=2, platform=15,
user_id=random.choice(user_id_list), content=data["content"], is_online=0, status=2, platform=platform_value,
content_level=data["level"],
is_excellent=0, create_time=now_str,
last_modified=now_str, user_del=0,
......@@ -380,6 +387,68 @@ def write_data_into_mysql(res_data):
return None
class EnumMeta(type):
"""Metaclass for Enum"""
@staticmethod
def _find_allow_types_(cls, bases):
all_types = set(six.integer_types) | {six.text_type, str}
allow_types = set()
if Enum is None: # Enum base class
assert cls == 'Enum'
return tuple(all_types)
else:
for base in bases:
if not issubclass(base, Enum):
allow_types.add(base)
if allow_types:
return tuple(all_types & allow_types)
else:
return tuple(all_types)
class Enum(six.with_metaclass(EnumMeta, object)):
"""Generic enumeration.
Derive from this class to define new enumerations.
"""
def __repr__(self):
return "<%s.%s: %r>" % (
self.__class__.__name__, self._name_, self._value_)
def __str__(self):
if self._desc_:
return "%s.%s(%s)" % (self.__class__.__name__, self._name_, self._desc_)
else:
return "%s.%s" % (self.__class__.__name__, self._name_)
def __hash__(self):
return hash(self._name_)
class TRACTATE_PLATFORM(Enum):
"""
新帖子发布来源
"""
GM = ("1", u"更美")
HERA = ("2", u"HERA后台")
DOCTOR = ("3", u"医生端")
XIAOHONGSHU = ("4", u"小红书")
WEIBO = ("5", u"微博")
SOYOUNG = ("6", u"新氧")
MARK = ("7", u"站内打卡活动")
VARIETY_SHOW_YOUNG = ("8", "选秀节目(少年之名)打榜活动")
GROUP_DETAIL = ("9", "普通小组")
GROUP_TOPIC_DETAIL = ("10", "普通小组话题")
STRATEGY_WEIBO_HOTSPOT = ("11", "策略微博热点")
STRATEGY_DOUBAN_HOTSPOT = ("12", "策略豆瓣鹅组热点")
STRATEGY_TOUTIAO = ("13", "策略头条文章")
STRATEGY_ZHIHU = ("14", "策略知乎文章")
STRATEGY_XIAOHONGSHU = ("15", "策略小红书文章")
STRATEGY_SOYOUNG = ("16", "策略新氧文章")
STRATEGY_WEIBO = ("17", "策略微博文章")
def task_main():
# 实例化数据判断规则 注意高优先级在前 低优先级在后
push_rule_class1 = push_rule(comment_count_ni=20, time_range=5, level=3)
......@@ -394,15 +463,15 @@ def task_main():
tractate_id = write_data_into_mysql(res_data)
try:
print("line394",tractate_id,res_data)
if res_data["level"] >= 1 and tractate_id:
if res_data["level"] >= 3 and tractate_id:
title_str = res_data["platform"] + "帖子内容审核"
body_str = """
问好:
有一篇新的内容需要审核,帖子号为{tractate_id}
有一篇新的{level}星内容需要审核,帖子号为{tractate_id}
内容如下:
{content}
""".format(tractate_id=tractate_id, content=res_data["content"])
""".format(tractate_id=tractate_id, content=res_data["content"],level=res_data["level"])
send_file_email("", "", email_group=["‎<hongxu@igengmei@igengmei.com>","‎<yangjiayue@igengmei.com>","‎<zhangweiwei@igengmei.com>","‎<liuyiting@igengmei.com>"], cc_group=["‎<duanyingrong@igengmei.com>","‎<litao@igengmei.com>"],
email_msg_body_str=body_str, title_str=title_str)
print("send to mysql")
......
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