mstinaff / PMS_Updater

Shell script for updating the Plex Media Server inside the FreeNAS Plex plugin
MIT License
442 stars 90 forks source link

Token now needed to view latest releases on api #50

Closed zinc69 closed 1 year ago

zinc69 commented 4 years ago

Plex now requires the X-Plex-Token in the url to view plexpass releases

i had to change the URL to the following... https://plex.tv/api/downloads/5.json?channel=plexpass&X-Plex-Token=NOTREALTOKEN

To get your X-Plex-Token see the support site https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/

jbeez commented 4 years ago

Changes to support token auth were recently merged in, please test this out again.

fvct5 commented 4 years ago

I had to update the path in the script because I'm not using the FreeNAS plugin. I'm already on the latest plexpass version so I can't say if it works, but I'm getting these errors:

Using URL https://plex.tv/api/downloads/5.json
Searching https://plex.tv/api/downloads/5.json for the FreeBSD download URL .....Certificate verification failed for /C=US/ST=Arizona/L=Scottsdale/O=Starfield Technologies, Inc./CN=Starfield Services Root Certificate Authority - G2
34374374552:error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed:/usr/src/crypto/openssl/ssl/s3_clnt.c:1269:
fetch: https://plex.tv/api/downloads/5.json?channel=plexpass&X-Plex-Token=XXXXXXXXXXXX: Authentication error
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/share/plexmediaserver-plexpass/Resources/Python/lib/python2.7/json/__init__.py", line 291, in load
    **kw)
  File "/usr/local/share/plexmediaserver-plexpass/Resources/Python/lib/python2.7/json/__init__.py", line 339, in loads
    return _default_decoder.decode(s)
  File "/usr/local/share/plexmediaserver-plexpass/Resources/Python/lib/python2.7/json/decoder.py", line 364, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/share/plexmediaserver-plexpass/Resources/Python/lib/python2.7/json/decoder.py", line 382, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
Could not find a FreeBSD download link on page https://plex.tv/api/downloads/5.json?channel=plexpass&X-Plex-Token=XXXXXXXXXXXXX
fvct5 commented 4 years ago

Looks like adding the --no-verify-peer to the fetch command works per usual for the cert error above:

DOWNLOADURL="$(fetch -q --no-verify-peer $TOKENURL -o- | $PMSPARENTPATH/$PMSLIVEFOLDER/...

jbeez commented 4 years ago

I had to update the path in the script because I'm not using the FreeNAS plugin. I'm already on the latest plexpass version so I can't say if it works, but I'm getting these errors:

Using URL https://plex.tv/api/downloads/5.json
Searching https://plex.tv/api/downloads/5.json for the FreeBSD download URL .....Certificate verification failed for /C=US/ST=Arizona/L=Scottsdale/O=Starfield Technologies, Inc./CN=Starfield Services Root Certificate Authority - G2
34374374552:error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed:/usr/src/crypto/openssl/ssl/s3_clnt.c:1269:
fetch: https://plex.tv/api/downloads/5.json?channel=plexpass&X-Plex-Token=XXXXXXXXXXXX: Authentication error
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/share/plexmediaserver-plexpass/Resources/Python/lib/python2.7/json/__init__.py", line 291, in load
    **kw)
  File "/usr/local/share/plexmediaserver-plexpass/Resources/Python/lib/python2.7/json/__init__.py", line 339, in loads
    return _default_decoder.decode(s)
  File "/usr/local/share/plexmediaserver-plexpass/Resources/Python/lib/python2.7/json/decoder.py", line 364, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/share/plexmediaserver-plexpass/Resources/Python/lib/python2.7/json/decoder.py", line 382, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
Could not find a FreeBSD download link on page https://plex.tv/api/downloads/5.json?channel=plexpass&X-Plex-Token=XXXXXXXXXXXXX

I'm getting an amazon cert issuer for plex.tv when I connect. Maybe there was a transient hosting issue when you tested it?

Are you on a freenas install just in the main host, or a totally different system?

If a different system do you have a ca-root-nss.crt file?

fvct5 commented 4 years ago

User error. I did not have the ca_root_nss package installed. It's a new iocage jail in FreeNAS 11.3. It found a new update (assuming today's release) and successfully went through the update to a good end. Thank you for the hard work you put into this script.

RonRN18 commented 4 years ago

I apparently was unable to automatically capture the token. I ended up downloading the latest 1.18.5.2260 file, placing in the /tmp folder, then used ./PMS_Updater.sh -vv -l /tmp/PlexMediaServer-1.18.5.2260-056ab4be9-FreeBSD-amd64.tar.bz2. This worked, but the first line upon running this command was sed: /Plex Media Server/Preferences.xml: No such file or directory. I believe this may be related to the fact that I built this in a jail as opposed to using the FreeNAS plugin. I did a search for the XML file... it was located in /usr/local/plexdata-plexpass/Plex Media Server/. I changed line 9 to read: PLEXTOKEN="$(sed -n 's/.*PlexOnlineToken="//p' /usr/local/plexdata-plexpass/Plex\ Media\ Server/Preferences.xml | sed 's/\".*//')". I believe this did the trick, although I can't be for certain, as I had already updated by updating from a manually downloaded file.

jbeez commented 4 years ago

I apparently was unable to automatically capture the token. I ended up downloading the latest 1.18.5.2260 file, placing in the /tmp folder, then used ./PMS_Updater.sh -vv -l /tmp/PlexMediaServer-1.18.5.2260-056ab4be9-FreeBSD-amd64.tar.bz2. This worked, but the first line upon running this command was sed: /Plex Media Server/Preferences.xml: No such file or directory. I believe this may be related to the fact that I built this in a jail as opposed to using the FreeNAS plugin. I did a search for the XML file... it was located in /usr/local/plexdata-plexpass/Plex Media Server/. I changed line 9 to read: PLEXTOKEN="$(sed -n 's/.*PlexOnlineToken="//p' /usr/local/plexdata-plexpass/Plex\ Media\ Server/Preferences.xml | sed 's/\".*//')". I believe this did the trick, although I can't be for certain, as I had already updated by updating from a manually downloaded file.

I'd love to write a line that just auto finds your preferences file but there could be multiple files with that name, I know on my machine I have 3 copies, backups, testing, etc etc. The token value may differ. I did just alter my script a little and tested it, this seems to work.

LOGGING=1

default location for pms plugin, for manual jail install try

PREFS="/usr/local/plexdata-plexpass/Plex Media Server/Preferences.xml"

PREFS="/Plex Media Server/Preferences.xml"

PLEXTOKEN="$(sed -n 's/.PlexOnlineToken="//p' "${PREFS}" | sed 's/\".//')"

going to pop this into my copy on github. Can prob do an if statement too where if you define a command line argument or something like that it uses one or the other but this is probably sufficient. IDK about original author but IMO the jail plugin version should be default because those users are least likely to know how to modify this in my experience. And for anyone that's done a manual install in a plain jail changing the variable near the top should be easy enough.

Thanks!

neilmecham commented 4 years ago

I can confirm that this script works. I just upgraded from plexpass version 1.18.4.2171 to 1.18.6.2348 using the following line: .\PMS_Updater.sh -vv Thanks for all of your hard work on this script!

ChaosBlades commented 4 years ago

Not to sidetrack this thread but. What does -vv do? Very Verbose? Or is that a typo? Also seeing -v -l. Doesn't -vl work?

jbeez commented 4 years ago

Not to sidetrack this thread but. What does -vv do? Very Verbose? Or is that a typo? Also seeing -v -l. Doesn't -vl work?

I don't believe vv does anything at all. Looks like a typo to me.

A single v just sets the VERBOSE variable to 1, and functionally in the script this does two things. It just echos out which baseURL is being used for the software check, and it also removes the quiet flag from the fetch command so you see what fetch is doing when it goes to download the new update.

If you're using the -l for localfile switch, you're instructing the script to just use a local copy it doesn't need to download anything, and the verbose switch is involved with telling you more information around downloading the update, so this effectively means v isn't needed at all in this case really.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.