add 下载历史记录
This commit is contained in:
@ -5,11 +5,12 @@ from typing import List, Optional, Tuple, Set, Dict, Union
|
||||
from app.chain import ChainBase
|
||||
from app.core.context import MediaInfo, TorrentInfo, Context
|
||||
from app.core.meta import MetaBase
|
||||
from app.db.downloadhistory_oper import DownloadHistoryOper
|
||||
from app.helper.torrent import TorrentHelper
|
||||
from app.log import logger
|
||||
from app.schemas.context import ExistMediaInfo, NotExistMediaInfo
|
||||
from app.utils.string import StringUtils
|
||||
from app.schemas.types import MediaType, TorrentStatus, EventType
|
||||
from app.utils.string import StringUtils
|
||||
|
||||
|
||||
class DownloadChain(ChainBase):
|
||||
@ -17,6 +18,7 @@ class DownloadChain(ChainBase):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.torrent = TorrentHelper()
|
||||
self.downloadhis = DownloadHistoryOper()
|
||||
|
||||
def process(self, *args, **kwargs) -> Optional[Context]:
|
||||
pass
|
||||
@ -55,6 +57,92 @@ class DownloadChain(ChainBase):
|
||||
image=mediainfo.get_message_image(),
|
||||
userid=userid)
|
||||
|
||||
def download_torrent(self, torrent: TorrentInfo,
|
||||
userid: Union[str, int] = None) -> Tuple[Optional[Path], str, list]:
|
||||
"""
|
||||
下载种子文件
|
||||
:return: 种子路径,种子目录名,种子文件清单
|
||||
"""
|
||||
torrent_file, _, download_folder, files, error_msg = self.torrent.download_torrent(
|
||||
url=torrent.enclosure,
|
||||
cookie=torrent.site_cookie,
|
||||
ua=torrent.site_ua,
|
||||
proxy=torrent.site_proxy)
|
||||
if not torrent_file:
|
||||
logger.error(f"下载种子文件失败:{torrent.title} - {torrent.enclosure}")
|
||||
self.post_message(title=f"{torrent.title} 种子下载失败!",
|
||||
text=f"错误信息:{error_msg}\n种子链接:{torrent.enclosure}",
|
||||
userid=userid)
|
||||
return None, "", []
|
||||
return torrent_file, download_folder, files
|
||||
|
||||
def download_single(self, context: Context, torrent_file: Path = None,
|
||||
episodes: Set[int] = None, userid: Union[str, int] = None) -> Optional[str]:
|
||||
"""
|
||||
下载及发送通知
|
||||
"""
|
||||
_torrent = context.torrent_info
|
||||
_media = context.media_info
|
||||
_meta = context.meta_info
|
||||
_folder_name = ""
|
||||
if not torrent_file:
|
||||
# 下载种子文件
|
||||
_torrent_file, _folder_name, _ = self.download_torrent(_torrent, userid=userid)
|
||||
if not _torrent_file:
|
||||
return
|
||||
# 添加下载
|
||||
result: Optional[tuple] = self.download(torrent_path=torrent_file,
|
||||
cookie=_torrent.site_cookie,
|
||||
episodes=episodes)
|
||||
if result:
|
||||
_hash, error_msg = result
|
||||
else:
|
||||
_hash, error_msg = None, "未知错误"
|
||||
|
||||
if _hash:
|
||||
# 登记下载记录
|
||||
self.downloadhis.add(
|
||||
path=_folder_name,
|
||||
type=_media.type.value,
|
||||
title=_media.title,
|
||||
year=_media.year,
|
||||
tmdbid=_media.tmdb_id,
|
||||
imdbid=_media.imdb_id,
|
||||
tvdbid=_media.tvdb_id,
|
||||
doubanid=_media.douban_id,
|
||||
seasons=_meta.season,
|
||||
episodes=_meta.episode,
|
||||
image=_media.poster_path,
|
||||
download_hash=_hash,
|
||||
torrent_name=_torrent.title,
|
||||
torrent_description=_torrent.description,
|
||||
torrent_site=_torrent.site_name
|
||||
)
|
||||
# 发送消息
|
||||
self.post_download_message(meta=_meta, mediainfo=_media, torrent=_torrent, userid=userid)
|
||||
# 下载成功后处理
|
||||
self.download_added(context=context, torrent_path=torrent_file)
|
||||
# 广播事件
|
||||
self.eventmanager.send_event(EventType.DownloadAdded, {
|
||||
"hash": _hash,
|
||||
"torrent_file": torrent_file,
|
||||
"context": context
|
||||
})
|
||||
else:
|
||||
# 下载失败
|
||||
logger.error(f"{_media.title_year} 添加下载任务失败:"
|
||||
f"{_torrent.title} - {_torrent.enclosure},{error_msg}")
|
||||
self.post_message(
|
||||
title="添加下载任务失败:%s %s"
|
||||
% (_media.title_year, _meta.season_episode),
|
||||
text=f"站点:{_torrent.site_name}\n"
|
||||
f"种子名称:{_meta.org_string}\n"
|
||||
f"种子链接:{_torrent.enclosure}\n"
|
||||
f"错误信息:{error_msg}",
|
||||
image=_media.get_message_image(),
|
||||
userid=userid)
|
||||
return _hash
|
||||
|
||||
def batch_download(self,
|
||||
contexts: List[Context],
|
||||
no_exists: Dict[int, Dict[int, NotExistMediaInfo]] = None,
|
||||
@ -69,73 +157,6 @@ class DownloadChain(ChainBase):
|
||||
# 已下载的项目
|
||||
downloaded_list: List[Context] = []
|
||||
|
||||
def __download_torrent(_torrent: TorrentInfo) -> Tuple[Optional[Path], list]:
|
||||
"""
|
||||
下载种子文件
|
||||
:return: 种子路径,种子文件清单
|
||||
"""
|
||||
torrent_file, _, _, files, error_msg = self.torrent.download_torrent(
|
||||
url=_torrent.enclosure,
|
||||
cookie=_torrent.site_cookie,
|
||||
ua=_torrent.site_ua,
|
||||
proxy=_torrent.site_proxy)
|
||||
if not torrent_file:
|
||||
logger.error(f"下载种子文件失败:{_torrent.title} - {_torrent.enclosure}")
|
||||
self.post_message(title=f"{_torrent.title} 种子下载失败!",
|
||||
text=f"错误信息:{error_msg}\n种子链接:{_torrent.enclosure}",
|
||||
userid=userid)
|
||||
return None, []
|
||||
return torrent_file, files
|
||||
|
||||
def __download(_context: Context, _torrent_file: Path = None, _episodes: Set[int] = None) -> Optional[str]:
|
||||
"""
|
||||
下载及发送通知
|
||||
"""
|
||||
_torrent = _context.torrent_info
|
||||
_media = _context.media_info
|
||||
_meta = _context.meta_info
|
||||
if not _torrent_file:
|
||||
# 下载种子文件
|
||||
_torrent_file, _ = __download_torrent(_torrent)
|
||||
if not _torrent_file:
|
||||
return
|
||||
# 添加下载
|
||||
result: Optional[tuple] = self.download(torrent_path=_torrent_file,
|
||||
cookie=_torrent.site_cookie,
|
||||
episodes=_episodes)
|
||||
if result:
|
||||
_hash, error_msg = result
|
||||
else:
|
||||
_hash, error_msg = None, "未知错误"
|
||||
|
||||
if _hash:
|
||||
# 下载成功
|
||||
downloaded_list.append(_context)
|
||||
# 发送消息
|
||||
self.post_download_message(meta=_meta, mediainfo=_media, torrent=_torrent, userid=userid)
|
||||
# 下载成功后处理
|
||||
self.download_added(context=_context, torrent_path=_torrent_file)
|
||||
# 广播事件
|
||||
self.eventmanager.send_event(EventType.DownloadAdded, {
|
||||
"hash": _hash,
|
||||
"torrent_file": _torrent_file,
|
||||
"context": _context
|
||||
})
|
||||
else:
|
||||
# 下载失败
|
||||
logger.error(f"{_media.title_year} 添加下载任务失败:"
|
||||
f"{_torrent.title} - {_torrent.enclosure},{error_msg}")
|
||||
self.post_message(
|
||||
title="添加下载任务失败:%s %s"
|
||||
% (_media.title_year, _meta.season_episode),
|
||||
text=f"站点:{_torrent.site_name}\n"
|
||||
f"种子名称:{_meta.org_string}\n"
|
||||
f"种子链接:{_torrent.enclosure}\n"
|
||||
f"错误信息:{error_msg}",
|
||||
image=_media.get_message_image(),
|
||||
userid=userid)
|
||||
return _hash
|
||||
|
||||
def __update_seasons(_tmdbid: int, _need: list, _current: list) -> list:
|
||||
"""
|
||||
更新need_tvs季数,返回剩余季数
|
||||
@ -194,7 +215,9 @@ class DownloadChain(ChainBase):
|
||||
# 如果是电影,直接下载
|
||||
for context in contexts:
|
||||
if context.media_info.type == MediaType.MOVIE:
|
||||
__download(context)
|
||||
if self.download_single(context, userid=userid):
|
||||
# 下载成功
|
||||
downloaded_list.append(context)
|
||||
|
||||
# 电视剧整季匹配
|
||||
if no_exists:
|
||||
@ -233,7 +256,7 @@ class DownloadChain(ChainBase):
|
||||
if set(torrent_season).issubset(set(need_season)):
|
||||
if len(torrent_season) == 1:
|
||||
# 只有一季的可能是命名错误,需要打开种子鉴别,只有实际集数大于等于总集数才下载
|
||||
torrent_path, torrent_files = __download_torrent(torrent)
|
||||
torrent_path, _, torrent_files = self.download_torrent(torrent)
|
||||
if not torrent_path:
|
||||
continue
|
||||
torrent_episodes = self.torrent.get_torrent_episodes(torrent_files)
|
||||
@ -241,16 +264,20 @@ class DownloadChain(ChainBase):
|
||||
or len(torrent_episodes) >= __get_season_episodes(need_tmdbid,
|
||||
torrent_season[0]):
|
||||
# 下载
|
||||
download_id = __download(_context=context, _torrent_file=torrent_path)
|
||||
download_id = self.download_single(context=context,
|
||||
torrent_file=torrent_path,
|
||||
userid=userid)
|
||||
else:
|
||||
logger.info(
|
||||
f"{meta.org_string} 解析文件集数为 {len(torrent_episodes)},未含所需集数")
|
||||
continue
|
||||
else:
|
||||
# 下载
|
||||
download_id = __download(context)
|
||||
download_id = self.download_single(context, userid=userid)
|
||||
|
||||
if download_id:
|
||||
# 下载成功
|
||||
downloaded_list.append(context)
|
||||
# 更新仍需季集
|
||||
need_season = __update_seasons(_tmdbid=need_tmdbid,
|
||||
_need=need_season,
|
||||
@ -304,8 +331,10 @@ class DownloadChain(ChainBase):
|
||||
# 为需要集的子集则下载
|
||||
if set(torrent_episodes).issubset(set(need_episodes)):
|
||||
# 下载
|
||||
download_id = __download(context)
|
||||
download_id = self.download_single(context, userid=userid)
|
||||
if download_id:
|
||||
# 下载成功
|
||||
downloaded_list.append(context)
|
||||
# 更新仍需集数
|
||||
need_episodes = __update_episodes(_tmdbid=need_tmdbid,
|
||||
_need=need_episodes,
|
||||
@ -358,7 +387,7 @@ class DownloadChain(ChainBase):
|
||||
and len(meta.season_list) == 1 \
|
||||
and meta.season_list[0] == need_season:
|
||||
# 检查种子看是否有需要的集
|
||||
torrent_path, torrent_files = __download_torrent(torrent)
|
||||
torrent_path, _, torrent_files = self.download_torrent(torrent, userid=userid)
|
||||
if not torrent_path:
|
||||
continue
|
||||
# 种子全部集
|
||||
@ -369,11 +398,14 @@ class DownloadChain(ChainBase):
|
||||
logger.info(f"{meta.org_string} 没有需要的集,跳过...")
|
||||
continue
|
||||
# 添加下载
|
||||
download_id = __download(_context=context,
|
||||
_torrent_file=torrent_path,
|
||||
_episodes=selected_episodes)
|
||||
download_id = self.download_single(context=context,
|
||||
torrent_file=torrent_path,
|
||||
episodes=selected_episodes,
|
||||
userid=userid)
|
||||
if not download_id:
|
||||
continue
|
||||
# 下载成功
|
||||
downloaded_list.append(context)
|
||||
# 更新仍需集数
|
||||
need_episodes = __update_episodes(_tmdbid=need_tmdbid,
|
||||
_need=need_episodes,
|
||||
|
@ -3,9 +3,9 @@ from typing import Any
|
||||
from app.chain.download import *
|
||||
from app.chain.search import SearchChain
|
||||
from app.chain.subscribe import SubscribeChain
|
||||
from app.core.context import MediaInfo, TorrentInfo
|
||||
from app.core.metainfo import MetaInfo
|
||||
from app.core.context import MediaInfo
|
||||
from app.core.event import EventManager
|
||||
from app.core.metainfo import MetaInfo
|
||||
from app.log import logger
|
||||
from app.schemas.types import EventType
|
||||
|
||||
@ -168,46 +168,8 @@ class UserMessageChain(ChainBase):
|
||||
else:
|
||||
# 下载种子
|
||||
context: Context = cache_list[int(text) - 1]
|
||||
torrent: TorrentInfo = context.torrent_info
|
||||
logger.info(f"开始下载种子:{torrent.title} - {torrent.enclosure}")
|
||||
# 识别前预处理
|
||||
result: Optional[tuple] = self.prepare_recognize(title=torrent.title,
|
||||
subtitle=torrent.description)
|
||||
if result:
|
||||
title, subtitle = result
|
||||
else:
|
||||
title, subtitle = torrent.title, torrent.description
|
||||
# 识别
|
||||
meta = MetaInfo(title=title, subtitle=subtitle)
|
||||
torrent_file, _, _, _, error_msg = self.torrent.download_torrent(
|
||||
url=torrent.enclosure,
|
||||
cookie=torrent.site_cookie,
|
||||
ua=torrent.site_ua,
|
||||
proxy=torrent.site_proxy)
|
||||
if not torrent_file:
|
||||
logger.error(f"下载种子文件失败:{torrent.title} - {torrent.enclosure}")
|
||||
self.post_message(title=f"{torrent.title} 种子下载失败!",
|
||||
text=f"错误信息:{error_msg}\n种子链接:{torrent.enclosure}",
|
||||
userid=userid)
|
||||
return
|
||||
# 添加下载
|
||||
result: Optional[tuple] = self.download(torrent_path=torrent_file,
|
||||
cookie=torrent.site_cookie)
|
||||
if result:
|
||||
state, msg = result
|
||||
else:
|
||||
state, msg = False, "未知错误"
|
||||
# 发送消息
|
||||
if not state:
|
||||
# 下载失败
|
||||
self.post_message(title=f"{torrent.title} 添加下载失败!",
|
||||
text=f"错误信息:{msg}",
|
||||
userid=userid)
|
||||
return
|
||||
# 下载成功,发送通知
|
||||
self.downloadchain.post_download_message(meta=meta, mediainfo=self._current_media, torrent=torrent)
|
||||
# 下载成功后处理
|
||||
self.download_added(context=context, torrent_path=torrent_file)
|
||||
# 下载
|
||||
self.downloadchain.download_single(context, userid=userid)
|
||||
|
||||
elif text.lower() == "p":
|
||||
# 上一页
|
||||
|
32
app/db/downloadhistory_oper.py
Normal file
32
app/db/downloadhistory_oper.py
Normal file
@ -0,0 +1,32 @@
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from app.db import DbOper
|
||||
from app.db.models.downloadhistory import DownloadHistory
|
||||
|
||||
|
||||
class DownloadHistoryOper(DbOper):
|
||||
"""
|
||||
插件数据管理
|
||||
"""
|
||||
|
||||
def get_by_path(self, path: Path) -> Any:
|
||||
"""
|
||||
按路径查询下载记录
|
||||
:param path: 数据key
|
||||
"""
|
||||
return DownloadHistory.get_by_path(self._db, path)
|
||||
|
||||
def get_by_hash(self, download_hash: str) -> Any:
|
||||
"""
|
||||
按Hash查询下载记录
|
||||
:param download_hash: 数据key
|
||||
"""
|
||||
return DownloadHistory.get_by_hash(self._db, download_hash)
|
||||
|
||||
def add(self, **kwargs):
|
||||
"""
|
||||
新增下载历史
|
||||
"""
|
||||
downloadhistory = DownloadHistory(**kwargs)
|
||||
return downloadhistory.create(self._db)
|
31
app/db/models/downloadhistory.py
Normal file
31
app/db/models/downloadhistory.py
Normal file
@ -0,0 +1,31 @@
|
||||
from sqlalchemy import Column, Integer, String, Sequence
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.db.models import Base
|
||||
|
||||
|
||||
class DownloadHistory(Base):
|
||||
"""
|
||||
下载历史记录
|
||||
"""
|
||||
id = Column(Integer, Sequence('id'), primary_key=True, index=True)
|
||||
path = Column(String, nullable=False, index=True)
|
||||
type = Column(String, nullable=False)
|
||||
title = Column(String, nullable=False)
|
||||
year = Column(String)
|
||||
tmdbid = Column(Integer, index=True)
|
||||
imdbid = Column(String)
|
||||
tvdbid = Column(Integer)
|
||||
doubanid = Column(String)
|
||||
seasons = Column(Integer)
|
||||
episodes = Column(String)
|
||||
image = Column(String)
|
||||
download_hash = Column(String, index=True)
|
||||
torrent_name = Column(String)
|
||||
torrent_description = Column(String)
|
||||
torrent_site = Column(String)
|
||||
note = Column(String)
|
||||
|
||||
@staticmethod
|
||||
def get_by_hash(db: Session, download_hash: str):
|
||||
return db.query(DownloadHistory).filter(DownloadHistory.download_hash == download_hash).first()
|
@ -468,7 +468,7 @@ class FileTransferModule(_ModuleBase):
|
||||
# 集号
|
||||
"episode": meta.episode_seqs,
|
||||
# 季集 SxxExx
|
||||
"season_episode": "%s%s" % (meta.season, meta.episode),
|
||||
"season_episode": "%s%s" % (meta.season, meta.episodes),
|
||||
# 段/节
|
||||
"part": meta.part,
|
||||
# 文件后缀
|
||||
|
@ -303,8 +303,8 @@ class TheMovieDbModule(_ModuleBase):
|
||||
uniqueid_tmdb.setAttribute("default", "true")
|
||||
# TVDB
|
||||
if mediainfo.tvdb_id:
|
||||
DomUtils.add_node(doc, root, "tvdbid", mediainfo.tvdb_id)
|
||||
uniqueid_tvdb = DomUtils.add_node(doc, root, "uniqueid", mediainfo.tvdb_id)
|
||||
DomUtils.add_node(doc, root, "tvdbid", str(mediainfo.tvdb_id))
|
||||
uniqueid_tvdb = DomUtils.add_node(doc, root, "uniqueid", str(mediainfo.tvdb_id))
|
||||
uniqueid_tvdb.setAttribute("type", "tvdb")
|
||||
# IMDB
|
||||
if mediainfo.imdb_id:
|
||||
|
@ -45,14 +45,13 @@ class Pt52(_ISiteSigninHandler):
|
||||
site_cookie = site_info.get("cookie")
|
||||
ua = site_info.get("ua")
|
||||
render = site_info.get("render")
|
||||
proxies = settings.PROXY if site_info.get("proxy") else None
|
||||
proxy_server = settings.PROXY_SERVER if site_info.get("proxy") else None
|
||||
proxy = site_info.get("proxy")
|
||||
|
||||
# 判断今日是否已签到
|
||||
html_text = self.get_page_source(url='https://52pt.site/bakatest.php',
|
||||
cookie=site_cookie,
|
||||
ua=ua,
|
||||
proxies=proxy_server,
|
||||
proxy=proxy,
|
||||
render=render)
|
||||
|
||||
if not html_text:
|
||||
@ -97,7 +96,7 @@ class Pt52(_ISiteSigninHandler):
|
||||
choice=choice,
|
||||
site_cookie=site_cookie,
|
||||
ua=ua,
|
||||
proxies=proxies,
|
||||
proxy=proxy,
|
||||
site=site)
|
||||
|
||||
def __signin(self, questionid: str,
|
||||
@ -105,7 +104,7 @@ class Pt52(_ISiteSigninHandler):
|
||||
site: str,
|
||||
site_cookie: str,
|
||||
ua: str,
|
||||
proxies: dict) -> Tuple[bool, str]:
|
||||
proxy: bool) -> Tuple[bool, str]:
|
||||
"""
|
||||
签到请求
|
||||
questionid: 450
|
||||
@ -125,7 +124,7 @@ class Pt52(_ISiteSigninHandler):
|
||||
|
||||
sign_res = RequestUtils(cookies=site_cookie,
|
||||
ua=ua,
|
||||
proxies=proxies
|
||||
proxies=settings.PROXY if proxy else None
|
||||
).post_res(url='https://52pt.site/bakatest.php', data=data)
|
||||
if not sign_res or sign_res.status_code != 200:
|
||||
logger.error(f"签到失败,签到接口请求失败")
|
||||
|
@ -6,6 +6,7 @@ from typing import Tuple
|
||||
import chardet
|
||||
from ruamel.yaml import CommentedMap
|
||||
|
||||
from app.core.config import settings
|
||||
from app.helper.browser import PlaywrightHelper
|
||||
from app.log import logger
|
||||
from app.utils.http import RequestUtils
|
||||
@ -39,13 +40,13 @@ class _ISiteSigninHandler(metaclass=ABCMeta):
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def get_page_source(url: str, cookie: str, ua: str, proxies: dict, render: bool) -> str:
|
||||
def get_page_source(url: str, cookie: str, ua: str, proxy: bool, render: bool) -> str:
|
||||
"""
|
||||
获取页面源码
|
||||
:param url: Url地址
|
||||
:param cookie: Cookie
|
||||
:param ua: UA
|
||||
:param proxies: 代理
|
||||
:param proxy: 是否使用代理
|
||||
:param render: 是否渲染
|
||||
:return: 页面源码,错误信息
|
||||
"""
|
||||
@ -53,11 +54,11 @@ class _ISiteSigninHandler(metaclass=ABCMeta):
|
||||
return PlaywrightHelper().get_page_source(url=url,
|
||||
cookies=cookie,
|
||||
ua=ua,
|
||||
proxies=proxies)
|
||||
proxies=settings.PROXY_SERVER if proxy else None)
|
||||
else:
|
||||
res = RequestUtils(cookies=cookie,
|
||||
ua=ua,
|
||||
proxies=proxies
|
||||
proxies=settings.PROXY if proxy else None
|
||||
).get_res(url=url)
|
||||
if res is not None:
|
||||
# 使用chardet检测字符编码
|
||||
|
@ -37,16 +37,14 @@ class BTSchool(_ISiteSigninHandler):
|
||||
site_cookie = site_info.get("cookie")
|
||||
ua = site_info.get("ua")
|
||||
render = site_info.get("render")
|
||||
proxies = settings.PROXY if site_info.get("proxy") else None
|
||||
proxy_server = settings.PROXY_SERVER if site_info.get("proxy") else None
|
||||
proxy_server = settings.PROXY_SERVER if site_info.get("proxy") else None
|
||||
proxy = site_info.get("proxy")
|
||||
|
||||
logger.info(f"{site} 开始签到")
|
||||
# 判断今日是否已签到
|
||||
html_text = self.get_page_source(url='https://pt.btschool.club',
|
||||
cookie=site_cookie,
|
||||
ua=ua,
|
||||
proxies=proxy_server,
|
||||
proxy=proxy,
|
||||
render=render)
|
||||
|
||||
if not html_text:
|
||||
@ -65,7 +63,7 @@ class BTSchool(_ISiteSigninHandler):
|
||||
html_text = self.get_page_source(url='https://pt.btschool.club/index.php?action=addbonus',
|
||||
cookie=site_cookie,
|
||||
ua=ua,
|
||||
proxies=proxy_server,
|
||||
proxy=proxy,
|
||||
render=render)
|
||||
|
||||
if not html_text:
|
||||
|
@ -45,15 +45,14 @@ class CHDBits(_ISiteSigninHandler):
|
||||
site = site_info.get("name")
|
||||
site_cookie = site_info.get("cookie")
|
||||
ua = site_info.get("ua")
|
||||
proxies = settings.PROXY if site_info.get("proxy") else None
|
||||
proxy_server = settings.PROXY_SERVER if site_info.get("proxy") else None
|
||||
proxy = site_info.get("proxy")
|
||||
render = site_info.get("render")
|
||||
|
||||
# 判断今日是否已签到
|
||||
html_text = self.get_page_source(url='https://chdbits.co/bakatest.php',
|
||||
cookie=site_cookie,
|
||||
ua=ua,
|
||||
proxies=proxy_server,
|
||||
proxy=proxy,
|
||||
render=render)
|
||||
|
||||
if not html_text:
|
||||
@ -98,7 +97,7 @@ class CHDBits(_ISiteSigninHandler):
|
||||
choice=choice,
|
||||
site_cookie=site_cookie,
|
||||
ua=ua,
|
||||
proxies=proxies,
|
||||
proxy=proxy,
|
||||
site=site)
|
||||
|
||||
def __signin(self, questionid: str,
|
||||
@ -106,7 +105,7 @@ class CHDBits(_ISiteSigninHandler):
|
||||
site: str,
|
||||
site_cookie: str,
|
||||
ua: str,
|
||||
proxies: dict) -> Tuple[bool, str]:
|
||||
proxy: bool) -> Tuple[bool, str]:
|
||||
"""
|
||||
签到请求
|
||||
questionid: 450
|
||||
@ -126,7 +125,7 @@ class CHDBits(_ISiteSigninHandler):
|
||||
|
||||
sign_res = RequestUtils(cookies=site_cookie,
|
||||
ua=ua,
|
||||
proxies=proxies
|
||||
proxies=settings.PROXY if proxy else None
|
||||
).post_res(url='https://chdbits.co/bakatest.php', data=data)
|
||||
if not sign_res or sign_res.status_code != 200:
|
||||
logger.error(f"签到失败,签到接口请求失败")
|
||||
|
@ -36,15 +36,14 @@ class HaiDan(_ISiteSigninHandler):
|
||||
site = site_info.get("name")
|
||||
site_cookie = site_info.get("cookie")
|
||||
ua = site_info.get("ua")
|
||||
proxies = settings.PROXY if site_info.get("proxy") else None
|
||||
proxy_server = settings.PROXY_SERVER if site_info.get("proxy") else None
|
||||
proxy = site_info.get("proxy")
|
||||
render = site_info.get("render")
|
||||
|
||||
# 签到
|
||||
html_text = self.get_page_source(url='https://www.haidan.video/signin.php',
|
||||
cookie=site_cookie,
|
||||
ua=ua,
|
||||
proxies=proxy_server,
|
||||
proxy=proxy,
|
||||
render=render)
|
||||
if not html_text:
|
||||
logger.error(f"签到失败,请检查站点连通性")
|
||||
|
@ -38,15 +38,14 @@ class Hares(_ISiteSigninHandler):
|
||||
site = site_info.get("name")
|
||||
site_cookie = site_info.get("cookie")
|
||||
ua = site_info.get("ua")
|
||||
proxies = settings.PROXY if site_info.get("proxy") else None
|
||||
proxy_server = settings.PROXY_SERVER if site_info.get("proxy") else None
|
||||
proxy = site_info.get("proxy")
|
||||
render = site_info.get("render")
|
||||
|
||||
# 获取页面html
|
||||
html_text = self.get_page_source(url='https://club.hares.top',
|
||||
cookie=site_cookie,
|
||||
ua=ua,
|
||||
proxies=proxy_server,
|
||||
proxy=proxy,
|
||||
render=render)
|
||||
|
||||
if not html_text:
|
||||
@ -67,7 +66,7 @@ class Hares(_ISiteSigninHandler):
|
||||
}
|
||||
sign_res = RequestUtils(cookies=site_cookie,
|
||||
headers=headers,
|
||||
proxies=proxies
|
||||
proxies=settings.PROXY if proxy else None
|
||||
).get_res(url="https://club.hares.top/attendance.php?action=sign")
|
||||
if not sign_res or sign_res.status_code != 200:
|
||||
logger.error(f"签到失败,签到接口请求失败")
|
||||
|
@ -38,15 +38,14 @@ class HDCity(_ISiteSigninHandler):
|
||||
site = site_info.get("name")
|
||||
site_cookie = site_info.get("cookie")
|
||||
ua = site_info.get("ua")
|
||||
proxies = settings.PROXY if site_info.get("proxy") else None
|
||||
proxy_server = settings.PROXY_SERVER if site_info.get("proxy") else None
|
||||
proxy = site_info.get("proxy")
|
||||
render = site_info.get("render")
|
||||
|
||||
# 获取页面html
|
||||
html_text = self.get_page_source(url='https://hdcity.city/sign',
|
||||
cookie=site_cookie,
|
||||
ua=ua,
|
||||
proxies=proxy_server,
|
||||
proxy=proxy,
|
||||
render=render)
|
||||
if not html_text:
|
||||
logger.error(f"签到失败,请检查站点连通性")
|
||||
|
@ -40,15 +40,14 @@ class HDSky(_ISiteSigninHandler):
|
||||
site = site_info.get("name")
|
||||
site_cookie = site_info.get("cookie")
|
||||
ua = site_info.get("ua")
|
||||
proxies = settings.PROXY if site_info.get("proxy") else None
|
||||
proxy_server = settings.PROXY_SERVER if site_info.get("proxy") else None
|
||||
proxy = site_info.get("proxy")
|
||||
render = site_info.get("render")
|
||||
|
||||
# 判断今日是否已签到
|
||||
html_text = self.get_page_source(url='https://hdsky.me',
|
||||
cookie=site_cookie,
|
||||
ua=ua,
|
||||
proxies=proxy_server,
|
||||
proxy=proxy,
|
||||
render=render)
|
||||
if not html_text:
|
||||
logger.error(f"签到失败,请检查站点连通性")
|
||||
@ -70,7 +69,7 @@ class HDSky(_ISiteSigninHandler):
|
||||
while not img_hash and res_times <= 3:
|
||||
image_res = RequestUtils(cookies=site_cookie,
|
||||
headers=ua,
|
||||
proxies=proxies
|
||||
proxies=settings.PROXY if proxy else None
|
||||
).post_res(url='https://hdsky.me/image_code_ajax.php',
|
||||
data={'action': 'new'})
|
||||
if image_res and image_res.status_code == 200:
|
||||
@ -115,7 +114,7 @@ class HDSky(_ISiteSigninHandler):
|
||||
# 访问签到链接
|
||||
res = RequestUtils(cookies=site_cookie,
|
||||
headers=ua,
|
||||
proxies=proxies
|
||||
proxies=settings.PROXY if proxy else None
|
||||
).post_res(url='https://hdsky.me/showup.php', data=data)
|
||||
if res and res.status_code == 200:
|
||||
if json.loads(res.text)["success"]:
|
||||
|
@ -40,15 +40,14 @@ class HDUpt(_ISiteSigninHandler):
|
||||
site = site_info.get("name")
|
||||
site_cookie = site_info.get("cookie")
|
||||
ua = site_info.get("ua")
|
||||
proxies = settings.PROXY if site_info.get("proxy") else None
|
||||
proxy_server = settings.PROXY_SERVER if site_info.get("proxy") else None
|
||||
proxy = site_info.get("proxy")
|
||||
render = site_info.get("render")
|
||||
|
||||
# 获取页面html
|
||||
html_text = self.get_page_source(url='https://pt.hdupt.com',
|
||||
cookie=site_cookie,
|
||||
ua=ua,
|
||||
proxies=proxy_server,
|
||||
proxy=proxy,
|
||||
render=render)
|
||||
if not html_text:
|
||||
logger.error(f"签到失败,请检查站点连通性")
|
||||
@ -68,7 +67,7 @@ class HDUpt(_ISiteSigninHandler):
|
||||
html_text = self.get_page_source(url='https://pt.hdupt.com/added.php?action=qiandao',
|
||||
cookie=site_cookie,
|
||||
ua=ua,
|
||||
proxies=proxy_server,
|
||||
proxy=proxy,
|
||||
render=render)
|
||||
if not html_text:
|
||||
logger.error(f"签到失败,请检查站点连通性")
|
||||
|
@ -41,15 +41,14 @@ class Opencd(_ISiteSigninHandler):
|
||||
site = site_info.get("name")
|
||||
site_cookie = site_info.get("cookie")
|
||||
ua = site_info.get("ua")
|
||||
proxies = settings.PROXY if site_info.get("proxy") else None
|
||||
proxy_server = settings.PROXY_SERVER if site_info.get("proxy") else None
|
||||
proxy = site_info.get("proxy")
|
||||
render = site_info.get("render")
|
||||
|
||||
# 判断今日是否已签到
|
||||
html_text = self.get_page_source(url='https://www.open.cd',
|
||||
cookie=site_cookie,
|
||||
ua=ua,
|
||||
proxies=proxy_server,
|
||||
proxy=proxy,
|
||||
render=render)
|
||||
if not html_text:
|
||||
logger.error(f"签到失败,请检查站点连通性")
|
||||
@ -67,7 +66,7 @@ class Opencd(_ISiteSigninHandler):
|
||||
html_text = self.get_page_source(url='https://www.open.cd/plugin_sign-in.php',
|
||||
cookie=site_cookie,
|
||||
ua=ua,
|
||||
proxies=proxy_server,
|
||||
proxy=proxy,
|
||||
render=render)
|
||||
if not html_text:
|
||||
logger.error(f"签到失败,请检查站点连通性")
|
||||
@ -116,7 +115,7 @@ class Opencd(_ISiteSigninHandler):
|
||||
# 访问签到链接
|
||||
sign_res = RequestUtils(cookies=site_cookie,
|
||||
headers=ua,
|
||||
proxies=proxies
|
||||
proxies=settings.PROXY if proxy else None
|
||||
).post_res(url='https://www.open.cd/plugin_sign-in.php?cmd=signin', data=data)
|
||||
if sign_res and sign_res.status_code == 200:
|
||||
logger.debug(f"sign_res返回 {sign_res.text}")
|
||||
|
@ -34,15 +34,14 @@ class PTerClub(_ISiteSigninHandler):
|
||||
site = site_info.get("name")
|
||||
site_cookie = site_info.get("cookie")
|
||||
ua = site_info.get("ua")
|
||||
proxies = settings.PROXY if site_info.get("proxy") else None
|
||||
proxy_server = settings.PROXY_SERVER if site_info.get("proxy") else None
|
||||
proxy = site_info.get("proxy")
|
||||
render = site_info.get("render")
|
||||
|
||||
# 签到
|
||||
html_text = self.get_page_source(url='https://pterclub.com/attendance-ajax.php',
|
||||
cookie=site_cookie,
|
||||
ua=ua,
|
||||
proxies=proxy_server,
|
||||
proxy=proxy,
|
||||
render=render)
|
||||
if not html_text:
|
||||
logger.error(f"签到失败,签到接口请求失败")
|
||||
|
@ -55,8 +55,7 @@ class Tjupt(_ISiteSigninHandler):
|
||||
site = site_info.get("name")
|
||||
site_cookie = site_info.get("cookie")
|
||||
ua = site_info.get("ua")
|
||||
proxies = settings.PROXY if site_info.get("proxy") else None
|
||||
proxy_server = settings.PROXY_SERVER if site_info.get("proxy") else None
|
||||
proxy = site_info.get("proxy")
|
||||
render = site_info.get("render")
|
||||
|
||||
# 创建正确答案存储目录
|
||||
@ -67,7 +66,7 @@ class Tjupt(_ISiteSigninHandler):
|
||||
html_text = self.get_page_source(url=self._sign_in_url,
|
||||
cookie=site_cookie,
|
||||
ua=ua,
|
||||
proxies=proxy_server,
|
||||
proxy=proxy,
|
||||
render=render)
|
||||
|
||||
# 获取签到后返回html,判断是否签到成功
|
||||
@ -101,7 +100,7 @@ class Tjupt(_ISiteSigninHandler):
|
||||
# 获取签到图片hash
|
||||
captcha_img_res = RequestUtils(cookies=site_cookie,
|
||||
headers=ua,
|
||||
proxies=proxies
|
||||
proxies=settings.PROXY if proxy else None
|
||||
).get_res(url=img_url)
|
||||
if not captcha_img_res or captcha_img_res.status_code != 200:
|
||||
logger.error(f"签到图片 {img_url} 请求失败")
|
||||
@ -139,7 +138,7 @@ class Tjupt(_ISiteSigninHandler):
|
||||
return self.__signin(answer=value,
|
||||
site_cookie=site_cookie,
|
||||
ua=ua,
|
||||
proxies=proxies,
|
||||
proxy=proxy,
|
||||
site=site)
|
||||
except (FileNotFoundError, IOError, OSError) as e:
|
||||
logger.debug(f"查询本地已知答案失败:{e},继续请求豆瓣查询")
|
||||
@ -182,7 +181,7 @@ class Tjupt(_ISiteSigninHandler):
|
||||
return self.__signin(answer=value,
|
||||
site_cookie=site_cookie,
|
||||
ua=ua,
|
||||
proxies=proxies,
|
||||
proxy=proxy,
|
||||
site=site,
|
||||
exits_answers=exits_answers,
|
||||
captcha_img_hash=captcha_img_hash)
|
||||
@ -194,7 +193,7 @@ class Tjupt(_ISiteSigninHandler):
|
||||
# 没有匹配签到成功,则签到失败
|
||||
return False, f'【{site}】签到失败,未获取到匹配答案'
|
||||
|
||||
def __signin(self, answer, site_cookie, ua, proxies, site, exits_answers=None, captcha_img_hash=None):
|
||||
def __signin(self, answer, site_cookie, ua, proxy, site, exits_answers=None, captcha_img_hash=None):
|
||||
"""
|
||||
签到请求
|
||||
"""
|
||||
@ -205,7 +204,7 @@ class Tjupt(_ISiteSigninHandler):
|
||||
logger.debug(f"提交data {data}")
|
||||
sign_in_res = RequestUtils(cookies=site_cookie,
|
||||
headers=ua,
|
||||
proxies=proxies
|
||||
proxies=settings.PROXY if proxy else None
|
||||
).post_res(url=self._sign_in_url, data=data)
|
||||
if not sign_in_res or sign_in_res.status_code != 200:
|
||||
logger.error(f"签到失败,签到接口请求失败")
|
||||
|
@ -42,15 +42,14 @@ class TTG(_ISiteSigninHandler):
|
||||
site = site_info.get("name")
|
||||
site_cookie = site_info.get("cookie")
|
||||
ua = site_info.get("ua")
|
||||
proxies = settings.PROXY if site_info.get("proxy") else None
|
||||
proxy_server = settings.PROXY_SERVER if site_info.get("proxy") else None
|
||||
proxy = site_info.get("proxy")
|
||||
render = site_info.get("render")
|
||||
|
||||
# 获取页面html
|
||||
html_text = self.get_page_source(url="https://totheglory.im",
|
||||
cookie=site_cookie,
|
||||
ua=ua,
|
||||
proxies=proxy_server,
|
||||
proxy=proxy,
|
||||
render=render)
|
||||
if not html_text:
|
||||
logger.error(f"签到失败,请检查站点连通性")
|
||||
@ -79,7 +78,7 @@ class TTG(_ISiteSigninHandler):
|
||||
# 签到
|
||||
sign_res = RequestUtils(cookies=site_cookie,
|
||||
headers=ua,
|
||||
proxies=proxies
|
||||
proxies=settings.PROXY if proxy else None
|
||||
).post_res(url="https://totheglory.im/signed.php",
|
||||
data=data)
|
||||
if not sign_res or sign_res.status_code != 200:
|
||||
|
@ -48,8 +48,7 @@ class U2(_ISiteSigninHandler):
|
||||
site = site_info.get("name")
|
||||
site_cookie = site_info.get("cookie")
|
||||
ua = site_info.get("ua")
|
||||
proxies = settings.PROXY if site_info.get("proxy") else None
|
||||
proxy_server = settings.PROXY_SERVER if site_info.get("proxy") else None
|
||||
proxy = site_info.get("proxy")
|
||||
render = site_info.get("render")
|
||||
|
||||
now = datetime.datetime.now()
|
||||
@ -62,7 +61,7 @@ class U2(_ISiteSigninHandler):
|
||||
html_text = self.get_page_source(url="https://u2.dmhy.org/showup.php",
|
||||
cookie=site_cookie,
|
||||
ua=ua,
|
||||
proxies=proxy_server,
|
||||
proxy=proxy,
|
||||
render=render)
|
||||
if not html_text:
|
||||
logger.error(f"签到失败,请检查站点连通性")
|
||||
@ -107,7 +106,7 @@ class U2(_ISiteSigninHandler):
|
||||
# 签到
|
||||
sign_res = RequestUtils(cookies=site_cookie,
|
||||
headers=ua,
|
||||
proxies=proxies
|
||||
proxies=settings.PROXY if proxy else None
|
||||
).post_res(url="https://u2.dmhy.org/showup.php?action=show",
|
||||
data=data)
|
||||
if not sign_res or sign_res.status_code != 200:
|
||||
|
@ -36,15 +36,14 @@ class ZhuQue(_ISiteSigninHandler):
|
||||
site = site_info.get("name")
|
||||
site_cookie = site_info.get("cookie")
|
||||
ua = site_info.get("ua")
|
||||
proxies = settings.PROXY if site_info.get("proxy") else None
|
||||
proxy_server = settings.PROXY_SERVER if site_info.get("proxy") else None
|
||||
proxy = site_info.get("proxy")
|
||||
render = site_info.get("render")
|
||||
|
||||
# 获取页面html
|
||||
html_text = self.get_page_source(url="https://zhuque.in",
|
||||
cookie=site_cookie,
|
||||
ua=ua,
|
||||
proxies=proxy_server,
|
||||
proxy=proxy,
|
||||
render=render)
|
||||
if not html_text:
|
||||
logger.error(f"模拟登录失败,请检查站点连通性")
|
||||
@ -74,7 +73,7 @@ class ZhuQue(_ISiteSigninHandler):
|
||||
}
|
||||
skill_res = RequestUtils(cookies=site_cookie,
|
||||
headers=headers,
|
||||
proxies=proxies
|
||||
proxies=settings.PROXY if proxy else None
|
||||
).post_res(url="https://zhuque.in/api/gaming/fireGenshinCharacterMagic", json=data)
|
||||
if not skill_res or skill_res.status_code != 200:
|
||||
logger.error(f"模拟登录失败,释放技能失败")
|
||||
|
Reference in New Issue
Block a user