From 41f1b147fc2bd84345e93bb4273ecd3d4bf4bfca Mon Sep 17 00:00:00 2001 From: Henric Andersson Date: Thu, 24 Apr 2014 01:20:34 -0700 Subject: [PATCH] Added support for non-plexpass It's now possible to use this tool to download the public version by supplying the -p option. Also renamed the tool to something more fitting. Signed-off-by: Henric Andersson --- plexpass_update.sh => plexupdate.sh | 43 ++++++++++++++++++----------- 1 file changed, 27 insertions(+), 16 deletions(-) rename plexpass_update.sh => plexupdate.sh (78%) diff --git a/plexpass_update.sh b/plexupdate.sh similarity index 78% rename from plexpass_update.sh rename to plexupdate.sh index 1eddc87..d78af92 100755 --- a/plexpass_update.sh +++ b/plexupdate.sh @@ -1,13 +1,15 @@ #!/bin/bash # -# PlexPass Linux Server download tool v2.3 -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -# This tool will login to the Plex homepage, locate the PlexPass -# Plex Media Server for Linux and download it. +# Plex Linux Server download tool v2.4 +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +# This tool will download the latest version of Plex Media +# Server for Linux. It supports both the public versions +# as well as the PlexPass versions. # -# Either modify this file to add email and password OR create -# a separate .plexupdate file in your home directory with these -# values. +# PlexPass users: +# Either modify this file to add email and password OR create +# a separate .plexupdate file in your home directory with these +# values. # # Returns 0 on success # 1 on error @@ -30,7 +32,7 @@ # resiliance to HTML changes and also better error handling # 2.3 Now reads an optional config file to avoid having to # modify this script. -# +# 2.4 Added support for the public versions of PMS ################################################################# # Set these two to what you need, or create a .plexupdate file @@ -51,27 +53,24 @@ fi # Current pages we need URL_LOGIN=https://plex.tv/users/sign_in URL_DOWNLOAD=https://plex.tv/downloads?channel=plexpass +URL_DOWNLOAD_PUBLIC=https://plex.tv/downloads # Defaults RELEASE="64-bit" KEEP=no FORCE=no - -# Sanity check -if [ "${EMAIL}" == "" -o "${PASS}" == "" ]; then - echo "Error: No email and/or password provided, please edit me." - exit 1 -fi +PUBLIC=no # Parse commandline set -- $(getopt fhko: -- "$@") while true; do case "$1" in - (-h) echo -e "Usage: $(basename $0) [-fhko]\n\nf = Force download even if it exists (WILL NOT OVERWRITE)\nh = This help\nk = Reuse last authentication\no = 32-bit version (default 64 bit)\n"; exit 0;; + (-h) echo -e "Usage: $(basename $0) [-fhkop]\n\nf = Force download even if it exists (WILL NOT OVERWRITE)\nh = This help\nk = Reuse last authentication\no = 32-bit version (default 64 bit)\np = Public Plex Media Server version"; exit 0;; (-f) FORCE=yes;; (-k) KEEP=yes;; (-o) RELEASE="32-bit";; + (-p) PUBLIC=yes;; (--) ;; (-*) echo "Error: unrecognized option $1" 1>&2; exit 1;; (*) break;; @@ -79,6 +78,13 @@ do shift done +# Sanity check +if [ "${EMAIL}" == "" -o "${PASS}" == "" ] && [ "${PUBLIC}" == "no" ]; then + echo "Error: Need username & password to download PlexPass version. Otherwise run with -p to download public version." + exit 1 +fi + + # Useful functions rawurlencode() { local string="${1}" @@ -114,7 +120,7 @@ keypair() { # commit Sign in # If user wants, we skip authentication, but only if previous auth exists -if [ "${KEEP}" != "yes" -o ! -f /tmp/kaka ]; then +if [ "${KEEP}" != "yes" -o ! -f /tmp/kaka ] && [ "${PUBLIC}" == "no" ]; then echo -n "Authenticating..." # Clean old session rm /tmp/kaka 2>/dev/null @@ -147,6 +153,11 @@ if [ "${KEEP}" != "yes" -o ! -f /tmp/kaka ]; then exit 1 fi echo "OK" +else + # It's a public version, so change URL and make doubly sure that cookies are empty + rm 2>/dev/null >/dev/null /tmp/kaka + touch /tmp/kaka + URL_DOWNLOAD=${URL_DOWNLOAD_PUBLIC} fi # Extract the URL for our release