fix
This commit is contained in:
parent
99dcf96c7c
commit
541a8d725d
@ -1,3 +1,4 @@
|
|||||||
|
import gc
|
||||||
import pickle
|
import pickle
|
||||||
import traceback
|
import traceback
|
||||||
from abc import ABCMeta
|
from abc import ABCMeta
|
||||||
@ -55,6 +56,10 @@ class ChainBase(metaclass=ABCMeta):
|
|||||||
pickle.dump(cache, f)
|
pickle.dump(cache, f)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
logger.error(f"保存缓存 {filename} 出错:{err}")
|
logger.error(f"保存缓存 {filename} 出错:{err}")
|
||||||
|
finally:
|
||||||
|
# 主动资源回收
|
||||||
|
del cache
|
||||||
|
gc.collect()
|
||||||
|
|
||||||
def run_module(self, method: str, *args, **kwargs) -> Any:
|
def run_module(self, method: str, *args, **kwargs) -> Any:
|
||||||
"""
|
"""
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import gc
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from app.chain.download import *
|
from app.chain.download import *
|
||||||
@ -316,9 +315,6 @@ class MessageChain(ChainBase):
|
|||||||
userid=userid, total=len(medias))
|
userid=userid, total=len(medias))
|
||||||
# 保存缓存
|
# 保存缓存
|
||||||
self.save_cache(user_cache, self._cache_file)
|
self.save_cache(user_cache, self._cache_file)
|
||||||
# 主动资源回收
|
|
||||||
del user_cache
|
|
||||||
gc.collect()
|
|
||||||
|
|
||||||
def __post_medias_message(self, channel: MessageChannel,
|
def __post_medias_message(self, channel: MessageChannel,
|
||||||
title: str, items: list, userid: str, total: int):
|
title: str, items: list, userid: str, total: int):
|
||||||
@ -339,6 +335,5 @@ class MessageChain(ChainBase):
|
|||||||
self.post_torrents_message(Notification(
|
self.post_torrents_message(Notification(
|
||||||
channel=channel,
|
channel=channel,
|
||||||
title=f"【{title}】共找到{total}条相关资源,请回复对应数字下载(0: 自动选择 p: 上一页 n: 下一页)",
|
title=f"【{title}】共找到{total}条相关资源,请回复对应数字下载(0: 自动选择 p: 上一页 n: 下一页)",
|
||||||
items=items,
|
|
||||||
userid=userid
|
userid=userid
|
||||||
), torrents=items)
|
), torrents=items)
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
import gc
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Dict, List, Optional, Union, Tuple
|
from typing import Dict, List, Optional, Union, Tuple
|
||||||
|
|
||||||
@ -399,15 +398,14 @@ class SubscribeChain(ChainBase):
|
|||||||
# 如果超过了200条则移除最早的一条
|
# 如果超过了200条则移除最早的一条
|
||||||
if len(torrents_cache[domain]) > settings.CACHE_CONF.get('torrents'):
|
if len(torrents_cache[domain]) > settings.CACHE_CONF.get('torrents'):
|
||||||
torrents_cache[domain].pop(0)
|
torrents_cache[domain].pop(0)
|
||||||
|
# 回收资源
|
||||||
|
del torrents
|
||||||
else:
|
else:
|
||||||
logger.info(f'{indexer.get("name")} 获取到种子')
|
logger.info(f'{indexer.get("name")} 获取到种子')
|
||||||
# 从缓存中匹配订阅
|
# 从缓存中匹配订阅
|
||||||
self.__match(torrents_cache)
|
self.__match(torrents_cache)
|
||||||
# 保存缓存到本地
|
# 保存缓存到本地
|
||||||
self.save_cache(torrents_cache, self._cache_file)
|
self.save_cache(torrents_cache, self._cache_file)
|
||||||
# 主动资源回收
|
|
||||||
del torrents_cache
|
|
||||||
gc.collect()
|
|
||||||
|
|
||||||
def __match(self, torrents_cache: Dict[str, List[Context]]):
|
def __match(self, torrents_cache: Dict[str, List[Context]]):
|
||||||
"""
|
"""
|
||||||
|
@ -9,8 +9,8 @@ from app.log import logger
|
|||||||
from app.modules import _ModuleBase
|
from app.modules import _ModuleBase
|
||||||
from app.modules.themoviedb.category import CategoryHelper
|
from app.modules.themoviedb.category import CategoryHelper
|
||||||
from app.modules.themoviedb.scraper import TmdbScraper
|
from app.modules.themoviedb.scraper import TmdbScraper
|
||||||
from app.modules.themoviedb.tmdbapi import TmdbHelper
|
|
||||||
from app.modules.themoviedb.tmdb_cache import TmdbCache
|
from app.modules.themoviedb.tmdb_cache import TmdbCache
|
||||||
|
from app.modules.themoviedb.tmdbapi import TmdbHelper
|
||||||
from app.schemas.types import MediaType, MediaImageType
|
from app.schemas.types import MediaType, MediaImageType
|
||||||
from app.utils.system import SystemUtils
|
from app.utils.system import SystemUtils
|
||||||
|
|
||||||
|
@ -116,8 +116,6 @@ class TmdbScraper:
|
|||||||
"""
|
"""
|
||||||
生成公共NFO
|
生成公共NFO
|
||||||
"""
|
"""
|
||||||
# TMDBINFO
|
|
||||||
tmdbinfo = mediainfo.tmdb_info
|
|
||||||
# 添加时间
|
# 添加时间
|
||||||
DomUtils.add_node(doc, root, "dateadded",
|
DomUtils.add_node(doc, root, "dateadded",
|
||||||
time.strftime('%Y-%m-%d %H:%M:%S',
|
time.strftime('%Y-%m-%d %H:%M:%S',
|
||||||
@ -160,19 +158,11 @@ class TmdbScraper:
|
|||||||
DomUtils.add_node(doc, xactor, "thumb", actor.get('image'))
|
DomUtils.add_node(doc, xactor, "thumb", actor.get('image'))
|
||||||
DomUtils.add_node(doc, xactor, "profile", actor.get('profile'))
|
DomUtils.add_node(doc, xactor, "profile", actor.get('profile'))
|
||||||
# 风格
|
# 风格
|
||||||
genres = tmdbinfo.get("genres") or []
|
genres = mediainfo.genres or []
|
||||||
for genre in genres:
|
for genre in genres:
|
||||||
DomUtils.add_node(doc, root, "genre", genre.get("name") or "")
|
DomUtils.add_node(doc, root, "genre", genre.get("name") or "")
|
||||||
# 评分
|
# 评分
|
||||||
DomUtils.add_node(doc, root, "rating", mediainfo.vote_average or "0")
|
DomUtils.add_node(doc, root, "rating", mediainfo.vote_average or "0")
|
||||||
# 评级
|
|
||||||
if tmdbinfo.get("releases") and tmdbinfo.get("releases").get("countries"):
|
|
||||||
releases = [i for i in tmdbinfo.get("releases").get("countries") if
|
|
||||||
i.get("certification") and i.get("certification").strip()]
|
|
||||||
# 国内没有分级,所以沿用美国的分级
|
|
||||||
us_release = next((c for c in releases if c.get("iso_3166_1") == "US"), None)
|
|
||||||
if us_release:
|
|
||||||
DomUtils.add_node(doc, root, "mpaa", us_release.get("certification") or "")
|
|
||||||
|
|
||||||
return doc
|
return doc
|
||||||
|
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
import warnings
|
|
||||||
from ..tmdb import TMDb
|
from ..tmdb import TMDb
|
||||||
from .find import Find
|
|
||||||
from .search import Search
|
|
||||||
|
|
||||||
|
|
||||||
class Movie(TMDb):
|
class Movie(TMDb):
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import warnings
|
|
||||||
from ..tmdb import TMDb
|
from ..tmdb import TMDb
|
||||||
from .search import Search
|
|
||||||
|
|
||||||
|
|
||||||
class Person(TMDb):
|
class Person(TMDb):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user