30 July 2016

Hide and Unhide Plex Media Servers Libraries

Plex media server is a famous media server, I use it at home to set local media server for myself and family.

However, to be able to hide some Libraries is not straightforward,  as it is not supported by the app itself, and there's a plugin that allows you to do so for 1 Library for free and pay for the others (It called Lock for Plex).

I used this extension and find out how it works, and I hacked it and be able to hide more than one Library.

How "Lock for Plex" work is by updating the database used by Plex.

It uses two bash files, one for lock and the other for unlock:


Plex Media Server/Plug-ins/Lock_for_Plex.bundle/Contents/Resources/lock_support/lock.sh

Plex Media Server/Plug-ins/Lock_for_Plex.bundle/Contents/Resources/lock_support/unlock.sh

Here's the content for myself after I've been modified on this file:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
cat lock.sh
#!/bin/bash


lockplex="UPDATE metadata_items SET metadata_type=20 WHERE library_section_id=2 and metadata_type=1; DELETE FROM library_sections WHERE id=2;"
lockplex2="UPDATE metadata_items SET metadata_type=4444 WHERE library_section_id=8 and metadata_type=4; DELETE FROM library_sections WHERE id=8;"

cd "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins/Lock_for_Plex.bundle/Contents/Resources/lock_support/"

./sqlite3 "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db" "$lockplex" 
./sqlite3 "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db" "$lockplex2" 

exit;
mhewedy@probook:~$ cat unlock.sh 
#!/bin/bash

unlockplex="UPDATE metadata_items SET metadata_type=1 WHERE library_section_id=2 and metadata_type=20; INSERT OR REPLACE INTO library_sections (id,name,section_type,language,agent,scanner,created_at,updated_at,scanned_at,user_fields,uuid) VALUES (2,'English Movies',1,'en','com.plexapp.agents.imdb','Plex Movie Scanner','2016-07-03 07:27:07','2016-07-03 08:35:21','2016-07-03 08:35:21','pr%3AenableCinemaTrailers=0&pr%3AincludeInGlobal=0','c07640f7-a137-4987-95ba-c3c5850383d3');"

unlockplex2="UPDATE metadata_items SET metadata_type=4 WHERE library_section_id=8 and metadata_type=4444; INSERT OR REPLACE INTO library_sections (id,name,section_type,language,agent,scanner,created_at,updated_at,scanned_at,user_fields,uuid) VALUES (8,'TV Shows',2,'en','com.plexapp.agents.thetvdb','Plex Movie Scanner','2016-07-07 03:45:33','2016-07-07 03:45:55','2016-07-13 21:03:02','pr%3AincludeInGlobal=0','0d670ea9-0da4-4639-8f52-2fcd64f3d8c8');"

cd "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins/Lock_for_Plex.bundle/Contents/Resources/lock_support/"

./sqlite3 "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db" "$unlockplex" 
./sqlite3 "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db" "$unlockplex2" 

exit;

One other way to achieve the same result is to have some other disk partition and mount it on-demond.


No comments: