jakewaldron / PlexEmail

This script aggregates all new TV, movie and music releases for the past configured time then optionally writes to your web directory and sends out an email.
206 stars 32 forks source link

App broken with Plex Media Server 1.1.3 #47

Closed crazybadger closed 7 years ago

crazybadger commented 8 years ago

I've added a post to the thread on the forums, but the more I look at this, the more I think the security changes in 1.1.3 (from 1.1.0 I think) have broken this as it doesn't log into to Plex.tv

sa2000a commented 8 years ago

The app needs to include a token on all requests to the server. Similar to what was expected of apps when Plex Home came along,

jakewaldron commented 7 years ago

I'll look into this later this week when I update my server to the latest. The only calls made with this app to plex.tv is the authentication call and the call to get the shared users info for emails. Outside of that, all data is retrieved from the db in the PMS installation and I don't see any mention of changes to the db in recent change logs.

What OS is your PMS running on?

crazybadger commented 7 years ago

I'm running PMS in a FreeBSD jail (on FreeNAS) and PlexEmail is running in a seperate jail with a mount point to the Plex Media Server folder on the PMS jail.

Seems too much of a coincidence that this broke just after I'd updated from 1.0.3 to 1.1.3.

Here's some lines from the log file:

2016-09-09 19:37:15,158 - INFO:Test flag found - setting script instance to test mode. 2016-09-09 19:37:15,211 - INFO:Setting Cloudinary config values 2016-09-09 19:37:15,212 - INFO:Including Plex Web Link - Getting machine identifier from the DLNA DB 2016-09-09 19:37:15,212 - INFO:DLNA_DB_FILE = /plexms/Plex Media Server/Plug-in Support/Databases/com.plexapp.dlna.db 2016-09-09 19:37:15,265 - ERROR:Logging an uncaught exception Traceback (most recent call last): File "/PlexEmail/scripts/plexEmail.py", line 903, in <module> cur.execute('SELECT machine_identifier FROM remote_servers WHERE url LIKE "http://127.0.0.1%";') OperationalError: unable to open database file

jakewaldron commented 7 years ago

Guessing you closed this by accident. I should have some free time on Sunday to upgrade my server (also FreeNAS) and see if I run into the same issue.

Could you verify that the user running the script still has read/write access to that db file and the folder it resides in? Maybe the upgrade modified the permissions.

crazybadger commented 7 years ago

Didn't even realised I had, and thanks!

That was the last thing I checked and all the permissions in the Plex Media Folder on plexms (my PMS jail) are -rw-r--r-- plex:plex. These showed through in PlexEmail as 972:972 as I didn't have a plex user with this UID, so I thought I'd create one to see if that made a difference, but it didn't. The UID for plex on plexms is 972, so I didn't think it would. Same error message generated in the logs.

Remember to snapshot your dataset before upgrading PMS if you want to rollback! I've still got one, although I'm still weighing up the options . Not happy with the way Plex keep forcing everything to be logged in to plex.tv, but they seem insistent as this isn't their first attempt, and I use PMS almost everyday so don't want to lag to far behind on updates. Not sure how easy it would be for PlexEmail to log in (it needs to obtain a token from what I've read). Would be great if it can, as I think it's a really useful app!

I also use PlexPy in another jail, and that's still working, but that already had the token from PMS. In a perfect world, the PlexEmail functionality would be in PlexPy, and the PlexPy functionality would be part of PMS :-D

Anyway, thanks again (and I try to click the right button this time!)

jakewaldron commented 7 years ago

So I just updated my server to 1.1.14 and I do not see this same issue. My setup is slightly different since my PlexEmail script runs inside the PMS jail. I am still thinking it is related to permissions since it can see the file but is having issues accessing it.

I think you will need to either make the 3rd portion of the permissions (other) to rw, use the plex user to run the script or make the 2nd portion of the permissions (plex group) to rw and add the user executing the script to that group.

crazybadger commented 7 years ago

Thanks for your update, and great to hear it's still working for you. I'd pretty much given up and assumed this was related to Plex security, but after your update decided to go back and check everything again.

When I went to change the permissions on the Databases folder (chmod 646) I found the problem - the mount point to the PMS jail was set as read only! Not sure how, but I suspect that must have been something I've checked at some point. Anyway, restarted the jail with the mount as writeable and the script ran without issue and e-mails were sent and received!

Thanks again, and I'll close it intentionally this time :-)