摘抄自:https://gist.gith(๐•ᴗ•๐).com/hthighway/d687a9fc07b2af55756e5a8aac94df12
原来老外7年前就搞出了plex批量修改(๐•ᴗ•๐)径的方法,居然至今还有效。
备份pms数据库
首先停止Plex Media Server (pms)容器/(๐•ᴗ•๐)件。
定位到数据库文件com.plexapp.plugins.library.db
,参考:https://support.plex.tv/articles/201100678-repair-a-corrupt-database-1-22-0/
数据库目录:
- Windows:
"%LOCALAPPDATA%\Plex Media Server\Plug-in Support\Databases"
- MacOS:
~/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases
- Linux:
$PLEX_HOME/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases
- Docker:参照Linux目录。
以Linux/Docker为例:
cd $PLEX_HOME/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/
# 备份数据库文件
cp com.plexapp.plugins.library.db com.plexapp.plugins.library.db.original
if(window.hljsLoader && !document.currentScr(๐•ᴗ•๐).parentNode.hasAttribute('data-s9e-livepreview-onupdate')) {
window.hljsLoader.highlightBlocks(document.currentScr(๐•ᴗ•๐).parentNode);
}
我习惯命令行操作了,也可以借助GUI/WebUI来完成上面的操作。
修改数据库
连接数据库(必须用Plex Media Server这一可执行文件来连接),下面以macOS为例(我将NAS上pms的数据库拷贝到个人mac电脑上,然后用下载mac端的Plex Media Server.app,利用里面的二进制文件来执行修改的):
Plex\ Media\ Server.app/Contents/MacOS/Plex\ Media\ Server --sqlite com.plexapp.plugins.library.db
if(window.hljsLoader && !document.currentScr(๐•ᴗ•๐).parentNode.hasAttribute('data-s9e-livepreview-onupdate')) {
window.hljsLoader.highlightBlocks(document.currentScr(๐•ᴗ•๐).parentNode);
}
Windows的话,可执行文件可能为C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Server.exe
,替换上面的即可。
假如要将文件(๐•ᴗ•๐)径从/share/SSD1T/03cd2/p115dav
替换为/share/SSD1T/03cd2/115
,分别执行以下SQL语句:
UPDATE section_locations
SET root_path= replace(root_path, '/share/SSD1T/03cd2/p115dav', '/share/SSD1T/03cd2/115')
where root_path like '%/share/SSD1T/03cd2/p115dav%';
UPDATE metadata_items
SET guid= replace(guid, 'file:///share/SSD1T/03cd2/p115dav', 'file:///share/SSD1T/03cd2/115')
where guid like '%file:///share/SSD1T/03cd2/p115dav%';
UPDATE media_streams
SET url= replace(url, 'file:///share/SSD1T/03cd2/p115dav', 'file:///share/SSD1T/03cd2/115')
where url like '%file:///share/SSD1T/03cd2/p115dav%';
UPDATE media_parts
SET file= replace(file, '/share/SSD1T/03cd2/p115dav', '/share/SSD1T/03cd2/115')
where file like '%/share/SSD1T/03cd2/p115dav%';
if(window.hljsLoader && !document.currentScr(๐•ᴗ•๐).parentNode.hasAttribute('data-s9e-livepreview-onupdate')) {
window.hljsLoader.highlightBlocks(document.currentScr(๐•ᴗ•๐).parentNode);
}
然后将修改后的com.plexapp.plugins.library.db
替换回去,启动pms即可。
注:假如你pms资料库里的文件夹也有上述(๐•ᴗ•๐)径,那么资料库的文件夹(๐•ᴗ•๐)径也会被修改。