39 lines
1003 B
Python
39 lines
1003 B
Python
from DB import DBVidcon
|
|
import requests
|
|
from logger import logger
|
|
db = DBVidcon()
|
|
|
|
|
|
def check_video_removed(video_id):
|
|
url = f"https://api.dailymotion.com/video/{video_id}"
|
|
params = {"fields": "published,private,status"}
|
|
resp = requests.get(url, params=params, timeout=10)
|
|
|
|
# 404 -> 不存在或已被删除
|
|
if resp.status_code == 404:
|
|
return 1
|
|
|
|
data = resp.json()
|
|
# published=False 或 private=True 都视作“已下架”
|
|
if not data.get("published", False) or data.get("private", False):
|
|
return 1
|
|
|
|
return 0
|
|
|
|
|
|
def main():
|
|
lis = db.getreport_video()
|
|
for li in lis:
|
|
video_id = li['v_xid']
|
|
status = check_video_removed(video_id)
|
|
if status == 1:
|
|
db.mark_video_removed(li['id'], status)
|
|
logger.info(f"视频id {video_id} 下架")
|
|
else:
|
|
db.mark_video_removed(li['id'], status)
|
|
logger.info(f"视频id {video_id} 仍然存在")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|