|
@@ -31,67 +31,64 @@ class AuthorLimit(object):
|
|
def __init__(self, mode, platform):
|
|
def __init__(self, mode, platform):
|
|
self.mode = mode
|
|
self.mode = mode
|
|
self.platform = platform
|
|
self.platform = platform
|
|
- self.limit_tag_dict = {"352": "余海涛", "353": "罗情", "53": "范军", "51": "鲁涛", "131": False}
|
|
|
|
|
|
+ self.limit_tag_dict = {
|
|
|
|
+ "余海涛": "352",
|
|
|
|
+ "罗情": "353",
|
|
|
|
+ "范军": "53",
|
|
|
|
+ "鲁涛": "51"
|
|
|
|
+ }
|
|
|
|
|
|
def find_tag(self, uid):
|
|
def find_tag(self, uid):
|
|
"""
|
|
"""
|
|
- 通过 uid 去找符合标准的 tag
|
|
|
|
|
|
+ 判断 uid 是否存在changsha_user_accounts中
|
|
"""
|
|
"""
|
|
- sql = f"""select tag from crawler_user_v3 where uid={uid};"""
|
|
|
|
|
|
+ sql = f"""select user_name from changsha_user_accounts where piaoquan_account_id = {uid};"""
|
|
result = MysqlHelper.get_values(
|
|
result = MysqlHelper.get_values(
|
|
log_type=self.mode, crawler=self.platform, env="prod", sql=sql
|
|
log_type=self.mode, crawler=self.platform, env="prod", sql=sql
|
|
)
|
|
)
|
|
- tags = result[0]["tag"]
|
|
|
|
- if tags:
|
|
|
|
- tags = tags.split(",")
|
|
|
|
- if "131" in tags:
|
|
|
|
- return None
|
|
|
|
- else:
|
|
|
|
- for tag in tags:
|
|
|
|
- if self.limit_tag_dict.get(tag):
|
|
|
|
- return tag
|
|
|
|
- return None
|
|
|
|
|
|
+ return result
|
|
|
|
|
|
def author_limitation(self, user_id):
|
|
def author_limitation(self, user_id):
|
|
"""
|
|
"""
|
|
限制账号, 服务长沙四名同学
|
|
限制账号, 服务长沙四名同学
|
|
"""
|
|
"""
|
|
- return True
|
|
|
|
- # if self.mode == "author":
|
|
|
|
- # tag = self.find_tag(user_id)
|
|
|
|
- # if tag:
|
|
|
|
- # AliyunLogger.logging(
|
|
|
|
- # code="8807",
|
|
|
|
- # platform=self.platform,
|
|
|
|
- # mode=self.mode,
|
|
|
|
- # env="prod",
|
|
|
|
- # message="找到个人账号,{}".format(tag)
|
|
|
|
- # )
|
|
|
|
- # R = RedisClient()
|
|
|
|
- # if R.connect():
|
|
|
|
- # tag_count = R.select(tag)
|
|
|
|
- # if tag_count:
|
|
|
|
- # tag_count = int(tag_count.decode("utf-8"))
|
|
|
|
- # if tag_count <= 300:
|
|
|
|
- # tag_count += 1
|
|
|
|
- # expire_seconds = generate_expire_time()
|
|
|
|
- # R.insert(
|
|
|
|
- # key=tag, value=tag_count, expire_time=expire_seconds
|
|
|
|
- # )
|
|
|
|
- # return True
|
|
|
|
- # else:
|
|
|
|
- # # 报警
|
|
|
|
- # return False
|
|
|
|
- # else:
|
|
|
|
- # tag_count = 1
|
|
|
|
- # expire_seconds = generate_expire_time()
|
|
|
|
- # R.insert(
|
|
|
|
- # key=tag, value=tag_count, expire_time=expire_seconds
|
|
|
|
- # )
|
|
|
|
- # return True
|
|
|
|
- # else:
|
|
|
|
- # return True
|
|
|
|
- # else:
|
|
|
|
- # return True
|
|
|
|
- # else:
|
|
|
|
- # return True
|
|
|
|
|
|
+ if self.mode == "author":
|
|
|
|
+ result = self.find_tag(user_id)
|
|
|
|
+ if result:
|
|
|
|
+ user_name = result[0]['user_name']
|
|
|
|
+ AliyunLogger.logging(
|
|
|
|
+ code="8807",
|
|
|
|
+ platform=self.platform,
|
|
|
|
+ mode=self.mode,
|
|
|
|
+ env="prod",
|
|
|
|
+ message="找到个人账号,{}".format(user_name)
|
|
|
|
+ )
|
|
|
|
+ R = RedisClient()
|
|
|
|
+ if R.connect():
|
|
|
|
+ tag = self.limit_tag_dict[user_name]
|
|
|
|
+ tag_count = R.select(tag)
|
|
|
|
+ if tag_count:
|
|
|
|
+ tag_count = int(tag_count.decode("utf-8"))
|
|
|
|
+ if tag_count <= 300:
|
|
|
|
+ tag_count += 1
|
|
|
|
+ expire_seconds = generate_expire_time()
|
|
|
|
+ R.insert(
|
|
|
|
+ key=tag, value=tag_count, expire_time=expire_seconds
|
|
|
|
+ )
|
|
|
|
+ return True
|
|
|
|
+ else:
|
|
|
|
+ # 报警
|
|
|
|
+ return False
|
|
|
|
+ else:
|
|
|
|
+ tag_count = 1
|
|
|
|
+ expire_seconds = generate_expire_time()
|
|
|
|
+ R.insert(
|
|
|
|
+ key=tag, value=tag_count, expire_time=expire_seconds
|
|
|
|
+ )
|
|
|
|
+ return True
|
|
|
|
+ else:
|
|
|
|
+ return True
|
|
|
|
+ else:
|
|
|
|
+ return True
|
|
|
|
+ else:
|
|
|
|
+ return True
|