修复打击过程
一个账号 打击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
|
return result['parameter'] if result else None
|
||||||
|
|
||||||
@redis_retry(max_retries=3)
|
@redis_retry(max_retries=3)
|
||||||
def item_report(self, count: int = 1):
|
def item_report(self, count: int = 20):
|
||||||
try:
|
try:
|
||||||
items = self.fetch_from_redis(count, list_key=self.report_list)
|
items = self.fetch_from_redis(count, list_key=self.report_list)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -376,16 +376,13 @@ class DBVidcon:
|
|||||||
@mysql_retry()
|
@mysql_retry()
|
||||||
def get_subsequent_report_video(self,did: int):
|
def get_subsequent_report_video(self,did: int):
|
||||||
sql = """
|
sql = """
|
||||||
SELECT
|
SELECT DISTINCT report_id
|
||||||
id,
|
FROM sh_dm_fight_records
|
||||||
report_id
|
WHERE
|
||||||
FROM
|
status = 2
|
||||||
sh_dm_fight_records
|
AND subsequent_status = 1
|
||||||
WHERE
|
AND report_time != ''
|
||||||
status = 2
|
AND mid = %s
|
||||||
AND subsequent_status = 1
|
|
||||||
AND report_time != ''
|
|
||||||
AND mid = %s
|
|
||||||
"""
|
"""
|
||||||
self.cursor.execute(sql,did)
|
self.cursor.execute(sql,did)
|
||||||
return self.cursor.fetchall()
|
return self.cursor.fetchall()
|
||||||
@ -415,10 +412,13 @@ class DBVidcon:
|
|||||||
self.flush()
|
self.flush()
|
||||||
|
|
||||||
@mysql_retry()
|
@mysql_retry()
|
||||||
def update_fight_record_status(self, id: int, report_id: int, new_status: int, errinfo: str = "",
|
def update_fight_record_status(self, ids: list[int], report_id: int, new_status: int, errinfo: str = "",
|
||||||
report_time: int = 0,
|
report_time: int = 0, subsequent_status: int = 1, mid=0):
|
||||||
subsequent_status: int = 1, mid=0):
|
if not ids:
|
||||||
sql = """
|
return # 空列表直接返回
|
||||||
|
|
||||||
|
placeholders = ','.join(['%s'] * len(ids))
|
||||||
|
sql = f"""
|
||||||
UPDATE
|
UPDATE
|
||||||
sh_dm_fight_records
|
sh_dm_fight_records
|
||||||
SET
|
SET
|
||||||
@ -427,27 +427,26 @@ class DBVidcon:
|
|||||||
updata_time = %s,
|
updata_time = %s,
|
||||||
report_id = %s,
|
report_id = %s,
|
||||||
subsequent_status = %s,
|
subsequent_status = %s,
|
||||||
report_time= %s,
|
report_time = %s,
|
||||||
mid = %s
|
mid = %s
|
||||||
WHERE
|
WHERE
|
||||||
id = %s
|
id IN ({placeholders})
|
||||||
"""
|
"""
|
||||||
now_ts = int(time.time())
|
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()
|
@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 = """
|
sql = """
|
||||||
UPDATE
|
UPDATE
|
||||||
sh_dm_fight_records
|
sh_dm_fight_records
|
||||||
SET
|
SET subsequent_status = %s,
|
||||||
subsequent_status = %s,
|
updata_time = UNIX_TIMESTAMP(),
|
||||||
updata_time = UNIX_TIMESTAMP(),
|
subsequent_info = %s
|
||||||
subsequent_info = %s
|
WHERE report_id = %s \
|
||||||
WHERE
|
"""
|
||||||
id = %s
|
self.cursor.execute(sql, (new_status, info, report_id))
|
||||||
"""
|
|
||||||
self.cursor.execute(sql, (new_status, info, ssid))
|
|
||||||
self.flush()
|
self.flush()
|
||||||
|
|
||||||
@mysql_retry()
|
@mysql_retry()
|
||||||
|
44
report.py
44
report.py
@ -1,4 +1,5 @@
|
|||||||
import argparse
|
import argparse
|
||||||
|
import json
|
||||||
import time
|
import time
|
||||||
from DB import DBVidcon, DBSA
|
from DB import DBVidcon, DBSA
|
||||||
from report_video import DailymotionClient
|
from report_video import DailymotionClient
|
||||||
@ -70,7 +71,7 @@ k = {
|
|||||||
last_main_run = 0
|
last_main_run = 0
|
||||||
last_subsequent_run = 0
|
last_subsequent_run = 0
|
||||||
|
|
||||||
MAIN_INTERVAL = 60 * 5 # 每 5 分钟执行一次
|
MAIN_INTERVAL = 60 * 60 # 每 5 分钟执行一次
|
||||||
SUBSEQUENT_INTERVAL = 60 * 60 # 每 60 分钟执行一次
|
SUBSEQUENT_INTERVAL = 60 * 60 # 每 60 分钟执行一次
|
||||||
|
|
||||||
# d.test()
|
# d.test()
|
||||||
@ -81,36 +82,39 @@ while True:
|
|||||||
# 处理主流程
|
# 处理主流程
|
||||||
if now - last_main_run >= MAIN_INTERVAL:
|
if now - last_main_run >= MAIN_INTERVAL:
|
||||||
last_main_run = now
|
last_main_run = now
|
||||||
lis = db.item_report()
|
re_list = []
|
||||||
|
idss = []
|
||||||
|
lis = db.item_report(20)
|
||||||
if len(lis) > 0:
|
if len(lis) > 0:
|
||||||
for _, li in lis:
|
for li in lis:
|
||||||
print(li)
|
item = json.loads(li[0])
|
||||||
logger.info(f"name:{li['name_title']},link:{li['link']} ")
|
re_list.append(item)
|
||||||
try:
|
idss.append(item['id'])
|
||||||
info, report_id, status, report_ts = d.process_ticket(li['name_title'], li['link'])
|
logger.info(f"name:{item['name_title']},link:{item['link']} ")
|
||||||
subsequent_status = k.get(status, 1)
|
try:
|
||||||
db.update_fight_record_status(
|
ids, info, report_id, status, report_ts = d.process_ticket(re_list)
|
||||||
li['id'], report_id, 2, f"http://{ip}:5000/image/{info}",
|
subsequent_status = k.get(status, 1)
|
||||||
report_ts, subsequent_status, MACHINE_ID
|
db.update_fight_record_status(
|
||||||
)
|
ids, report_id, 2, f"http://{ip}:5000/image/{info}",
|
||||||
db.flush()
|
report_ts, subsequent_status, MACHINE_ID
|
||||||
except Exception as e:
|
)
|
||||||
logger.error(f"ID:{li['id']}, e:{e}")
|
db.flush()
|
||||||
db.update_fight_record_status(li['id'], 0, 3, str(e), mid=MACHINE_ID)
|
except Exception as e:
|
||||||
time.sleep(60) # 出错延迟
|
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:
|
if now - last_subsequent_run >= SUBSEQUENT_INTERVAL and IsSubsequent:
|
||||||
last_subsequent_run = now
|
last_subsequent_run = now
|
||||||
subsequent_list = db.get_subsequent_report_video(MACHINE_ID)
|
subsequent_list = db.get_subsequent_report_video(MACHINE_ID)
|
||||||
if len(subsequent_list) > 0:
|
if len(subsequent_list) > 0:
|
||||||
for li in subsequent_list:
|
for li in subsequent_list:
|
||||||
rs_id = li['id']
|
|
||||||
r_id = li['report_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:
|
# try:
|
||||||
subsequent_status, info = d.report_follow_up(r_id)
|
subsequent_status, info = d.report_follow_up(r_id)
|
||||||
db.update_subsequent_status_by_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:
|
# except Exception as e:
|
||||||
# logger.logger.error(f"ID:{rs_id}, e:{e}")
|
# logger.logger.error(f"ID:{rs_id}, e:{e}")
|
||||||
|
@ -203,22 +203,35 @@ class DailymotionClient:
|
|||||||
self._do_login()
|
self._do_login()
|
||||||
|
|
||||||
@require_login
|
@require_login
|
||||||
def process_ticket(self, title, link):
|
def process_ticket(self, lis: list):
|
||||||
# titles = '\r\n'.join(title)
|
titles = "\r\n"
|
||||||
logger.info(f"Processing ticket for title: {title}, link: {link}")
|
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)
|
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.
|
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
|
1) please help remove these videos
|
||||||
2) The drama series titles are {}
|
2) The drama series titles are {}
|
||||||
""".format(title)
|
""".format(titles)
|
||||||
# likls = ["\"" + l + "\"" for l in link]
|
# likls = ["\"" + l + "\"" for l in link]
|
||||||
# links = ','.join(likls)
|
# links = ','.join(likls)
|
||||||
if self.page.query_selector("div.cf-turnstile[data-sitekey]"):
|
if self.page.query_selector("div.cf-turnstile[data-sitekey]"):
|
||||||
ok = solve_turnstile_capsolver(self.page)
|
ok = solve_turnstile_capsolver(self.page)
|
||||||
if not ok:
|
if not ok:
|
||||||
raise RuntimeError("CapSolver 处理 Turnstile 失败")
|
raise RuntimeError("CapSolver 处理 Turnstile 失败")
|
||||||
file_path = f'screenshots/{str(int(time.time()))}_{title}_{link.split("/")[-1]}.png'
|
# file_path = f'screenshots/{str(int(time.time()))}_{title}_{link.split("/")[-1]}.png'
|
||||||
self.page.screenshot(path=file_path)
|
# self.page.screenshot(path=file_path)
|
||||||
resports = self.page.locator('li.blocks-item:nth-child(8)')
|
resports = self.page.locator('li.blocks-item:nth-child(8)')
|
||||||
resports.click()
|
resports.click()
|
||||||
|
|
||||||
@ -241,7 +254,7 @@ class DailymotionClient:
|
|||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
self.page.get_by_label("Subject").fill("Copyright infringement Notification")
|
self.page.get_by_label("Subject").fill("Copyright infringement Notification")
|
||||||
time.sleep(1)
|
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)
|
time.sleep(1)
|
||||||
self.page.get_by_label("Description").nth(1).fill(description)
|
self.page.get_by_label("Description").nth(1).fill(description)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
@ -283,7 +296,7 @@ class DailymotionClient:
|
|||||||
if self.page.url != self.url:
|
if self.page.url != self.url:
|
||||||
self.page.goto(self.url, timeout=30000)
|
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
|
@require_login
|
||||||
def report_follow_up(self, report_id: str):
|
def report_follow_up(self, report_id: str):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user