Plex/Plex Media Server

From Omnia
Revision as of 05:16, 1 September 2014 by Kenneth (talk | contribs) (→‎CentOS 6 Install)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Plex

Plex - Plex Media Server: Your Media on all of Your Devices - Plex.tv - http://plex.tv/

Plex Download - https://plex.tv/downloads

myPlex Account - https://my.plexapp.com/

Plex Media Center bridges the gap between your computer and your home theater, doing so with a visually appealing user interface that provides instant access to your media.

http://www.plexapp.com/ now redirects http://plex.tv/

CentOS 6 Install

Install package:

# 64bit install
wget http://downloads.plexapp.com/plex-media-server/0.9.9.16.555-50cd0c3/plexmediaserver-0.9.9.16.555-50cd0c3.x86_64.rpm
yum install plexmediaserver-0.9.9.16.555-50cd0c3.x86_64.rpm
# 32bit install
wget http://downloads.plexapp.com/plex-media-server/0.9.9.16.555-50cd0c3/plexmediaserver-0.9.9.16.555-50cd0c3.i386.rpm
yum install plexmediaserver-0.9.9.16.555-50cd0c3.i386.rpm

Reboot server:

reboot

Enable syslog logging: [1]

sed -i 's/# export PLEX_MEDIA_SERVER_USE_SYSLOG=true/export PLEX_MEDIA_SERVER_USE_SYSLOG=true/g' /etc/sysconfig/PlexMediaServer

Start service:

chkconfig plexmediaserver on
service plexmediaserver restart

Connect to server:

http://MYSERVER:32400/web
  • Accept End User License Agreement
  • Wait for Plex Server to fully start
  • Sign In with Plex Account (optional)
  • Name Server
  • Provide announcement email
  • Create Media Library (Movies)
    • /movies/plex
  • Install (or skip) channels

--

This adds the following yum repo, which appears to be broken:

/etc/yum.repos.d/plex.repo:

[PlexRepo]
name=PlexRepo
baseurl=http://plex.r.worldssl.net/PlexMediaServer/fedora-repo/release/$basearch/
enabled=1
gpgkey=https://plexapp.com/plex_pub_key.pub
gpgcheck=1

So to update, just download the latest RPM.

--

# mount movie share
mkdir /movies
echo "prime:/data/movies      /movies                 nfs     defaults        0 0" >> /etc/fstab
mount /movies

--

Apache

yum -y install apache php
ln -s /var/www/html /www
cd /www
cat > index.php << "EOF"
<?php
header('Location: http://plex:32400/web/');
EOF
chkconfig httpd on
service httpd restart

Ubuntu Install

Dependencies:

apt-get install avahi-utils

Install package:

# 64bit install
wget http://downloads.plexapp.com/plex-media-server/0.9.9.16.555-50cd0c3/plexmediaserver_0.9.9.16.555-50cd0c3_amd64.deb
dpkg -i plexmediaserver_0.9.9.16.555-50cd0c3_amd64.deb

Reboot server:

reboot

Enable syslog logging: [2]

echo "PLEX_MEDIA_SERVER_USE_SYSLOG=true" >> /etc/default/plexmediaserver

Start service:

chkconfig plexmediaserver on
service plexmediaserver restart

Connect to server:

http://MYSERVER:32400/web
  • Accept End User License Agreement
  • Wait for Plex Server to fully start
  • Sign In with Plex Account (optional)
  • Name Server
  • Provide announcement email
  • Create Media Library (Movies)
    • /movies/plex
  • Install (or skip) channels

--

This adds the following apt repo, ?which appears to be broken:?

/etc/apt/sources.list.d/plexmediaserver.list:

deb http://plex.r.worldssl.net/PlexMediaServer/ubuntu-repo lucid main

So to update, just download the latest DEB.

--

Preference File:

/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Preferences.xml 

Library:

/var/lib/plexmediaserver/Library

--

# mount movie share
mkdir /movies
echo "prime:/data/movies      /movies                 nfs     defaults        0 0" >> /etc/fstab
mount /movies

--

Apache

yum -y install apache php
ln -s /var/www/html /www
cd /www
cat > index.php << "EOF"
<?php
header('Location: http://plex:32400/web/');
EOF
chkconfig httpd on
service httpd restart

Plex.tv Connect

WARNING: To see the "Server" options, you need to connect to the Plex server from localhost or local network.

Firewall

What network ports do I need to allow through my firewall to enable access? [3]

TCP 32400 (for access to the Plex Media Server) [required]

UDP 1900 (for access to the Plex DLNA Server)

TCP 32469 (for access to the Plex DLNA Server)

UDP 5353 (for Bonjour/Avahi if you are using these products for service discovery) [recommended for iOS clients]

Web Interface

How do I access the Plex media management interface? [4]

http://YourServerIP:32400/web

Command Line Mangement

Get sections:

curl http://plex:32400/library/sections
  key="1"

Refresh section:

curl http://plex:32400/library/sections/1/refresh

Maybe something more convoluted: [5]

curl http://127.0.0.1:32400/library/sections%7Cgrep "title="| awk -F = '{print $6" "$7" "$8}'| \
   sed 's/ art//g'|sed 's/title//g'| sed 's/type//g'| awk -F \" '{print "Section=\""$6"\" ID="$2}'

References:

Refresh on startup hack

/etc/init.d/plexmediaserver
# diff -u plexmediaserver.original plexmediaserver
# patch -p0 < plexmediaserver.patch

plexmediaserver.patch:

--- plexmediaserver.original    2013-12-21 09:20:54.818961489 -0700
+++ plexmediaserver     2014-01-18 16:02:28.986902515 -0700
@@ -127,9 +127,22 @@
         fi
 }

+refresh_movies () {
+  for i in `seq 1 10`; do
+    echo "Refreshing movies ..."
+    curl http://plex:32400/library/sections/1/refresh
+    if [ $? -eq 0 ] ; then
+      return 0
+    fi
+    sleep 1
+  done
+}
+
 case "$1" in
        start)
                start
+               # refresh movies
+               refresh_movies
                ;;
        stop)
                stop
@@ -138,6 +151,8 @@
                stop
                 sleep 1
                start
+               # refresh movies
+               refresh_movies
                ;;
        status)
                check_status

Download Video

  1. http://plexapp.com
  2. select video
  3. Click "Info" icon
  4. Click "View XML" link
  5. Get <Part id="3486" key="/library/parts/3486/file.mkv"
    • Collect Title and Year for file name
  6. Swap file url with current url, and append X-Plex-Token

Subtitle

save the .srt file as "[movie].eng.srt"

Script

git clone https://gist.github.com/3183688e946a2c444efc.git

See plex.py

Issues

imuxsock begins to drop messages

imuxsock begins to drop messages from pid 21238 due to rate-limiting [6]

/etc/rsyslog.conf

$SystemLogRateLimitInterval 0
#$SystemLogRateLimitBurst 50
$SystemLogUsePIDFromSystem on

Test syslog rate limiting: [7]

n=1000
i=0

while [ $i -lt $n ]
do
logger "This is Testmessage #$i"
echo "Messages: $i"
i=`expr $i + 1`
done

keywords