Plex: Difference between revisions

From Hurlster Wiki
Jump to navigation Jump to search
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
= Manually Edit Metadata =
Inspired by: https://forums.plex.tv/t/change-the-addedat-date/171646/8<br>
From Web interface:
# Select show
# Get Info
# View XML
# Search for /library/metadata/'''xxxxx'''
# cp /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db /tmp/
* Search by NAME
<pre>sqlite3 /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db
SELECT id,title,originally_available_at,added_at FROM metadata_items WHERE title LIKE 'Close%';
644|Close Rick-Counters of the Rick Kind|2014-04-07 00:00:00|2018-07-23 20:14:04
13962|Close Encounters of the Third Kind|1977-12-14 00:00:00|2021-06-24 09:32:04
13963|Close Encounters Of The Third Kind||2021-06-24 09:32:06
13964|Close Encounters Of The Third Kind (English Trailer 1)||2021-06-24 09:32:06</pre>
* Search by ID
<pre>sqlite3 /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db
SELECT id,title,originally_available_at,added_at FROM metadata_items WHERE id='xxxxx';
13963|Close Encounters Of The Third Kind||2021-06-24 09:32:06</pre>
* One Liner
<pre>
/usr/lib/plexmediaserver/Plex\ Media\ Server --sqlite /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db "UPDATE metadata_items SET added_at = datetime(originally_available_at, '+365 days') WHERE id = 'xxxxx';"
</pre>
=== Bash Script ===
Find $ID by clicking movie name, more, get info, View XML and look for <Video ratingKey="XXXXX"<br>
The ratingKey number is the $ID to use for the script.
*/usr/local/sbin/plexdatechanger.sh
#!/bin/bash
SQLITE=/usr/lib/plexmediaserver/Plex\ Media\ Server
DB=./com.plexapp.plugins.library.db
ID=$1
sudo cp /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/$DB /tmp/$DB
cd /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases
sudo "$SQLITE" --sqlite $DB "UPDATE metadata_items SET added_at = datetime(originally_available_at, '+365 days') WHERE id = $ID;"
/usr/local/sbin/plexdatechanger.sh XXXXX
= Plex DVR =
= Plex DVR =
Update DVR from command line<br>
Update DVR from command line<br>

Latest revision as of 15:45, 22 February 2022

Manually Edit Metadata

Inspired by: https://forums.plex.tv/t/change-the-addedat-date/171646/8
From Web interface:

  1. Select show
  2. Get Info
  3. View XML
  4. Search for /library/metadata/xxxxx
  5. cp /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db /tmp/
  • Search by NAME
sqlite3 /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db
SELECT id,title,originally_available_at,added_at FROM metadata_items WHERE title LIKE 'Close%';
644|Close Rick-Counters of the Rick Kind|2014-04-07 00:00:00|2018-07-23 20:14:04
13962|Close Encounters of the Third Kind|1977-12-14 00:00:00|2021-06-24 09:32:04
13963|Close Encounters Of The Third Kind||2021-06-24 09:32:06
13964|Close Encounters Of The Third Kind (English Trailer 1)||2021-06-24 09:32:06
  • Search by ID
sqlite3 /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db
SELECT id,title,originally_available_at,added_at FROM metadata_items WHERE id='xxxxx';
13963|Close Encounters Of The Third Kind||2021-06-24 09:32:06
  • One Liner
/usr/lib/plexmediaserver/Plex\ Media\ Server --sqlite /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db "UPDATE metadata_items SET added_at = datetime(originally_available_at, '+365 days') WHERE id = 'xxxxx';"

Bash Script

Find $ID by clicking movie name, more, get info, View XML and look for <Video ratingKey="XXXXX"
The ratingKey number is the $ID to use for the script.

  • /usr/local/sbin/plexdatechanger.sh
#!/bin/bash
SQLITE=/usr/lib/plexmediaserver/Plex\ Media\ Server
DB=./com.plexapp.plugins.library.db
ID=$1
sudo cp /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/$DB /tmp/$DB
cd /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases
sudo "$SQLITE" --sqlite $DB "UPDATE metadata_items SET added_at = datetime(originally_available_at, '+365 days') WHERE id = $ID;"
/usr/local/sbin/plexdatechanger.sh XXXXX

Plex DVR

Update DVR from command line
To find your Plex Update URL navigate to your plex server in chrome (eg, 192.168.1.1:32400/web/),
and open chrome developer tools (press F12). Once developer tools is open, press (Ctrl/Cmd)+Shift+P,
type "network" and press enter. Then, find and click the "Refresh Guide" link in Plex. Over in the
developer tools window/pane, the first request listed should start with "reloadGuide?". Right click
the line and go to copy -> Copy link address. Paste the result below as plexUpdateURL.

#!/bin/bash
plexUpdateURL='http://192.168.0.254:32400/livetv/dvrs/xx/reloadGuide?X-Plex-Product=Plex%20Web&X-Plex-Version=4.69.1&X-Plex-Client-Identifier=123456789&X-Plex-Platform=Chrome&X-Plex-Platform-Version=97.0&X-Plex-Sync-Version=2&X-Plex-Features=external-media%2Cindirect-media&X-Plex-Model=bundled&X-Plex-Device=Windows&X-Plex-Device-Name=Chrome&X-Plex-Device-Screen-Resolution=1491x1324%2C2560x1440&X-Plex-Language=en'
plexHostPort='192.168.0.254:32400'

curl --location --request POST "$plexUpdateURL" -H "authority: $plexHostPort" -H "content-length: 0" -H "pragma: no-cache" -H "cache-control: no-cache" -H "sec-ch-ua: 'Google Chrome';v='95', 'Chromium';v='95', ';Not A Brand';v='99'" -H "accept: text/plain, */*; q=0.01" -H "x-requested-with: XMLHttpRequest" -H "accept-language: en" -H "sec-ch-ua-mobile: ?0" -H "user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36" -H "sec-ch-ua-platform: 'macOS'" -H "origin: http://$plexHostPort" -H "sec-fetch-site: same-origin" -H "sec-fetch-mode: cors" -H "sec-fetch-dest: empty" -H "referer: http://$plexHostPort/web/index.html"

RasPlex

Installation on RaspberryPi 2 Get and install Rasbian Lite

https://downloads.raspberrypi.org/raspbian_lite_latest.torrent
  • Burn with Win32DiskImager

Prepare wireless network (/etc/wpa_supplicant/wpa_supplicant.conf)

network={
ssid="SSID"
psk="SSIDPASSWD"
}

Install updated tools

$ sudo wget -q -O - https://www.bunkus.org/gpg-pub-moritzbunkus.txt | sudo apt-key add -
$ sudo apt-get update && sudo apt-get upgrade -y
$ sudo nano /etc/apt/sources.list.d/bunkus.list

add these lines......

deb http://www.bunkus.org/debian/jessie/ ./
deb-src http://www.bunkus.org/debian/jessie/ ./

Then install plexmediaserver on raspberrypi 2

$ sudo wget https://dev2day.de/plex-latest
$ sudo dpkg -i plex-latest
$ sudo apt-get install mkvtoolnix libexpat1 libav-tools ntfs-3g samba samba-common exfat-utils -y
$ sudo wget -q -O - http://dev2day.de/pms/dev2day-pms.gpg.key | sudo apt-key add -
$ sudo su
# echo "deb http://dev2day.de/pms/ jessie main" >> /etc/apt/sources.list.d/pms.list
# apt-get update
# apt-get install plexmediaserver
  • left out ffmpeg

Mount external(USB/HDD) disk:

$ sudo nano /etc/fstab
/dev/sda1 /media/usbhdd1 ntfs-3g gid=pi,uid=pi,noatime 0 0
$ sudo mkdir -p /media/usbhdd1
$ sudo reboot
  • Option
Follow these simple steps to install PMS on your armv7 device running Debian or a deriviate :
# become root
sudo su
# add my public key
wget -O - https://dev2day.de/pms/dev2day-pms.gpg.key | apt-key add -
# add my PMS repo
echo "deb https://dev2day.de/pms/ jessie main" >> /etc/apt/sources.list.d/pms.list
# activate https
apt-get install apt-transport-https
# update the repos
apt-get update
# install PMS
apt-get install plexmediaserver-installer
For ARM64 please use the following steps:
# become root
sudo su
# add my public key
wget -O - https://dev2day.de/pms/dev2day-pms.gpg.key | apt-key add -
# add my PMS repo
echo "deb [arch=armhf] https://dev2day.de/pms/ jessie main" >> /etc/apt/sources.list.d/pms.list
# activate https
apt-get install apt-transport-https
#enable armhf support
dpkg --add-architecture armhf 
# update the repos
apt-get update
# install PMS
apt-get install plexmediaserver-installer:armhf

OpenPHT

  • Ubuntu 14.04 Trusty install
apt-get build-dep kodi
https://github.com/RasPlex/OpenPHT/releases
https://github.com/RasPlex/OpenPHT/releases/download/v1.6.2.123-e23a7eef/openpht_1.6.2.123-e23a7eef-trusty_amd64.deb
  • /etc/init.d/plexhometheater
#!/bin/sh

### BEGIN INIT INFO
# Provides:          plexhometheater
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts instance of Plex Home Theater
# Description:       starts instance of Plex Home Theater using start-stop-daemon and xinit
### END INIT INFO

############### EDIT ME ##################

# Read configuration variable file if it is present
[ -r /etc/default/plexhometheater ] && . /etc/default/plexhometheater

# path to xinit exec
DAEMON=/usr/bin/xinit

# startup args
DAEMON_OPTS="/usr/bin/openpht"

# script name
NAME=plexhometheater

# app name
DESC="Plex Home Theater"

# user
RUN_AS=root

# Path of the PID file
PID_FILE=/var/run/plexhometheater.pid

############### END EDIT ME ##################

test -x $DAEMON || exit 0

set -e

case "$1" in
  start)
        echo "Starting $DESC"
        start-stop-daemon --start -c $RUN_AS --background --pidfile $PID_FILE  --make-pidfile --exec $DAEMON -- $DAEMON_OPTS
        ;;
  stop)
        echo "Stopping $DESC"
        start-stop-daemon --stop --pidfile $PID_FILE
        ;;

  restart|force-reload)
        echo "Restarting $DESC"
        start-stop-daemon --stop --pidfile $PID_FILE
        sleep 5
        start-stop-daemon --start -c $RUN_AS --background --pidfile $PID_FILE  --make-pidfile --exec $DAEMON -- $DAEMON_OPTS
        ;;
  *)
        N=/etc/init.d/$NAME
        echo "Usage: $N {start|stop|restart|force-reload}" >&2
        exit 1
        ;;
esac

exit 0

OpenPHT Debian

Installation for Jessie/Sid

  • Enable all extras.ubuntu.com packages in sources.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 16126D3A3E5C1192
  • Add repos
apt-get install software-properties-common
add-apt-repository ppa:team-xbmc/ppa
apt-get update
  • Install key
gpg --keyserver pgp.mit.edu --recv-keys 0x860CDC13 && gpg --armor --export 0x860CDC13 | apt-key add -
  • Add /etc/sources.list.d/openpht.list
deb http://www.preining.info/debian/ openpht-sid main
deb-src http://www.preining.info/debian/ openpht-sid main
  • Install libssl
wget http://ftp.us.debian.org/debian/pool/main/o/openssl/libssl1.0.2_1.0.2h-1_i386.deb
dpkg -i libssl1.0.2_1.0.2h-1_i386.deb
apt-get update
apt-get install libjpeg62-dev openpht

OpenPHT Minimal (ION)

The following guide/information assume you have decent linux knowledge adn can create a bootable usb pen
Get the ubuntu minial iso from ubuntu, extract it to a usb pen. Use plex as your username in the setup
When the initial setup completes and you've logged in, run the following commands

sudo apt-get install software-properties-common pkg-config
sudo apt-add-repository ppa:plexapp/plexht
sudo apt-add-repository ppa:pulse-eight/libcec
  • Install plexmediaserver (if dual setup system)
wget https://downloads.plex.tv/plex-media-server/1.0.3.2461-35f0caa/plexmediaserver_1.0.3.2461-35f0caa_i386.deb
dpkg -i plexmediaserver_1.0.3.2461-35f0caa_i386.deb
  • Add /etc/sources.list.d/openpht.list
deb http://www.preining.info/debian/ openpht-sid main
deb-src http://www.preining.info/debian/ openpht-sid main
  • Install preining.info key
gpg --keyserver pgp.mit.edu --recv-keys 0x860CDC13 && gpg --armor --export 0x860CDC13 | apt-key add -
  • Update
apt-get update
  • Get libshair requirement
wget https://www.preining.info/debian/pool/main/s/shairplay/libshairplay0_0.9.0.20160527-1_i386.deb
dpkg -i libshairplay0_0.9.0.20160527-1_i386.deb
  • Install SSL
wget http://ftp.us.debian.org/debian/pool/main/o/openssl/libssl1.0.2_1.0.2h-1_i386.deb
dpkg -i libssl1.0.2_1.0.2h-1_i386.deb
  • Install deps
sudo apt-get install openpht xorg alsa-utils lirc libsdl1.2-dev libjpeg-dev liblzo2-dev libyajl-dev \
libmicrohttpd-dev libtinyxml-dev libglew-dev libavahi-client-dev libflac++-dev libsdl-image1.2-dev \
libboost-thread1.58-dev libva-dev libtiff5-dev libjpeg-turbo8-dev libjpeg62-dev -y
  • NVidia only install
wget http://us.download.nvidia.com/XFree86/Linux-x86/340.96/NVIDIA-Linux-x86-340.96.run
chmod 755 NVIDIA-Linux-x86-340.96.run
sudo ./NVIDIA-Linux-x86-340.96.run -a -q --opengl-headers -X --dkms

sudo nvidia-xconfig -s --no-logo --force-generate --output-xconfig=/etc/X11/xorg.conf

Set X to be accessed by everyone?

sudo dpkg-reconfigure x11-common

Setup OpenPHT to boot at startup by editing openpht

sudo nano /etc/init.d/openpht

Paste this:

#!/bin/sh

### BEGIN INIT INFO
# Provides:          openpht
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts instance of Plex Home Theater
# Description:       starts instance of Plex Home Theater using start-stop-daemon and xinit
### END INIT INFO

############### EDIT ME ##################

# Read configuration variable file if it is present
[ -r /etc/default/plexhometheater ] && . /etc/default/plexhometheater

# path to xinit exec
DAEMON=/usr/bin/xinit

# startup args
DAEMON_OPTS="/usr/bin/openpht"

# script name
NAME=openpht

# app name
DESC="Plex Home Theater"

# user
RUN_AS=root

# Path of the PID file
PID_FILE=/var/run/openpht.pid

############### END EDIT ME ##################

test -x $DAEMON || exit 0

set -e

case "$1" in
 start)
       echo "Starting $DESC"
       start-stop-daemon --start -c $RUN_AS --background --pidfile $PID_FILE  --make-pidfile --exec $DAEMON -- $DAEMON_OPTS
       ;;
 stop)
       echo "Stopping $DESC"
       start-stop-daemon --stop --pidfile $PID_FILE
       ;;

 restart|force-reload)
       echo "Restarting $DESC"
       start-stop-daemon --stop --pidfile $PID_FILE
       sleep 5
       start-stop-daemon --start -c $RUN_AS --background --pidfile $PID_FILE  --make-pidfile --exec $DAEMON -- $DAEMON_OPTS
       ;;
 *)
       N=/etc/init.d/$NAME
       echo "Usage: $N {start|stop|restart|force-reload}" >&2
       exit 1
       ;;
esac

exit 0
  • Make executable
update-rc.d openpht defaults

And finally run

sudo reboot