From fc0090512b31e283a6fbfe6fda1ed7979198b1fb Mon Sep 17 00:00:00 2001 From: xiaoQQya Date: Tue, 30 Sep 2025 23:28:28 +0800 Subject: [PATCH] =?UTF-8?q?fix(embymetarefresh):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E5=BA=8F=E5=88=97=E5=8C=96=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.v2.json | 3 ++- plugins.v2/embymetarefresh/__init__.py | 21 ++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/package.v2.json b/package.v2.json index 15f6097..142e29a 100644 --- a/package.v2.json +++ b/package.v2.json @@ -21,11 +21,12 @@ "name": "Emby元数据刷新", "description": "定时刷新Emby媒体库元数据,演职人员中文。", "labels": "Emby", - "version": "2.3.1", + "version": "2.3.2", "icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/emby-icon.png", "author": "thsrite", "level": 1, "history": { + "v2.3.2": "修复缓存序列化错误问题", "v2.3.1": "doumao yyds", "v2.3.0": "优化内存占用", "v2.2.8": "修复按照历史记录刷新,auto默认为true", diff --git a/plugins.v2/embymetarefresh/__init__.py b/plugins.v2/embymetarefresh/__init__.py index 6e86fb7..3791321 100644 --- a/plugins.v2/embymetarefresh/__init__.py +++ b/plugins.v2/embymetarefresh/__init__.py @@ -1,12 +1,12 @@ import base64 -import copy import json import re import threading import time +import pickle from datetime import datetime, timedelta from typing import Optional, Any, List, Dict, Tuple -from app.core.cache import FileCache, AsyncFileCache +from app.core.cache import FileCache from pathlib import Path import pytz @@ -43,7 +43,7 @@ class EmbyMetaRefresh(_PluginBase): # 插件图标 plugin_icon = "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/emby-icon.png" # 插件版本 - plugin_version = "2.3.1" + plugin_version = "2.3.2" # 插件作者 plugin_author = "thsrite" # 作者主页 @@ -77,7 +77,7 @@ class EmbyMetaRefresh(_PluginBase): _EMBY_USER = None _EMBY_APIKEY = None _scheduler: Optional[BackgroundScheduler] = None - _tmdb_cache = {} + _tmdb_cache = None _episodes_images = [] _region_name = "embymetarefresh_cache" @@ -87,10 +87,10 @@ class EmbyMetaRefresh(_PluginBase): self.tmdbchain = TmdbChain() self.tmdbapi = TmdbApi() self.mediaserver_helper = MediaServerHelper() - # 创建缓存实例,最大128项,TTL 30分钟 + # 创建缓存实例,使用 Redis 缓存时保留 7 天,使用文件系统缓存停止服务时清理 self._tmdb_cache = FileCache( base=Path(f"/tmp/{self._region_name}"), - ttl=604800 # 7天 + ttl=604800 ) if config: @@ -280,7 +280,7 @@ class EmbyMetaRefresh(_PluginBase): # 判断是否有缓存 key = f"{item.get('Type')}-{item.get('SeriesName')}-{str(item.get('ProductionYear'))}" # 检查缓存 - tv_info = self._tmdb_cache.get(key, region=self._region_name) or None + tv_info = self._tmdb_cache.get(key, region=self._region_name) if not tv_info: # 判断下tmdb有没有封面,没有则不刷新封面 @@ -292,7 +292,10 @@ class EmbyMetaRefresh(_PluginBase): mtype=MediaType.TV, year=str(item.get('ProductionYear'))) if tv_info: - self._tmdb_cache.set(key, tv_info, region=self._region_name) + if isinstance(tv_info, bytes): + tv_info = pickle.loads(tv_info) + + self._tmdb_cache.set(key, pickle.dumps(tv_info), region=self._region_name) episode_info = TmdbApi().get_tv_episode_detail(tv_info["id"], item.get('ParentIndexNumber'), item.get('IndexNumber')) @@ -1495,4 +1498,4 @@ class EmbyMetaRefresh(_PluginBase): if subscribe_history: tmdb_id = subscribe_history.tmdbid - return tmdb_id + return tmdb_id \ No newline at end of file