From 52018d3d99fe88f813f3571c2b67c3903c3ed5c6 Mon Sep 17 00:00:00 2001 From: thsrite Date: Sat, 17 Aug 2024 20:44:12 +0800 Subject: [PATCH] fix --- README.md | 2 +- package.json | 3 +- plugins/embyaudiobook/__init__.py | 50 +++++++++++++++++++++---------- 3 files changed, 38 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 874f55f..dc09f8e 100644 --- a/README.md +++ b/README.md @@ -51,4 +51,4 @@ MoviePilot三方插件市场:https://github.com/thsrite/MoviePilot-Plugins/ - Emby合集媒体排序 v1.1 - 影视将映订阅 v1.1 - Emby视频类型检查 v1.0 -- Emby有声书整理 v1.0 +- Emby有声书整理 v1.1 diff --git a/package.json b/package.json index 1ae8f3b..02d10b1 100644 --- a/package.json +++ b/package.json @@ -734,11 +734,12 @@ "name": "Emby有声书整理", "description": "还在为Emby有声书整理烦恼吗?入库存在很多单集?", "labels": "Emby,媒体库", - "version": "1.0", + "version": "1.1", "icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/audiobook.png", "author": "thsrite", "level": 1, "history": { + "v1.1": "整理完锁定,防止数据被刷新", "v1.0": "还在为Emby有声书整理烦恼吗?入库存在很多单集。" } } diff --git a/plugins/embyaudiobook/__init__.py b/plugins/embyaudiobook/__init__.py index 1e85e42..abbf4a5 100644 --- a/plugins/embyaudiobook/__init__.py +++ b/plugins/embyaudiobook/__init__.py @@ -30,7 +30,7 @@ class EmbyAudioBook(_PluginBase): # 插件图标 plugin_icon = "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/audiobook.png" # 插件版本 - plugin_version = "1.0" + plugin_version = "1.1" # 插件作者 plugin_author = "thsrite" # 作者主页 @@ -145,21 +145,33 @@ class EmbyAudioBook(_PluginBase): return # 检查有声书是否需要整理 + __need_zl = False for book_item in book_items: if not book_item.get("AlbumId"): - logger.info(f"有声书 {item.get('Name')} 需要整理,共 {len(book_items)} 集") - # self.__zl(items, -1) - # 发送通知 - if self._notify: - mtype = NotificationType.Manual - if self._msgtype: - mtype = NotificationType.__getitem__(str(self._msgtype)) or NotificationType.Manual - self.post_message(title="Emby有声书整理", - mtype=mtype, - text=f"有声书 {item.get('Name')} 需要整理,共 {len(book_items)} 集") - + __need_zl = True break + # 需要整理的提示需要整理 + if __need_zl: + logger.info(f"有声书 {item.get('Name')} 需要整理,共 {len(book_items)} 集") + # self.__zl(items, -1) + # 发送通知 + if self._notify: + mtype = NotificationType.Manual + if self._msgtype: + mtype = NotificationType.__getitem__(str(self._msgtype)) or NotificationType.Manual + self.post_message(title="Emby有声书整理", + mtype=mtype, + text=f"有声书 {item.get('Name')} 需要整理,共 {len(book_items)} 集") + else: + # 不需要整理的锁定 + other_book_info = self.__get_item_info(item.get("Id")) + other_book_info.update({ + "LockData": True, + }) + self.__update_item_info(item.get("Id"), other_book_info) + logger.info(f"有声书 {item.get('Name')} 不需要整理,已锁定") + logger.info("Emby有声书整理服务执行完毕") @eventmanager.register(EventType.PluginAction) @@ -206,9 +218,11 @@ class EmbyAudioBook(_PluginBase): # 获取指定有声书 book_id = None + book_info = None for item in items: if book_name in item.get("Name"): book_id = item.get("Id") + book_info = self.__get_item_info(book_id) break if not book_id: @@ -227,6 +241,11 @@ class EmbyAudioBook(_PluginBase): return self.__zl(items, int(book_idx)) + if book_info: + book_info.update({ + "LockData": True, + }) + self.__update_item_info(book_id, book_info) self.post_message(channel=event.event_data.get("channel"), title=f"{book_name} 有声书整理完成!", userid=event.event_data.get("user")) @@ -305,7 +324,7 @@ class EmbyAudioBook(_PluginBase): while retry < 3: try: # 获取有声书信息 - item_info = self.__get_audiobook_item_info(item.get("Id")) + item_info = self.__get_item_info(item.get("Id")) # 重命名前判断名称是否一致 if self._rename and item.get("Name") == Path(Path(item_info.get("Path")).name).stem: @@ -322,7 +341,8 @@ class EmbyAudioBook(_PluginBase): "AlbumArtist": AlbumArtist, "AlbumArtists": AlbumArtists, "ParentIndexNumber": ParentIndexNumber, - "IndexNumber": episode + "IndexNumber": episode, + "LockData": True, }) retry = 3 except Exception as e: @@ -360,7 +380,7 @@ class EmbyAudioBook(_PluginBase): logger.error(f"连接有声书Items出错:" + str(e)) return [] - def __get_audiobook_item_info(self, item_id) -> dict: + def __get_item_info(self, item_id) -> dict: """ 获取有声书剧集详情 """