jxxghp / MoviePilot

NAS媒体库自动化管理工具
https://wiki.movie-pilot.org
GNU General Public License v3.0
6.77k stars 810 forks source link

[错误报告]: plex`媒体库服务器刷新`有问题 #2188

Closed BrettDean closed 5 months ago

BrettDean commented 5 months ago

确认

当前程序版本

v1.9.1-1

运行环境

Docker

问题类型

主程序运行问题

问题描述

plex部分刷新有问题,据我观察,这个函数貌似全都是匹配失败刷新全库

    def refresh_library_by_items(self, items: List[schemas.RefreshMediaItem]) -> bool:
        """
        按路径刷新媒体库 item: target_path
        """
        if not self._plex:
            return False
        result_dict = {}
        for item in items:
            file_path = item.target_path
            lib_key, path = self.__find_librarie(file_path, self._libraries)
            # 如果存在同一剧集的多集,key(path)相同会合并
            result_dict[path] = lib_key
        if "" in result_dict:
            # 如果有匹配失败的,刷新整个库
            self._plex.library.update()
        else:
            # 否则一个一个刷新
            for path, lib_key in result_dict.items():
                logger.info(f"刷新媒体库:{lib_key} - {path}")
                self._plex.query(f'/library/sections/{lib_key}/refresh?path={quote_plus(path)}')

为了便于观察,媒体库服务器刷新的延迟时间设置为0

这是dirmonitor.log:

【INFO】2024-05-26 15:08:09,127 - filetransfer - 获取转移目标路径:/mnt/MyPassport/Library/电视剧/综艺
【INFO】2024-05-26 15:08:09,199 - filetransfer - 正在转移文件:/mnt/MyPassport/downloads/电视剧/综艺/康熙来了.Pass.Through.ConCsi.S02.2005.1080p.WEB-DL.H264.AAC/康熙来了.Pass.Through.ConCsi.S02E018.2005.1080p.WEB-DL.H264.AAC.mp4 到 /mnt/MyPassport/Library/电视剧/综艺/康熙来了 (2004)/Season 2/康熙来了 - S02E18 - 1080p - 王子的真实世界 - H264 - AAC.mp4
【INFO】2024-05-26 15:08:16,840 - dirmonitor - 开始处理媒体 康熙来了 (2004) S06 消息
【INFO】2024-05-26 15:08:31,840 - dirmonitor - 开始处理媒体 康熙来了 (2004) S06 消息
【INFO】2024-05-26 15:08:46,840 - dirmonitor - 开始处理媒体 康熙来了 (2004) S06 消息
【INFO】2024-05-26 15:08:46,843 - chain - 发送消息:channel=None,title=康熙来了 (2004) S06 E41 已入库, text=评分:7.5,类型:电视剧,类别:综艺,质量: WEB-DL 1080p,共1个文件,大小:1.7G,userid=None
【INFO】2024-05-26 15:22:18,143 - filetransfer - 文件 /mnt/MyPassport/downloads/电视剧/综艺/康熙来了.Pass.Through.ConCsi.S02.2005.1080p.WEB-DL.H264.AAC/康熙来了.Pass.Through.ConCsi.S02E018.2005.1080p.WEB-DL.H264.AAC.mp4 move完成
【INFO】2024-05-26 15:22:18,151 - filetransfer - 文件 /mnt/MyPassport/downloads/电视剧/综艺/康熙来了.Pass.Through.ConCsi.S02.2005.1080p.WEB-DL.H264.AAC/康熙来了.Pass.Through.ConCsi.S02E018.2005.1080p.WEB-DL.H264.AAC.mp4 转移成功
【INFO】2024-05-26 15:22:18,739 - themoviedb - 开始刮削媒体库文件:/mnt/MyPassport/Library/电视剧/综艺/康熙来了 (2004)/Season 2/康熙来了 - S02E18 - 1080p - 王子的真实世界 - H264 - AAC.mp4 ...
【INFO】2024-05-26 15:22:18,763 - scraper.py - 正在生成剧集NFO文件:康熙来了 - S02E18 - 1080p - 王子的真实世界 - H264 - AAC.mp4
【INFO】2024-05-26 15:22:18,770 - scraper.py - NFO文件已保存:/mnt/MyPassport/Library/电视剧/综艺/康熙来了 (2004)/Season 2/康熙来了 - S02E18 - 1080p - 王子的真实世界 - H264 - AAC.nfo
【INFO】2024-05-26 15:22:18,773 - themoviedb - /mnt/MyPassport/Library/电视剧/综艺/康熙来了 (2004)/Season 2/康熙来了 - S02E18 - 1080p - 王子的真实世界 - H264 - AAC.mp4 刮削完成
【INFO】2024-05-26 15:22:18,952 - themoviedb - 康熙来了 使用TMDB识别缓存:康熙来了
【INFO】2024-05-26 15:22:18,958 - themoviedb - 康熙来了 TMDB识别结果:电视剧 康熙来了 (2004) 6836
【INFO】2024-05-26 15:22:18,959 - dirmonitor - 康熙来了.Pass.Through.ConCsi.S01E123.2004.1080p.WEB-DL.H264.AAC.mp4 识别为:电视剧 康熙来了 (2004)
【WARNING】2024-05-26 15:22:18,965 - fanart - 没有获取到 康熙来了 (2004) 的fanart图片数据

可以看见第7行,15:22:18,143filetransfer转移文件成功


这是plex日志:

May 26, 2024 15:22:18.830 [134032528517944] DEBUG - Activity: registered new activity 63772ef0-de99-44be-baeb-1a1e79ae4e12 - "Scanning"
May 26, 2024 15:22:18.836 [134032528517944] DEBUG - Scanning section 2
May 26, 2024 15:22:18.836 [134032528517944] DEBUG - Activity: updated activity 63772ef0-de99-44be-baeb-1a1e79ae4e12 - completed 0.0% - Scanning 儿童电视剧
May 26, 2024 15:22:18.894 [134032528517944] DEBUG - Scanning 儿童电视剧 using zh-CN(Plex TV Series) with 10847 current media items and 1 section locations in the database.
May 26, 2024 15:22:18.894 [134032528517944] DEBUG - Performing a scan with 'Plex TV Series' (language: zh-CN virtual: 0).
May 26, 2024 15:22:18.894 [134032528517944] DEBUG -   * Scanning /mnt/MyPassport/Library/电视剧/儿童
May 26, 2024 15:22:19.277 [134032528517944] DEBUG - Scanner: Processing directory /mnt/MyPassport/Library/电视剧/儿童 (parent: no)
May 26, 2024 15:22:19.312 [134032528517944] DEBUG - Scanner: Processing directory /mnt/MyPassport/Library/电视剧/儿童/巴啦啦小魔仙 (2008) (parent: yes)
...
...
略

可以看见第1行,15:22:18.830,plex注册了一个扫描活动,并且扫描不是精准扫描刚才入库的位置,而是全部媒体库全盘扫描,儿童电视剧只是全盘扫描中的第一个媒体库。

入库的剧集不是plex中的新剧,而是plex中已经有记录的剧,只是plex缺少新入库的这集

感觉plex一天24h都在不停扫描(plex所有定时扫描,自动刷新任务都关闭了,只保留了mp的插件:媒体库服务器刷新




下面是另外一次:

dirmonitor.log:

【INFO】2024-05-26 15:47:35,604 - themoviedb - The Flavor Of History TMDB识别结果:电视剧 惟有香如故 (2023) 219992
【INFO】2024-05-26 15:47:35,914 - dirmonitor - The.Flavor.of.History.S01E02.2160p.WEB-DL.H264.AAC.mkv 识别为:电视剧 惟有香如故 (2023)
【INFO】2024-05-26 15:47:35,960 - fanart - 惟有香如故 (2023) 没有tvdbid,无法获取fanart图片
【INFO】2024-05-26 15:47:37,098 - filetransfer - 获取转移目标路径:/mnt/MyPassport/Library/电视剧/纪录片
【INFO】2024-05-26 15:47:37,378 - filetransfer - 正在转移文件:/mnt/MyPassport/downloads/电视剧/纪录片/The.Flavor.of.History.S01.2160p.WEB-DL.H264.AAC/The.Flavor.of.History.S01E02.2160p.WEB-DL.H264.AAC.mkv 到 /mnt/MyPassport/Library/电视剧/纪录片/惟有香如故 (2023)/Season 1/惟有香如故 - S01E02 - 2160p - 如梦令 - H264 - AAC.mkv
【INFO】2024-05-26 15:48:59,821 - filetransfer - 文件 /mnt/MyPassport/downloads/电视剧/纪录片/The.Flavor.of.History.S01.2160p.WEB-DL.H264.AAC/The.Flavor.of.History.S01E02.2160p.WEB-DL.H264.AAC.mkv move完成
【INFO】2024-05-26 15:48:59,827 - filetransfer - 文件 /mnt/MyPassport/downloads/电视剧/纪录片/The.Flavor.of.History.S01.2160p.WEB-DL.H264.AAC/The.Flavor.of.History.S01E02.2160p.WEB-DL.H264.AAC.mkv 转移成功
【INFO】2024-05-26 15:48:59,843 - themoviedb - 开始刮削媒体库文件:/mnt/MyPassport/Library/电视剧/纪录片/惟有香如故 (2023)/Season 1/惟有香如故 - S01E02 - 2160p - 如梦令 - H264 - AAC.mkv ...
【INFO】2024-05-26 15:48:59,847 - scraper.py - 正在生成剧集NFO文件:惟有香如故 - S01E02 - 2160p - 如梦令 - H264 - AAC.mkv
【INFO】2024-05-26 15:48:59,850 - scraper.py - NFO文件已保存:/mnt/MyPassport/Library/电视剧/纪录片/惟有香如故 (2023)/Season 1/惟有香如故 - S01E02 - 2160p - 如梦令 - H264 - AAC.nfo
【INFO】2024-05-26 15:48:59,852 - scraper.py - 正在下载惟有香如故 - S01E02 - 2160p - 如梦令 - H264 - AAC-thumb图片:https://image.tmdb.org/t/p/original/p2ODbZekxTA6nl4mHDwq35qOBqV.jpg ...
【INFO】2024-05-26 15:49:02,724 - scraper.py - 图片已保存:/mnt/MyPassport/Library/电视剧/纪录片/惟有香如故 (2023)/Season 1/惟有香如故 - S01E02 - 2160p - 如梦令 - H264 - AAC-thumb.jpg
【INFO】2024-05-26 15:49:02,736 - themoviedb - /mnt/MyPassport/Library/电视剧/纪录片/惟有香如故 (2023)/Season 1/惟有香如故 - S01E02 - 2160p - 如梦令 - H264 - AAC.mkv 刮削完成
【INFO】2024-05-26 15:49:16,841 - dirmonitor - 开始处理媒体 惟有香如故 (2023) S01 消息
【INFO】2024-05-26 15:49:31,850 - dirmonitor - 开始处理媒体 惟有香如故 (2023) S01 消息
【INFO】2024-05-26 15:49:46,841 - dirmonitor - 开始处理媒体 惟有香如故 (2023) S01 消息
【INFO】2024-05-26 15:49:46,842 - chain - 发送消息:channel=None,title=惟有香如故 (2023) S01 E02 已入库, text=评分:9.0,类型:电视剧,类别:纪录片,质量: WEB-DL 2160p,共1个文件,大小:1.77G,userid=None

plex日志:

May 26, 2024 15:49:02.820 [134032528517944] DEBUG - Activity: registered new activity 656485a0-fcc0-4f55-a0bc-e9482aa9e8ae - "Scanning"
May 26, 2024 15:49:02.821 [134032528517944] DEBUG - Scanning section 2
May 26, 2024 15:49:02.821 [134032528517944] DEBUG - Activity: updated activity 656485a0-fcc0-4f55-a0bc-e9482aa9e8ae - completed 0.0% - Scanning 儿童电视剧
May 26, 2024 15:49:02.893 [134032528517944] DEBUG - Scanning 儿童电视剧 using zh-CN(Plex TV Series) with 10847 current media items and 1 section locations in the database.
May 26, 2024 15:49:02.893 [134032528517944] DEBUG - Performing a scan with 'Plex TV Series' (language: zh-CN virtual: 0).
May 26, 2024 15:49:02.893 [134032528517944] DEBUG -   * Scanning /mnt/MyPassport/Library/电视剧/儿童
May 26, 2024 15:49:03.502 [134032528517944] DEBUG - Scanner: Processing directory /mnt/MyPassport/Library/电视剧/儿童 (parent: no)
May 26, 2024 15:49:03.529 [134032528517944] DEBUG - Scanner: Processing directory /mnt/MyPassport/Library/电视剧/儿童/巴啦啦小魔仙 (2008) (parent: yes)
May 26, 2024 15:49:03.732 [134032528517944] DEBUG - Scanner: Processing directory /mnt/MyPassport/Library/电视剧/儿童/巴啦啦小魔仙 (2008)/Season 1 (parent: yes)
May 26, 2024 15:49:04.191 [134032528517944] DEBUG - Activity: updated activity 656485a0-fcc0-4f55-a0bc-e9482aa9e8ae - completed 1.0% - Scanning 儿童电视剧
May 26, 2024 15:49:04.191 [134032528517944] DEBUG - Scanner: Processing directory /mnt/MyPassport/Library/电视剧/儿童/机界战队全开者 (2021) (parent: yes)
...
...
略

和第一次一样,基本是mp转移完成以后,plex就会开始刷新全库,而不是精准扫描

发生问题时系统日志和配置文件

我也感觉到我提issue有点频繁了,,我以后注意。。
InfinityPacer commented 5 months ago

MyPassport/Library/电视剧/综艺/ MyPassport/Library/电视剧/儿童/ 麻烦分别贴一下 Plex 上述内容媒体库对应的路径,以及 plex.py 的完整日志

BrettDean commented 5 months ago

MyPassport/Library/电视剧/综艺/ MyPassport/Library/电视剧/儿童/ 麻烦分别贴一下 Plex 上述内容媒体库对应的路径

@InfinityPacer ,Plex 上述内容媒体库对应的路径:

/home/Library/电视剧/综艺
/home/Library/电视剧/儿童

你这么一说我就明白了,我的

Library同时挂载到了/mnt/MyPassport/home

/mnt/MyPassport/Library用于mp转移;

/home/Library用于plex读取

以前以为mp传给plex刷新的路径是通过plexapi获取的,没想到不是这样

刚才我将mp媒体库路径也改成和plex设置中相同的/home/Library以后,就可以部分刷新了

Plex\ Media\ Server.log:

May 27, 2024 11:02:07.843 [134032199265080] DEBUG - Activity: registered new activity 9bd74c2d-6f1b-46f7-8a3b-212f458dc153 - "Scanning"
May 27, 2024 11:02:07.843 [134032199265080] DEBUG - Scanning section 3
May 27, 2024 11:02:07.843 [134032199265080] DEBUG - Activity: updated activity 9bd74c2d-6f1b-46f7-8a3b-212f458dc153 - completed 0.0% - Scanning 国产剧
May 27, 2024 11:02:08.786 [134032199265080] DEBUG - Scanning 国产剧 using zh-CN(Plex TV Series) with 0 current media items and 1 section locations in the database.
May 27, 2024 11:02:08.786 [134032199265080] DEBUG - Performing a scan with 'Plex TV Series' (language: zh-CN virtual: 0).
May 27, 2024 11:02:08.786 [134032199265080] DEBUG -   * Scanning /home/Library/电视剧/国产剧/完全省钱恋爱手册 (2024)/Season 1/完全省钱恋爱手册 - S01E12 - 1080p - 第 12 集 - H264 - DDP 2.0.mkv
May 27, 2024 11:02:08.790 [134032199265080] DEBUG - Scanner: Processing directory /home/Library/电视剧/国产剧/完全省钱恋爱手册 (2024)/Season 1/完全省钱恋爱手册 - S01E12 - 1080p - 第 12 集 - H264 - DDP 2.0.mkv (parent: yes)
May 27, 2024 11:02:08.793 [134032199265080] DEBUG - Activity: updated activity 9bd74c2d-6f1b-46f7-8a3b-212f458dc153 - completed 0.0% - Scanning 国产剧
May 27, 2024 11:02:08.793 [134032199265080] DEBUG - Activity: updated activity 9bd74c2d-6f1b-46f7-8a3b-212f458dc153 - completed 99.0% - Scanning 国产剧

将两个软件操作的路径分开本是为了区分读取和写入(是用两个不同的软件挂载的),没想弄巧成拙,现在我知道怎么做了,

只要将moviepilotdocker路径映射改一下,和plex设置相同即可

至于后续刷新的时候要不要调用plexapi来获取刷新路径,你们随意

若不用,可以Close issue

感谢!