fix 优化豆瓣插件媒体识别
This commit is contained in:
parent
573a943467
commit
21908bdc6f
@ -2,12 +2,13 @@ import datetime
|
|||||||
import re
|
import re
|
||||||
import xml.dom.minidom
|
import xml.dom.minidom
|
||||||
from threading import Event
|
from threading import Event
|
||||||
from typing import Tuple, List, Dict, Any, Optional
|
from typing import Tuple, List, Dict, Any
|
||||||
|
|
||||||
import pytz
|
import pytz
|
||||||
from apscheduler.schedulers.background import BackgroundScheduler
|
from apscheduler.schedulers.background import BackgroundScheduler
|
||||||
from apscheduler.triggers.cron import CronTrigger
|
from apscheduler.triggers.cron import CronTrigger
|
||||||
|
|
||||||
|
from app.chain.douban import DoubanChain
|
||||||
from app.chain.download import DownloadChain
|
from app.chain.download import DownloadChain
|
||||||
from app.chain.subscribe import SubscribeChain
|
from app.chain.subscribe import SubscribeChain
|
||||||
from app.core.config import settings
|
from app.core.config import settings
|
||||||
@ -46,6 +47,7 @@ class DoubanRank(_PluginBase):
|
|||||||
# 私有属性
|
# 私有属性
|
||||||
downloadchain: DownloadChain = None
|
downloadchain: DownloadChain = None
|
||||||
subscribechain: SubscribeChain = None
|
subscribechain: SubscribeChain = None
|
||||||
|
doubanchain: DoubanChain = None
|
||||||
_scheduler = None
|
_scheduler = None
|
||||||
_douban_address = {
|
_douban_address = {
|
||||||
'movie-ustop': 'https://rsshub.app/douban/movie/ustop',
|
'movie-ustop': 'https://rsshub.app/douban/movie/ustop',
|
||||||
@ -68,6 +70,7 @@ class DoubanRank(_PluginBase):
|
|||||||
def init_plugin(self, config: dict = None):
|
def init_plugin(self, config: dict = None):
|
||||||
self.downloadchain = DownloadChain()
|
self.downloadchain = DownloadChain()
|
||||||
self.subscribechain = SubscribeChain()
|
self.subscribechain = SubscribeChain()
|
||||||
|
self.doubanchain = DoubanChain()
|
||||||
|
|
||||||
if config:
|
if config:
|
||||||
self._enabled = config.get("enabled")
|
self._enabled = config.get("enabled")
|
||||||
@ -471,26 +474,23 @@ class DoubanRank(_PluginBase):
|
|||||||
# 检查是否已处理过
|
# 检查是否已处理过
|
||||||
if unique_flag in [h.get("unique") for h in history]:
|
if unique_flag in [h.get("unique") for h in history]:
|
||||||
continue
|
continue
|
||||||
|
# 元数据
|
||||||
|
meta = MetaInfo(title)
|
||||||
# 识别媒体信息
|
# 识别媒体信息
|
||||||
if douban_id:
|
if douban_id:
|
||||||
# 根据豆瓣ID获取豆瓣数据
|
# 识别豆瓣信息
|
||||||
doubaninfo: Optional[dict] = self.chain.douban_info(doubanid=douban_id)
|
context = self.doubanchain.recognize_by_doubanid(douban_id)
|
||||||
if not doubaninfo:
|
mediainfo = context.media_info
|
||||||
logger.warn(f'未获取到豆瓣信息,标题:{title},豆瓣ID:{douban_id}')
|
if not mediainfo or not mediainfo.tmdb_id:
|
||||||
|
logger.warn(f'未识别到媒体信息,标题:{title},豆瓣ID:{douban_id}')
|
||||||
continue
|
continue
|
||||||
logger.info(f'获取到豆瓣信息,标题:{title},豆瓣ID:{douban_id}')
|
|
||||||
# 识别
|
|
||||||
title = doubaninfo.get("title")
|
|
||||||
meta = MetaInfo(doubaninfo.get("original_title") or title)
|
|
||||||
if doubaninfo.get("year"):
|
|
||||||
meta.year = doubaninfo.get("year")
|
|
||||||
else:
|
else:
|
||||||
meta = MetaInfo(title)
|
# 匹配媒体信息
|
||||||
# 匹配媒体信息
|
mediainfo: MediaInfo = self.chain.recognize_media(meta=meta)
|
||||||
mediainfo: MediaInfo = self.chain.recognize_media(meta=meta)
|
if not mediainfo:
|
||||||
if not mediainfo:
|
logger.warn(f'未识别到媒体信息,标题:{title},豆瓣ID:{douban_id}')
|
||||||
logger.warn(f'未识别到媒体信息,标题:{title},豆瓣ID:{douban_id}')
|
continue
|
||||||
continue
|
|
||||||
# 查询缺失的媒体信息
|
# 查询缺失的媒体信息
|
||||||
exist_flag, _ = self.downloadchain.get_no_exists_info(meta=meta, mediainfo=mediainfo)
|
exist_flag, _ = self.downloadchain.get_no_exists_info(meta=meta, mediainfo=mediainfo)
|
||||||
if exist_flag:
|
if exist_flag:
|
||||||
@ -526,7 +526,7 @@ class DoubanRank(_PluginBase):
|
|||||||
logger.info(f"所有榜单RSS刷新完成")
|
logger.info(f"所有榜单RSS刷新完成")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def __get_rss_info(addr):
|
def __get_rss_info(addr) -> List[dict]:
|
||||||
"""
|
"""
|
||||||
获取RSS
|
获取RSS
|
||||||
"""
|
"""
|
||||||
|
@ -7,11 +7,11 @@ import pytz
|
|||||||
from apscheduler.schedulers.background import BackgroundScheduler
|
from apscheduler.schedulers.background import BackgroundScheduler
|
||||||
from apscheduler.triggers.cron import CronTrigger
|
from apscheduler.triggers.cron import CronTrigger
|
||||||
|
|
||||||
|
from app.chain.douban import DoubanChain
|
||||||
from app.chain.download import DownloadChain
|
from app.chain.download import DownloadChain
|
||||||
from app.chain.search import SearchChain
|
from app.chain.search import SearchChain
|
||||||
from app.chain.subscribe import SubscribeChain
|
from app.chain.subscribe import SubscribeChain
|
||||||
from app.core.config import settings
|
from app.core.config import settings
|
||||||
from app.core.context import MediaInfo
|
|
||||||
from app.core.event import Event
|
from app.core.event import Event
|
||||||
from app.core.event import eventmanager
|
from app.core.event import eventmanager
|
||||||
from app.core.metainfo import MetaInfo
|
from app.core.metainfo import MetaInfo
|
||||||
@ -53,6 +53,7 @@ class DoubanSync(_PluginBase):
|
|||||||
downloadchain = None
|
downloadchain = None
|
||||||
searchchain = None
|
searchchain = None
|
||||||
subscribechain = None
|
subscribechain = None
|
||||||
|
doubanchain = None
|
||||||
|
|
||||||
# 配置属性
|
# 配置属性
|
||||||
_enabled: bool = False
|
_enabled: bool = False
|
||||||
@ -69,6 +70,7 @@ class DoubanSync(_PluginBase):
|
|||||||
self.downloadchain = DownloadChain()
|
self.downloadchain = DownloadChain()
|
||||||
self.searchchain = SearchChain()
|
self.searchchain = SearchChain()
|
||||||
self.subscribechain = SubscribeChain()
|
self.subscribechain = SubscribeChain()
|
||||||
|
self.doubanchain = DoubanChain()
|
||||||
|
|
||||||
# 停止现有任务
|
# 停止现有任务
|
||||||
self.stop_service()
|
self.stop_service()
|
||||||
@ -474,18 +476,11 @@ class DoubanSync(_PluginBase):
|
|||||||
if not douban_id or douban_id in [h.get("doubanid") for h in history]:
|
if not douban_id or douban_id in [h.get("doubanid") for h in history]:
|
||||||
logger.info(f'标题:{title},豆瓣ID:{douban_id} 已处理过')
|
logger.info(f'标题:{title},豆瓣ID:{douban_id} 已处理过')
|
||||||
continue
|
continue
|
||||||
# 根据豆瓣ID获取豆瓣数据
|
|
||||||
doubaninfo: Optional[dict] = self.chain.douban_info(doubanid=douban_id)
|
|
||||||
if not doubaninfo:
|
|
||||||
logger.warn(f'未获取到豆瓣信息,标题:{title},豆瓣ID:{douban_id}')
|
|
||||||
continue
|
|
||||||
logger.info(f'获取到豆瓣信息,标题:{title},豆瓣ID:{douban_id}')
|
|
||||||
# 识别媒体信息
|
# 识别媒体信息
|
||||||
meta = MetaInfo(doubaninfo.get("original_title") or doubaninfo.get("title"))
|
meta = MetaInfo(title=title)
|
||||||
if doubaninfo.get("year"):
|
context = self.doubanchain.recognize_by_doubanid(douban_id)
|
||||||
meta.year = doubaninfo.get("year")
|
mediainfo = context.media_info
|
||||||
mediainfo: MediaInfo = self.chain.recognize_media(meta=meta)
|
if not mediainfo or not mediainfo.tmdb_id:
|
||||||
if not mediainfo:
|
|
||||||
logger.warn(f'未识别到媒体信息,标题:{title},豆瓣ID:{douban_id}')
|
logger.warn(f'未识别到媒体信息,标题:{title},豆瓣ID:{douban_id}')
|
||||||
continue
|
continue
|
||||||
# 查询缺失的媒体信息
|
# 查询缺失的媒体信息
|
||||||
@ -531,7 +526,7 @@ class DoubanSync(_PluginBase):
|
|||||||
# 存储历史记录
|
# 存储历史记录
|
||||||
history.append({
|
history.append({
|
||||||
"action": action,
|
"action": action,
|
||||||
"title": doubaninfo.get("title") or mediainfo.title,
|
"title": title,
|
||||||
"type": mediainfo.type.value,
|
"type": mediainfo.type.value,
|
||||||
"year": mediainfo.year,
|
"year": mediainfo.year,
|
||||||
"poster": mediainfo.get_poster_image(),
|
"poster": mediainfo.get_poster_image(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user