修复AB当作Proxy无法获取海报的问题。

移除 RSS 检查器
This commit is contained in:
EstrellaXD
2023-05-19 00:14:16 +08:00
parent 4b50f210dc
commit 9aa6b09005
8 changed files with 33 additions and 19 deletions

View File

@@ -24,4 +24,4 @@ if __name__ == "__main__":
uvicorn.run(
router, host="0.0.0.0", port=settings.program.webui_port,
log_config=uvicorn_logging_config,
)
)

View File

@@ -69,4 +69,16 @@ async def get_rss(full_path: str):
@router.get("/Download/{full_path:path}", tags=["proxy"])
async def download(full_path: str):
torrent = get_torrent(full_path)
return Response(torrent, media_type="application/x-bittorrent")
return Response(torrent, media_type="application/x-bittorrent")
@router.get("/Home/Episode/{full_path:path}", tags=["proxy"])
async def get_ep_info(full_path: str):
url = f"https://mikanani.me/Home/Episode/{full_path}"
try:
with RequestContent() as request:
return Response(request.get_html(url), media_type="text/html")
except Exception as e:
logger.debug(e)
logger.warning("Failed to get ep info")
raise HTTPException(status_code=500, detail="Failed to get ep info")

View File

@@ -17,8 +17,7 @@ class Checker:
return False
def check_analyser(self) -> bool:
if self.check_torrents() and\
self.check_downloader() and\
if self.check_downloader() and\
settings.rss_parser.enable:
return True
else:

View File

@@ -37,10 +37,9 @@ class Program(RenameThread, RSSThread):
settings.load()
if self.enable_renamer:
self.rename_start()
logger.info("Renamer started.")
if self.enable_rss:
self.rss_start()
logger.info("RSS started.")
logger.info("Program running.")
return {"status": "Program started."}
def stop(self):

View File

@@ -13,11 +13,11 @@ class RSSThread(ProgramStatus):
self._rss_thread = threading.Thread(
target=self.rss_loop,
)
self._rss_analyser = RSSAnalyser()
def rss_loop(self):
rss_analyser = RSSAnalyser()
while not self.stop_event.is_set():
rss_analyser.run()
self._rss_analyser.run()
add_rules()
if settings.bangumi_manage.eps_complete:
with FullSeasonGet() as full_season_get:

View File

@@ -10,10 +10,6 @@ class BangumiDatabase(DataConnector):
def __init__(self):
super().__init__()
self.__table_name = "bangumi"
self.__updated = False
if not self.__updated:
self.update_table()
self.__updated = True
def update_table(self):
db_data = self.__data_to_db(BangumiData())

View File

@@ -16,7 +16,7 @@ class RequestURL:
def get_url(self, url, retry=3):
try_time = 0
while try_time < retry:
while True:
try:
req = self.session.get(url=url, headers=self.header, timeout=5)
req.raise_for_status()
@@ -26,8 +26,10 @@ class RequestURL:
logger.debug(e)
logger.warning(f"Cannot connect to {url}. Wait for 5 seconds.")
logger.warning("Please check DNS/Connection settings")
time.sleep(5)
try_time += 1
if try_time >= retry:
break
time.sleep(5)
except Exception as e:
logger.debug(f"URL: {url}")
logger.debug(e)
@@ -35,7 +37,7 @@ class RequestURL:
def post_url(self, url: str, data: dict, retry=3):
try_time = 0
while try_time < retry:
while True:
try:
req = self.session.post(url=url, headers=self.header, data=data, timeout=5)
req.raise_for_status()
@@ -44,8 +46,10 @@ class RequestURL:
logger.debug(e)
logger.warning(f"Cannot connect to {url}.")
logger.warning("Please check DNS/Connection settings")
time.sleep(5)
try_time += 1
if try_time >= retry:
break
time.sleep(5)
except Exception as e:
logger.debug(f"URL: {url}")
logger.debug(e)

View File

@@ -12,10 +12,12 @@ logger = logging.getLogger(__name__)
class RSSAnalyser:
def __init__(self):
self._title_analyser = TitleParser()
with BangumiDatabase() as db:
db.update_table()
def official_title_parser(self, data: BangumiData, mikan_title: str):
if settings.rss_parser.parser_type == "mikan":
data.official_title = mikan_title
data.official_title = mikan_title if mikan_title else data.official_title
elif settings.rss_parser.parser_type == "tmdb":
tmdb_title, season, year = self._title_analyser.tmdb_parser(
data.official_title,
@@ -44,7 +46,10 @@ class RSSAnalyser:
raw=torrent.name, rss_link=rss_link, _id=_id
)
if data and data.title_raw not in [i.title_raw for i in new_data]:
poster_link, mikan_title = torrent.poster_link, torrent.official_title
try:
poster_link, mikan_title = torrent.poster_link, torrent.official_title
except AttributeError:
poster_link, mikan_title = None, None
data.poster_link = poster_link
self.official_title_parser(data, mikan_title)
if not full_parse:
@@ -73,5 +78,4 @@ class RSSAnalyser:
self.rss_to_data(rss_link)
except Exception as e:
logger.debug(e)
print(e)
logger.error("Failed to collect RSS info.")