feat: 添加视频报告功能并优化数据库操作
This commit is contained in:
parent
b3343e1034
commit
da4a5ac828
36
DB.py
36
DB.py
@ -309,6 +309,42 @@ class DBVidcon:
|
|||||||
self.redis.lpush(self.l2_list_key, *raws)
|
self.redis.lpush(self.l2_list_key, *raws)
|
||||||
logger.info(f"[回滚l2] 已退回 {len(raws)} 条")
|
logger.info(f"[回滚l2] 已退回 {len(raws)} 条")
|
||||||
|
|
||||||
|
|
||||||
|
@mysql_retry()
|
||||||
|
def get_report_video(self):
|
||||||
|
sql = """
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
name_title,
|
||||||
|
link
|
||||||
|
FROM
|
||||||
|
sh_dm_fight_records
|
||||||
|
WHERE
|
||||||
|
status = 1
|
||||||
|
"""
|
||||||
|
self.cursor.execute(sql)
|
||||||
|
return self.cursor.fetchall()
|
||||||
|
|
||||||
|
@mysql_retry()
|
||||||
|
def update_fight_record_status(self, record_id: int, new_status: int, errinfo: str = ""):
|
||||||
|
sql = """
|
||||||
|
UPDATE
|
||||||
|
sh_dm_fight_records
|
||||||
|
SET
|
||||||
|
status = %s,
|
||||||
|
errinfo = %s,
|
||||||
|
updata_time = %s
|
||||||
|
WHERE
|
||||||
|
id = %s
|
||||||
|
"""
|
||||||
|
now_ts = int(time.time())
|
||||||
|
self.cursor.execute(sql, (new_status, errinfo, now_ts, record_id))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@mysql_retry()
|
@mysql_retry()
|
||||||
def upsert_video(self, data: dict):
|
def upsert_video(self, data: dict):
|
||||||
logger.info(fr"DB处理->{data.get('v_xid')},\tlevel->{data.get('level')}")
|
logger.info(fr"DB处理->{data.get('v_xid')},\tlevel->{data.get('level')}")
|
||||||
|
16
report.py
Normal file
16
report.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
from DB import DBVidcon, DBSA
|
||||||
|
from report_video import DailymotionClient
|
||||||
|
|
||||||
|
db = DBVidcon()
|
||||||
|
d = DailymotionClient()
|
||||||
|
|
||||||
|
|
||||||
|
while True:
|
||||||
|
lis = db.get_report_video()
|
||||||
|
for li in lis:
|
||||||
|
try:
|
||||||
|
info = d.process_ticket(li['name_title'], li['link'])
|
||||||
|
db.update_fight_record_status(li['id'], 2, info)
|
||||||
|
db.flush()
|
||||||
|
except Exception as e:
|
||||||
|
db.update_fight_record_status(li['id'],3,str(e))
|
@ -26,7 +26,7 @@ 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 = True):
|
||||||
self.email = self.EMAIL
|
self.email = self.EMAIL
|
||||||
self.password = self.PASSWORD
|
self.password = self.PASSWORD
|
||||||
self.headless = headless
|
self.headless = headless
|
||||||
@ -43,7 +43,7 @@ class DailymotionClient:
|
|||||||
|
|
||||||
self._last_check_ts = 0
|
self._last_check_ts = 0
|
||||||
self._last_check_result = False
|
self._last_check_result = False
|
||||||
|
os.makedirs('screenshots', exist_ok=True)
|
||||||
self.page.goto(self.url)
|
self.page.goto(self.url)
|
||||||
|
|
||||||
def _do_login(self) -> None:
|
def _do_login(self) -> None:
|
||||||
@ -82,6 +82,8 @@ class DailymotionClient:
|
|||||||
# 等待跳回
|
# 等待跳回
|
||||||
self.page.wait_for_url(self.url, timeout=30000)
|
self.page.wait_for_url(self.url, timeout=30000)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
self._last_check_ts = time.time()
|
||||||
|
self._last_check_result = True
|
||||||
|
|
||||||
def _detect_login(self) -> bool:
|
def _detect_login(self) -> bool:
|
||||||
self.page.goto(self.url, timeout=30000)
|
self.page.goto(self.url, timeout=30000)
|
||||||
@ -137,9 +139,9 @@ 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()
|
self.page.get_by_label("Please indicate the URL of the video(s) you would like to report*").fill(link)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
self.page.get_by_label("Description").fill(description)
|
self.page.get_by_label("Description").nth(1).fill(description)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
self.page.get_by_label("I state in good faith", exact=False).check()
|
self.page.get_by_label("I state in good faith", exact=False).check()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
@ -156,10 +158,13 @@ class DailymotionClient:
|
|||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
self.page.get_by_role("button", name="Submit").click()
|
self.page.get_by_role("button", name="Submit").click()
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
file_path = f'screenshots/{str(int(time.time()))}_{title}_{link}.png'
|
||||||
|
self.page.screenshot(path=file_path)
|
||||||
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
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
try:
|
try:
|
||||||
self.page.close()
|
self.page.close()
|
0
screenshots_flask.py
Normal file
0
screenshots_flask.py
Normal file
46
test2.py
Normal file
46
test2.py
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import requests
|
||||||
|
headers = {
|
||||||
|
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
|
||||||
|
"accept-language": "zh-CN,zh;q=0.9",
|
||||||
|
"cache-control": "no-cache",
|
||||||
|
"content-type": "application/x-www-form-urlencoded",
|
||||||
|
"origin": "https://faq.dailymotion.com",
|
||||||
|
"pragma": "no-cache",
|
||||||
|
"priority": "u=0, i",
|
||||||
|
"referer": "https://faq.dailymotion.com/hc/en-us/requests/new?ticket_form_id=136048",
|
||||||
|
"sec-ch-ua": "\"Chromium\";v=\"136\", \"Microsoft Edge\";v=\"136\", \"Not.A/Brand\";v=\"99\"",
|
||||||
|
"sec-ch-ua-mobile": "?0",
|
||||||
|
"sec-ch-ua-platform": "\"Windows\"",
|
||||||
|
"sec-fetch-dest": "document",
|
||||||
|
"sec-fetch-mode": "navigate",
|
||||||
|
"sec-fetch-site": "same-origin",
|
||||||
|
"sec-fetch-user": "?1",
|
||||||
|
"upgrade-insecure-requests": "1",
|
||||||
|
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36 Edg/136.0.0.0"
|
||||||
|
}
|
||||||
|
cookies = {'__cf_bm': '5p5XdlgJwCwEVb04rcGa1__.kAFxCJkqi_EaMAenlFc-1748939566-1.0.1.1-2nv40QIELoyIWTsxV091z7UNpt4ZL6c2BhlXPNYsqoEyPMBLy08jytaB4ue9OdgSY53JT.mJ9u0ZV2vOGdk_2Ct90JrwqsCK6nirTPAUt_E', '_cfuvid': 'l.EdbUtZDtbp.RJCJOTI0tpJ9OYVMZWzE6Ml7xSi1qQ-1748939566473-0.0.1.1-604800000', 'dmvk': '683eb331c93b5', 'ts': '161431', 'v1st': '0126e707-0bf0-4a41-be9e-a263c2f22f92', 'ff': 'on', 'lang': 'zh_CN', 'usprivacy': '1---', 'dmaid': '7bbd9c5e-845e-439d-9173-4ce2c1fa95ce', 'cookie_policy_closed': '1', 'access_token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhaWQiOiJmMWEzNjJkMjg4YzFiOTgwOTljNyIsInJvbCI6ImNhbi1tYW5hZ2UtcGFydG5lcnMtcmVwb3J0cyBjYW4tcmVhZC12aWRlby1zdHJlYW1zIGNhbi1zcG9vZi1jb3VudHJ5IGNhbi1hZG9wdC11c2Vyc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CI6IkFGODQ5REQ3M0E1ODYzQ0Q3RDk3RDBCQUIwNzIyNDNCIn0.NWtmCZtraLZB1m3zS8Y6zmJoEZL5dgIElz_PJS0RTeA', 'refresh_token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjaWQiOiJmMWEzNjJkMjg4YzFiOTgwOTljNyIsImxydCI6IjBhN2FkZjQ3NmUxMmE3MDU5ODhiOWYxMjBkNzRhNTI1MmE3NTFhYzYiLCJpYXQiOjE3NDg5Mzk1NzUsImV4cCI6MTc1Njk3NDc3NSwiZG12IjoiMSIsInN1YiI6IngyNzB5a2QiLCJraWQiOiJBQUE4NkFFMDk0OTk1MjIyREMyMUIxMjJBRTY5NTM0NiJ9.orbhcNPSdZThBdpj5buQGHqBxu22RrtPRfiJKxD6wco', 'sdx': '6pRlxw4I_iV2wjrD-1AZT_wb7ZMmnLTGeUp4z_csYmrbuuEzJ8pLYo9v6i3WipPM', '_zendesk_shared_session': '-dlRsWTNQeExhdjdqTTVidDZlcFBaN3R4aVk2VHY0L3FIUHZvWkdiNTdwbkFuMU9QeENhVFZhazlhTkxOWGV0S0gyTDlnMGo0U2szaTJJMWl6TTRCYklHMzFFL1g3WDMyaWlCNmVTWVNkR01JN3YwNlBwNVV6ZTZYZGJNa3lXQVctLWdoUWtxMXJJbXArMFNvbGRsQ2tWdEE9PQ%3D%3D--8bc94ffb0b735b671aebdedc3f41824a4f393870', '_zendesk_authenticated': '1', '_zendesk_cookie': 'BAhJIhl7ImRldmljZV90b2tlbnMiOnt9fQY6BkVU--0bf2100788cb010d0183feca16aaf88ccaf719ca', '_zendesk_session': 'N4mJviwE36oOucGR21%2FY5Qvi5raDNGTh7t%2BXZBJlOttPb9s%2FJA4z6r1ZLrXMvaMajg56tOFb96tb2oc%2B3S%2FKJfQJtYPkMs%2BM7Qp%2FFT%2BnJvBZ69iLaao2fKSUXxzHTN1veKOulyFnsdSQEL77Jjy%2BeHcxhIvWbFkbaOTKFDvKqH9n3%2B5n29uQ674uCBw0YN4Gjh8NLsJaXfb6hnohjPuWYMJpXdXXr%2BsnkgwpI30b0qvoKfh89Murpwyyi0%2FG6pDQDo2kDEPFRTE7xgA0WmpBcuPMFglSQRjZlt40FVMG%2B6Ai1BPoh%2BB19379Ltj6dJokE%2BirZIUzC7lQtznJTsRQ473GwmiqgSmoyPiH8jHNWvHsU3Kf%2FuQy1tenbaIRvMAEEOOEro%2BNS7emJKhnW7GqIiV9Wc%2BCZDka6H1GfrFy0OBUHhAMxqjsynMDhoNcYYZlFgiZO6VgaNtJCCaLT6jIT2NO7U2HzdHS%2BxhZqi2OCJ72lcC36xonWBKalR3T%2Ft2co%2FEHbw%3D%3D--FlvBP1iaEsCoCdIO--btifX85nvBy73Hiv%2Bo49lA%3D%3D', '_help_center_session': 'ZGNuRFFLY29RcEpZMWpZK085emJKTElEQVRKYTRkcVluWUd2b3Q1d25QR3hTTXBkYnhsdVQ4dmZ1UFdDMDBSNkE1REE2TDdhYm1mSHY2SXhpeS9iSEs4ZmtmQzZjeE14TFZHdmJ0c0Q5YXVoL3RQV0w1TmE2c0tVU3lnZzlrMys5MEpPQ3pKOXRDQmErdVl3L3VMOThzM2dBemRJVWJUOStYcnc2QW8va1dVamxPOG1FOHRkWnFSY1JEY3JpcTZtZW9kVEVsemdjUHhjQlpoWWgrdDFJZz09LS1naGh5RnFFcWl0WHdNL0RlNzJROHN3PT0%3D--d8b0ef12def3a63cff03cfa1cd30040403c934b0'}
|
||||||
|
url = "https://faq.dailymotion.com/hc/en-us/requests"
|
||||||
|
data = {
|
||||||
|
"utf8": "✓",
|
||||||
|
"authenticity_token": "hc:requests:client:81RVgWn01YdQitELJBNZPesWKwaUQK0SXIaYjcdPMN9v9Y4im9p4kokDa693mVxFM_dwndUXVvlNw_jutz_iNQ",
|
||||||
|
"request%5Bticket_form_id%5D": "136048",
|
||||||
|
"request%5Bcollaborators%5D%5B%5D": "duke.chen@dailymotion.com",
|
||||||
|
"request%5Bcustom_fields%5D%5B360008684839%5D": "__dc.copyright_user_protection_-_copyright__",
|
||||||
|
"request%5Bcustom_fields%5D%5B30150188%5D": "copyrightform-notification",
|
||||||
|
"request%5Bcustom_fields%5D%5B25089567%5D": "legal_entity",
|
||||||
|
"request%5Bcustom_fields%5D%5B25159868%5D": "Beijing iQIYI Science & Technology Co.,Ltd",
|
||||||
|
"request%5Bcustom_fields%5D%5B4869133282962%5D": "Legal Department",
|
||||||
|
"request%5Bsubject%5D": "Copyright infringement Notification",
|
||||||
|
"request%5Bcustom_fields%5D%5B25613698%5D": "https://www.dailymotion.com/video/x925b9i",
|
||||||
|
"request%5Bdescription%5D": "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.\r\n1) please help remove these videos\r\n2) The drama series titles are \"UK street food showdown: Which UK city has the best street cuisine?\"\r\n",
|
||||||
|
"request%5Bdescription_mimetype%5D": "text/plain",
|
||||||
|
"request%5Bcustom_fields%5D%5B4769880845586%5D": "on",
|
||||||
|
"request%5Bcustom_fields%5D%5B25626417%5D": "on",
|
||||||
|
"request%5Bcustom_fields%5D%5B4769797363346%5D": "off",
|
||||||
|
"request%5Bcustom_fields%5D%5B25159848%5D": "on",
|
||||||
|
"request%5Bcustom_fields%5D%5B4769658191250%5D": "on"
|
||||||
|
}
|
||||||
|
response = requests.post(url, headers=headers, cookies=cookies, data=data)
|
||||||
|
|
||||||
|
print(response.text)
|
||||||
|
print(response)
|
Loading…
x
Reference in New Issue
Block a user