mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 07:27:15 +08:00
feat: add Rust acceleration for core parsing
This commit is contained in:
@@ -12,6 +12,7 @@ from pyquery import PyQuery
|
||||
from app.core.config import settings
|
||||
from app.log import logger
|
||||
from app.schemas.types import MediaType
|
||||
from app.utils import rust_accel
|
||||
from app.utils.http import RequestUtils, AsyncRequestUtils
|
||||
from app.utils.string import StringUtils
|
||||
from app.utils.url import UrlUtils
|
||||
@@ -95,6 +96,19 @@ class SiteSpider:
|
||||
"""
|
||||
获取搜索URL
|
||||
"""
|
||||
rust_url = rust_accel.build_indexer_search_url({
|
||||
"search": self.search,
|
||||
"batch": self.batch,
|
||||
"browse": self.browse,
|
||||
"category": self.category,
|
||||
"domain": self.domain,
|
||||
"keyword": self.keyword,
|
||||
"mtype": self.mtype.value if self.mtype else None,
|
||||
"cat": self.cat,
|
||||
"page": self.page,
|
||||
})
|
||||
if rust_url:
|
||||
return rust_url
|
||||
# 种子搜索相对路径
|
||||
paths = self.search.get('paths', [])
|
||||
torrentspath = ""
|
||||
@@ -658,6 +672,9 @@ class SiteSpider:
|
||||
"""
|
||||
if not text or not filters or not isinstance(filters, list):
|
||||
return text
|
||||
rust_text = rust_accel.apply_indexer_text_filters(text, filters)
|
||||
if rust_text is not None:
|
||||
return rust_text
|
||||
if not isinstance(text, str):
|
||||
text = str(text)
|
||||
for filter_item in filters:
|
||||
@@ -739,6 +756,16 @@ class SiteSpider:
|
||||
|
||||
# 清空旧结果
|
||||
self.torrents_info_array = []
|
||||
rust_torrents = rust_accel.parse_indexer_torrents(
|
||||
html_text=html_text,
|
||||
domain=self.domain,
|
||||
list_config=self.list,
|
||||
fields=self.fields,
|
||||
category=self.category,
|
||||
result_num=int(self.result_num),
|
||||
)
|
||||
if rust_torrents is not None:
|
||||
return rust_torrents
|
||||
html_doc = None
|
||||
try:
|
||||
# 解析站点文本对象
|
||||
|
||||
Reference in New Issue
Block a user