feat: 添加获取和更新后续视频报告状态的方法
This commit is contained in:
parent
239b16b938
commit
fb098565ce
32
DB.py
32
DB.py
@ -323,6 +323,23 @@ class DBVidcon:
|
|||||||
sh_dm_fight_records
|
sh_dm_fight_records
|
||||||
WHERE
|
WHERE
|
||||||
status = 1
|
status = 1
|
||||||
|
LIMIT 1
|
||||||
|
"""
|
||||||
|
self.cursor.execute(sql)
|
||||||
|
return self.cursor.fetchall()
|
||||||
|
|
||||||
|
@mysql_retry()
|
||||||
|
def get_subsequent_report_video(self):
|
||||||
|
sql = """
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
report_id
|
||||||
|
FROM
|
||||||
|
sh_dm_fight_records
|
||||||
|
WHERE
|
||||||
|
status = 2
|
||||||
|
AND subsequent_status = 1
|
||||||
|
AND report_time != ''
|
||||||
LIMIT 10
|
LIMIT 10
|
||||||
"""
|
"""
|
||||||
self.cursor.execute(sql)
|
self.cursor.execute(sql)
|
||||||
@ -348,6 +365,21 @@ class DBVidcon:
|
|||||||
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, id))
|
self.cursor.execute(sql, (new_status, errinfo, now_ts, report_id, subsequent_status, report_time, id))
|
||||||
|
|
||||||
|
@mysql_retry()
|
||||||
|
def update_subsequent_status_by_id(self, ssid: 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))
|
||||||
|
self.flush()
|
||||||
|
|
||||||
@mysql_retry()
|
@mysql_retry()
|
||||||
def update_video_ts_status(self):
|
def update_video_ts_status(self):
|
||||||
sql = """
|
sql = """
|
||||||
|
25
report.py
25
report.py
@ -13,6 +13,8 @@ k = {
|
|||||||
"awaiting your reply":3,
|
"awaiting your reply":3,
|
||||||
}
|
}
|
||||||
while True:
|
while True:
|
||||||
|
start_time = int(time.time())
|
||||||
|
|
||||||
lis = db.get_report_video()
|
lis = db.get_report_video()
|
||||||
if len(lis) == 0:
|
if len(lis) == 0:
|
||||||
time.sleep(60 * 5)
|
time.sleep(60 * 5)
|
||||||
@ -24,8 +26,29 @@ while True:
|
|||||||
subsequent_status = k.get(status, 1)
|
subsequent_status = k.get(status, 1)
|
||||||
db.update_fight_record_status(li['id'],report_id, 2, f"http://123.58.197.91:5000/image/{info}", report_ts, subsequent_status)
|
db.update_fight_record_status(li['id'],report_id, 2, f"http://123.58.197.91:5000/image/{info}", report_ts, subsequent_status)
|
||||||
db.flush()
|
db.flush()
|
||||||
time.sleep(5 * 60)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.logger.error(f"ID:{li['id']}, e:{e}")
|
logger.logger.error(f"ID:{li['id']}, e:{e}")
|
||||||
db.update_fight_record_status(li['id'], 3, str(e))
|
db.update_fight_record_status(li['id'], 3, str(e))
|
||||||
time.sleep(1 * 60)
|
time.sleep(1 * 60)
|
||||||
|
|
||||||
|
|
||||||
|
subsequent_list = db.get_subsequent_report_video()
|
||||||
|
if len(subsequent_list) == 0:
|
||||||
|
time.sleep(60 * 5)
|
||||||
|
else:
|
||||||
|
for li in subsequent_list:
|
||||||
|
rs_id = li['id']
|
||||||
|
r_id = li['report_id']
|
||||||
|
logger.logger.info(f"subsequent id:{rs_id},report_id:{r_id} ")
|
||||||
|
try:
|
||||||
|
subsequent_status, info = d.report_follow_up(r_id)
|
||||||
|
db.update_subsequent_status_by_id(rs_id, subsequent_status, info)
|
||||||
|
except Exception as e:
|
||||||
|
logger.logger.error(f"ID:{rs_id}, e:{e}")
|
||||||
|
db.update_subsequent_status_by_id(rs_id, 1, str(e))
|
||||||
|
|
||||||
|
used = int(time.time() - start_time)
|
||||||
|
remain = max(0, 60 * 5 - used)
|
||||||
|
if remain > 0:
|
||||||
|
logger.logger.info(f"当前轮耗时 {used:.1f} 秒,休眠 {remain:.1f} 秒")
|
||||||
|
time.sleep(remain)
|
@ -3,8 +3,9 @@ import functools
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from sys import platform
|
||||||
import requests
|
import requests
|
||||||
|
from asgiref.timeout import timeout
|
||||||
from playwright.sync_api import (
|
from playwright.sync_api import (
|
||||||
sync_playwright,
|
sync_playwright,
|
||||||
TimeoutError as PlaywrightTimeoutError,
|
TimeoutError as PlaywrightTimeoutError,
|
||||||
@ -91,16 +92,23 @@ class DailymotionClient:
|
|||||||
EMAIL = "copyright@qiyi.com"
|
EMAIL = "copyright@qiyi.com"
|
||||||
PASSWORD = "ppsIQIYI2018@"
|
PASSWORD = "ppsIQIYI2018@"
|
||||||
|
|
||||||
def __init__(self, headless: bool = False):
|
def __init__(self, headless: bool = None):
|
||||||
self.email = self.EMAIL
|
self.email = self.EMAIL
|
||||||
self.password = self.PASSWORD
|
self.password = self.PASSWORD
|
||||||
self.headless = headless
|
self.headless = headless
|
||||||
self.check_interval = 60 * 60
|
self.check_interval = 60 * 60
|
||||||
|
if self.headless is None:
|
||||||
|
self.headless = platform == "linux" or platform == "linux2"
|
||||||
|
|
||||||
|
if self.headless:
|
||||||
|
proxy = None
|
||||||
|
else:
|
||||||
|
proxy={'server': 'http://127.0.0.1:7890'}
|
||||||
|
|
||||||
self._pw = sync_playwright().start()
|
self._pw = sync_playwright().start()
|
||||||
self.browser: Browser = self._pw.chromium.launch(
|
self.browser: Browser = self._pw.chromium.launch(
|
||||||
headless=self.headless,
|
headless=self.headless,
|
||||||
proxy={'server': 'http://127.0.0.1:7890'}
|
proxy=proxy,
|
||||||
)
|
)
|
||||||
self.context = self.browser.new_context(
|
self.context = self.browser.new_context(
|
||||||
user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
|
user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
|
||||||
@ -270,35 +278,50 @@ class DailymotionClient:
|
|||||||
def report_follow_up(self, report_id: str):
|
def report_follow_up(self, report_id: str):
|
||||||
txt = "I am the authorized agent of Beijing iQIYI Technology Co., Ltd., responsible for dealing with unauthorized overseas distribution of pirated videos of our works.We have confirmed that the above links contain infringing content and we insist on requesting to takedown. Thank you!"
|
txt = "I am the authorized agent of Beijing iQIYI Technology Co., Ltd., responsible for dealing with unauthorized overseas distribution of pirated videos of our works.We have confirmed that the above links contain infringing content and we insist on requesting to takedown. Thank you!"
|
||||||
self.page.goto("https://faq.dailymotion.com/hc/en-us/requests/{}".format(report_id), timeout=30000)
|
self.page.goto("https://faq.dailymotion.com/hc/en-us/requests/{}".format(report_id), timeout=30000)
|
||||||
self.page.wait_for_load_state("networkidle", timeout=3000)
|
self.page.wait_for_selector("span.status-label", timeout=30000)
|
||||||
|
|
||||||
status_raw = self.page.locator("span.status-label").text_content()
|
status_raw = self.page.locator("span.status-label").text_content()
|
||||||
subsequent_status = status_raw.strip().lower() if status_raw else None
|
subsequent_status = status_raw.strip().lower() if status_raw else None
|
||||||
if "awaiting your reply" in subsequent_status:
|
if "awaiting your reply" in subsequent_status:
|
||||||
pass
|
span_show = self.page.locator('span.comment-show-container-content')
|
||||||
# TODO: 处理其他状态
|
if span_show.count() > 0:
|
||||||
elif "open" in subsequent_status:
|
span_show.nth(0).click()
|
||||||
pass
|
textarea = self.page.locator('#request_comment_body')
|
||||||
# 处理 Open 状态
|
textarea.fill(txt)
|
||||||
elif "solved" in subsequent_status:
|
self.page.get_by_role("button", name="Submit").click()
|
||||||
# 处理 Solved 状态
|
self.page.wait_for_selector("span.status-label", timeout=30000)
|
||||||
return
|
|
||||||
|
|
||||||
def close(self):
|
span_show = self.page.locator('span.comment-show-container-content')
|
||||||
try:
|
if span_show.count() > 0:
|
||||||
self.page.close()
|
span_show.nth(0).click()
|
||||||
except Exception:
|
pic_path = f'screenshots/{str(int(time.time()))}_{report_id}.png'
|
||||||
pass
|
self.page.screenshot(path=pic_path)
|
||||||
try:
|
return 1
|
||||||
self.browser.close()
|
|
||||||
except Exception:
|
elif "open" in subsequent_status:
|
||||||
pass
|
return 1,""
|
||||||
try:
|
# 处理 Open 状态
|
||||||
self._pw.stop()
|
|
||||||
except Exception:
|
elif "solved" in subsequent_status:
|
||||||
pass
|
# 处理 Solved 状态
|
||||||
|
return 2,""
|
||||||
|
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
try:
|
||||||
|
self.page.close()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
self.browser.close()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
self._pw.stop()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
dm = DailymotionClient()
|
dm = DailymotionClient()
|
||||||
dm.process_ticket()
|
dm.report_follow_up("2990081")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user