修复打击过程
一个账号 打击20条视频 4个账号 同时打击
This commit is contained in:
parent
8d0728a11f
commit
82e65d86f8
59
DB.py
59
DB.py
@ -297,7 +297,7 @@ class DBVidcon:
|
||||
return result['parameter'] if result else None
|
||||
|
||||
@redis_retry(max_retries=3)
|
||||
def item_report(self, count: int = 1):
|
||||
def item_report(self, count: int = 20):
|
||||
try:
|
||||
items = self.fetch_from_redis(count, list_key=self.report_list)
|
||||
except Exception as e:
|
||||
@ -376,16 +376,13 @@ class DBVidcon:
|
||||
@mysql_retry()
|
||||
def get_subsequent_report_video(self,did: int):
|
||||
sql = """
|
||||
SELECT
|
||||
id,
|
||||
report_id
|
||||
FROM
|
||||
sh_dm_fight_records
|
||||
WHERE
|
||||
status = 2
|
||||
AND subsequent_status = 1
|
||||
AND report_time != ''
|
||||
AND mid = %s
|
||||
SELECT DISTINCT report_id
|
||||
FROM sh_dm_fight_records
|
||||
WHERE
|
||||
status = 2
|
||||
AND subsequent_status = 1
|
||||
AND report_time != ''
|
||||
AND mid = %s
|
||||
"""
|
||||
self.cursor.execute(sql,did)
|
||||
return self.cursor.fetchall()
|
||||
@ -415,10 +412,13 @@ class DBVidcon:
|
||||
self.flush()
|
||||
|
||||
@mysql_retry()
|
||||
def update_fight_record_status(self, id: int, report_id: int, new_status: int, errinfo: str = "",
|
||||
report_time: int = 0,
|
||||
subsequent_status: int = 1, mid=0):
|
||||
sql = """
|
||||
def update_fight_record_status(self, ids: list[int], report_id: int, new_status: int, errinfo: str = "",
|
||||
report_time: int = 0, subsequent_status: int = 1, mid=0):
|
||||
if not ids:
|
||||
return # 空列表直接返回
|
||||
|
||||
placeholders = ','.join(['%s'] * len(ids))
|
||||
sql = f"""
|
||||
UPDATE
|
||||
sh_dm_fight_records
|
||||
SET
|
||||
@ -427,27 +427,26 @@ class DBVidcon:
|
||||
updata_time = %s,
|
||||
report_id = %s,
|
||||
subsequent_status = %s,
|
||||
report_time= %s,
|
||||
report_time = %s,
|
||||
mid = %s
|
||||
WHERE
|
||||
id = %s
|
||||
"""
|
||||
id IN ({placeholders})
|
||||
"""
|
||||
now_ts = int(time.time())
|
||||
self.cursor.execute(sql, (new_status, errinfo, now_ts, report_id, subsequent_status, report_time, mid, id))
|
||||
params = [new_status, errinfo, now_ts, report_id, subsequent_status, report_time, mid] + ids
|
||||
self.cursor.execute(sql, params)
|
||||
|
||||
@mysql_retry()
|
||||
def update_subsequent_status_by_id(self, ssid: int, new_status: int, info: str = ""):
|
||||
def update_subsequent_status_by_report_id(self, report_id: int, new_status: int, info: str = ""):
|
||||
sql = """
|
||||
UPDATE
|
||||
sh_dm_fight_records
|
||||
SET
|
||||
subsequent_status = %s,
|
||||
updata_time = UNIX_TIMESTAMP(),
|
||||
subsequent_info = %s
|
||||
WHERE
|
||||
id = %s
|
||||
"""
|
||||
self.cursor.execute(sql, (new_status, info, ssid))
|
||||
UPDATE
|
||||
sh_dm_fight_records
|
||||
SET subsequent_status = %s,
|
||||
updata_time = UNIX_TIMESTAMP(),
|
||||
subsequent_info = %s
|
||||
WHERE report_id = %s \
|
||||
"""
|
||||
self.cursor.execute(sql, (new_status, info, report_id))
|
||||
self.flush()
|
||||
|
||||
@mysql_retry()
|
||||
|
44
report.py
44
report.py
@ -1,4 +1,5 @@
|
||||
import argparse
|
||||
import json
|
||||
import time
|
||||
from DB import DBVidcon, DBSA
|
||||
from report_video import DailymotionClient
|
||||
@ -70,7 +71,7 @@ k = {
|
||||
last_main_run = 0
|
||||
last_subsequent_run = 0
|
||||
|
||||
MAIN_INTERVAL = 60 * 5 # 每 5 分钟执行一次
|
||||
MAIN_INTERVAL = 60 * 60 # 每 5 分钟执行一次
|
||||
SUBSEQUENT_INTERVAL = 60 * 60 # 每 60 分钟执行一次
|
||||
|
||||
# d.test()
|
||||
@ -81,36 +82,39 @@ while True:
|
||||
# 处理主流程
|
||||
if now - last_main_run >= MAIN_INTERVAL:
|
||||
last_main_run = now
|
||||
lis = db.item_report()
|
||||
re_list = []
|
||||
idss = []
|
||||
lis = db.item_report(20)
|
||||
if len(lis) > 0:
|
||||
for _, li in lis:
|
||||
print(li)
|
||||
logger.info(f"name:{li['name_title']},link:{li['link']} ")
|
||||
try:
|
||||
info, report_id, status, report_ts = d.process_ticket(li['name_title'], li['link'])
|
||||
subsequent_status = k.get(status, 1)
|
||||
db.update_fight_record_status(
|
||||
li['id'], report_id, 2, f"http://{ip}:5000/image/{info}",
|
||||
report_ts, subsequent_status, MACHINE_ID
|
||||
)
|
||||
db.flush()
|
||||
except Exception as e:
|
||||
logger.error(f"ID:{li['id']}, e:{e}")
|
||||
db.update_fight_record_status(li['id'], 0, 3, str(e), mid=MACHINE_ID)
|
||||
time.sleep(60) # 出错延迟
|
||||
for li in lis:
|
||||
item = json.loads(li[0])
|
||||
re_list.append(item)
|
||||
idss.append(item['id'])
|
||||
logger.info(f"name:{item['name_title']},link:{item['link']} ")
|
||||
try:
|
||||
ids, info, report_id, status, report_ts = d.process_ticket(re_list)
|
||||
subsequent_status = k.get(status, 1)
|
||||
db.update_fight_record_status(
|
||||
ids, report_id, 2, f"http://{ip}:5000/image/{info}",
|
||||
report_ts, subsequent_status, MACHINE_ID
|
||||
)
|
||||
db.flush()
|
||||
except Exception as e:
|
||||
logger.error(f"ID:{re_list[0]['id']}, end id{re_list[-1]['id']}, e:{e}")
|
||||
db.update_fight_record_status(idss, 0, 3, str(e), mid=MACHINE_ID)
|
||||
time.sleep(60) # 出错延迟
|
||||
|
||||
if now - last_subsequent_run >= SUBSEQUENT_INTERVAL and IsSubsequent:
|
||||
last_subsequent_run = now
|
||||
subsequent_list = db.get_subsequent_report_video(MACHINE_ID)
|
||||
if len(subsequent_list) > 0:
|
||||
for li in subsequent_list:
|
||||
rs_id = li['id']
|
||||
r_id = li['report_id']
|
||||
logger.info(f"subsequent id:{rs_id},report_id:{r_id} ")
|
||||
logger.info(f"subsequent report_id:{r_id} ")
|
||||
# try:
|
||||
subsequent_status, info = d.report_follow_up(r_id)
|
||||
db.update_subsequent_status_by_id(
|
||||
rs_id, subsequent_status, f"http://{ip}:5000/image/{info}"
|
||||
r_id, subsequent_status, f"http://{ip}:5000/image/{info}"
|
||||
)
|
||||
# except Exception as e:
|
||||
# logger.logger.error(f"ID:{rs_id}, e:{e}")
|
||||
|
@ -203,22 +203,35 @@ class DailymotionClient:
|
||||
self._do_login()
|
||||
|
||||
@require_login
|
||||
def process_ticket(self, title, link):
|
||||
# titles = '\r\n'.join(title)
|
||||
logger.info(f"Processing ticket for title: {title}, link: {link}")
|
||||
def process_ticket(self, lis: list):
|
||||
titles = "\r\n"
|
||||
links = ""
|
||||
ids= []
|
||||
title = ""
|
||||
link = ""
|
||||
assignment = True
|
||||
for li in lis:
|
||||
if assignment:
|
||||
title = li['name_title']
|
||||
link = li['link']
|
||||
assignment = False
|
||||
ids.append(li['id'])
|
||||
titles += li['name_title'] + ",\r\n"
|
||||
links += li['link'] + ",\r\n"
|
||||
logger.info(f"Processing ticket for title: {titles}, link: {links}")
|
||||
self.page.goto(self.url, timeout=3000)
|
||||
description = """We request that you take immediate actionto stop the infringing activity, take steps to ensure that iQIYI Content is notre-posted on, re-linked to, or otherwise available through your site. Pleaseinform us of the actions you have taken and their results.
|
||||
1) please help remove these videos
|
||||
2) The drama series titles are {}
|
||||
""".format(title)
|
||||
""".format(titles)
|
||||
# likls = ["\"" + l + "\"" for l in link]
|
||||
# links = ','.join(likls)
|
||||
if self.page.query_selector("div.cf-turnstile[data-sitekey]"):
|
||||
ok = solve_turnstile_capsolver(self.page)
|
||||
if not ok:
|
||||
raise RuntimeError("CapSolver 处理 Turnstile 失败")
|
||||
file_path = f'screenshots/{str(int(time.time()))}_{title}_{link.split("/")[-1]}.png'
|
||||
self.page.screenshot(path=file_path)
|
||||
# file_path = f'screenshots/{str(int(time.time()))}_{title}_{link.split("/")[-1]}.png'
|
||||
# self.page.screenshot(path=file_path)
|
||||
resports = self.page.locator('li.blocks-item:nth-child(8)')
|
||||
resports.click()
|
||||
|
||||
@ -241,7 +254,7 @@ class DailymotionClient:
|
||||
time.sleep(1)
|
||||
self.page.get_by_label("Subject").fill("Copyright infringement Notification")
|
||||
time.sleep(1)
|
||||
self.page.get_by_label("Please indicate the URL of the video(s) you would like to report*").fill(link)
|
||||
self.page.get_by_label("Please indicate the URL of the video(s) you would like to report*").fill(links)
|
||||
time.sleep(1)
|
||||
self.page.get_by_label("Description").nth(1).fill(description)
|
||||
time.sleep(1)
|
||||
@ -283,7 +296,7 @@ class DailymotionClient:
|
||||
if self.page.url != self.url:
|
||||
self.page.goto(self.url, timeout=30000)
|
||||
|
||||
return file_path, report_id, subsequent_status, timestamp
|
||||
return ids, file_path, report_id, subsequent_status, timestamp
|
||||
|
||||
@require_login
|
||||
def report_follow_up(self, report_id: str):
|
||||
|
Loading…
x
Reference in New Issue
Block a user