Direct download link

I find it greatly annoying and almost impossible to automate the update of PMS due to lack of direct download links. Unless I am missing something?

Currently there is a JS download link requires a proper browser and opening the “link” in new tab to get a proper download link.

Why not have https://downloads.plex.tv/plex-media-server/latest_amd64_deb/ 302 to plexmediaserverXXXXXXX_amd64.deb?
Or similar fashion that one could use with a simple bash script?

Not everyone runs PMS on their desktop machine, and I believe this oversight with links is due to Windows users expecting to have GUI on their “servers”.

The link you show is a directory reference, not a discrete file URL. If you used the direct file URL, you would get the results you appear to expect which works well with wget

The downloads page is structured and written for interactive selection and download due to the existence of Public & Beta package availability which requires the user select the version as latest public != latest beta. It has nothing to do with Windows. It is OS agnostic.

To somewhat answer my own question the following will get a real download link that could be used with wget/curl:
curl -s "https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=ubuntu" | grep -Po '(?<=url=\")(\S+)(?=\")'

I believe ChuckPA completely misunderstood my question.

To clarify, one needs a non JS generated link that they could put in a cron job to automate update of the plex media server on their headless server (as in no GUI/screen).

As bonus here is how to get version of the “latest” download:
curl -s "https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=ubuntu" | grep -Po '(?<=(\" version=\"))(\S+)(?=(\"))'

Regarding the comment about URL to a directory vs URL to file, URL is URL, and from webserver/webapplication point of view it does not make any difference. Here is a quick example I made: https://sergei.nz/directory/ will 302 redirect to https://sergei.nz/file .

You could fully automate this by using Mr. Worf’s Plex Update Script on cron:

@“frederick.grayson” said:
You could fully automate this by using Mr. Worf’s Plex Update Script on cron:

GitHub - mrworf/plexupdate: Plex Update script to simplify the life of Linux Plex Media Server users.

I looked at that, but it has 500 something lines of bash, for something that should take at most 10. I would rather write my own.

Knock yourself out :slight_smile:

Then post your 10 lines.

1 Like

@SergeiFranco Why don’t you just use the official repository [1]? Btw: Unattended updates are not really the Linux / server way.

[1] https://support.plex.tv/hc/en-us/articles/235974187-Enable-repository-updating-for-supported-Linux-server-distributions

1 Like

@uglymagoo said:
@SergeiFranco Why don’t you just use the official repository [1]? Btw: Unattended updates are not really the Linux / server way.

[1] https://support.plex.tv/hc/en-us/articles/235974187-Enable-repository-updating-for-supported-Linux-server-distributions

Awesome, didn’t realize there was one.

I’ve done this script based on information I could find around, it does the job :slight_smile:

#!/bin/bash

#####
#
# This Script will update Plex Media Server to the latest version for Ubuntu
#
# To automatically check & update plex, run "crontab -e" and add the following lines
#
# # Check for Plex Media Server Updates every day @6:00 am
# 0 6 * * * /root/update-plexmediaserver.sh
#
#  2018 - Matthieu Guerry
#
###

# Check Current installed version and exit if latest is already installed
VersionInstalled=$(dpkg -s plexmediaserver | grep -Po '(?<=Version\: )(\S+)')
VersionAvailable=$(curl -s "https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=ubuntu" | grep -Po '(?<=(\" version=\"))(\S+)(?=(\"))')
if [ $VersionAvailable = $VersionInstalled ]; then echo "Plex Media Server is already up-to-date (version $VersionInstalled)"; exit; fi

# Download latest installation package to /tmp folder
curl -s "https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=ubuntu" | grep -Po '(?<=url=\")(\S+)(?=\")' | xargs wget -P /tmp/

# Stop Plex Service
sudo service plexmediaserver stop

# Install latest version
sudo dpkg -i /tmp/$(curl -s "https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=ubuntu" | grep -Po '(?<=fileName=\")(\S+)(?=\")')

# Start Plex Service
sudo service plexmediaserver start

# Remove installation package from /tmp folder
rm /tmp/plexmediaserver_*
3 Likes

Here is mine for FreeBSD, it’s probably not very optimzed, but it works

#!/usr/bin/env bash

installed=$(cat $HOME/bin/version.txt) #you need to fill this file with your version first
version=$(w3m -dump https://plex.tv/downloads/details/1?build=freebsd-x86_64&channel=16&distro=freebsd | awk ‘/Release id/ {print $3}’ | cut -d “”" -f 2) #backslash before 2nd double cote doesn’t appear
arch=“freebsd-amd64”
plex_tmp=“PlexMediaServer-${version}”
plex_dir=“plexmediaserver”
plex_dir_old=“plexmediaserver_old”
plex_path="/usr/local/share"

if [ ${installed} == ${version} ]
then
echo “installed : $installed”
echo “current : $version”
echo “No update available”
else
echo “installed : $installed”
echo “current : $version”
echo “Update available, do you want to update ? (Y/n)”
read answer
if [ ${answer} == “n” ] ; then
exit 0
else
echo ${version} > $HOME/bin/version.txt
wget https://downloads.plex.tv/plex-media-server/${version}/PlexMediaServer-${version}-${arch}.tar.bz2
archive=“PlexMediaServer-${version}-${arch}.tar.bz2”
tar -xvf ${archive} > /dev/null 2>&1
rm PlexMediaServer-${version}-${arch}.tar.bz2

mv ${plex_tmp} ${plex_dir}
cd ${plex_dir}
ln -s “Plex Media Server” Plex_Media_Server

cd ${plex_path}
if [ -d ${plex_dir_old} ] ; then
sudo rm -rf ${plex_dir_old}
sudo mv ${plex_dir} ${plex_dir_old}
sudo mv $HOME/${plex_dir} ${plex_path}/
sudo service plexmediaserver restart
else
sudo mv ${plex_dir} ${plex_dir_old}
sudo mv $HOME/${plex_dir} ${plex_path}/
sudo service plexmediaserver restart
fi
fi
fi

Room21, This is great, I like this script. It’s easy to understand and does exactly what I was looking for. Honestly I would have been fine with just downloading the correct version and I can do the install myself but your script takes care of it. Thanks for sharing.

What is the url to get the 32bit deb? I’ve tried x86_32, i386, x86, and they didn’t work.

https://downloads.plex.tv/plex-media-server/1.13.9.5456-ecd600442/plexmediaserver_1.13.9.5456-ecd600442_i386.deb

I mean, in the scripts above, the curl command is run with this url: “https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=ubuntu

That will be used to get the download url for the amd64 deb, What is the equivalent for i386?

I dunno. You could always use Mr. Worf’s script instead. It will grab 32 bit debs.

Thank you, that helps. For reference, in mrworf’s script I found that the correct arch for 32bit deb is i686. If you want to obtain the correct deb based on your system’s architecture, uname -m is your friend:

curl -s "https://plex.tv/downloads/details/1?build=linux-ubuntu-$(uname -m)&channel=16&distro=ubuntu" | grep -Po '(?<=url=\")(\S+)(?=\")'

Will get the appropriate deb file for your system.

Is there some reason you aren’t using the package repository provided by Plex.tv? I used it when I was running Plex as deb packages, but I am now on docker.

I like this script, I use CentOS though, so I couldn’t use it as is, but I made my own changes.
I haven’t had the opportunity to see it work first hand but I believe it should work, if someone notices an error I appreciate the correction.

#!/bin/bash

#####
#
# This Script will update Plex Media Server to the latest version for CentOS
#
# To automatically check & update plex, run "crontab -e" and add the following lines
#
# # Check for Plex Media Server Updates every day @6:00 am
# 0 6 * * * /root/update-plexmediaserver.sh
#
#  2018 - Original by Matthieu Guerry - Modified by Arturo Vazquez
#
###

# Check Current installed version and exit if latest is already installed
VersionInstalled=$(rpm -q plexmediaserver | grep -Po '(?<=plexmediaserver-)(\S+)(?=\.x86_64)')
VersionAvailable=$(curl -s "https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=redhat" | grep -Po '(?<=(\" version=\"))(\S+)(?=(\"))')
if [ $VersionAvailable = $VersionInstalled ]; then echo "Plex Media Server is already up-to-date (version $VersionInstalled)"; exit; fi

# Download latest installation package to /tmp folder
curl -s "https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=redhat" | grep -Po '(?<=url=\")(\S+)(?=\")' | xargs wget -P /tmp/

# Stop Plex Service
systemctl stop plexmediaserver

# Install latest version
yum localinstall -y /tmp/$(curl -s "https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=16&distro=redhat" | grep -Po '(?<=fileName=\")(\S+)(?=\")')

# Start Plex Service
systemctl start plexmediaserver

# Remove installation package from /tmp folder
rm /tmp/plexmediaserver_*

Thank you very much for this script.
Your script is doing exactly what I used to do manually.