Hey, I just found out about the script. This is great. Been running into a problem though. I’m a programmer, but Python and the Plex Web API is new to me. Here’s what I got :
Plex Version: 1.0.2.2413
uname -a: Linux 4.2.0-42-generic #49~14.04.1-Ubuntu SMP Wed Jun 29 20:22:11 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
PlexHome Setup
Script is Running on Same Machine as Plex
I’ve been debugging the script and when it tries to check what users have watched a program I get HTTP 401: Unauthorized when executing this line: user_media_page = getURLX(Settings['Host'] + ":" + Settings['Port'] + '/library/metadata/' + media_id, token=home_user_tokens) in def checkUsersWatched(users, media_id, progressAsWatched):
When I step through – home_user_tokens does have a value.
I’ve attached sanitized versions of my config and log as well at the offending url and the headers that are set.
Its odd, the script does appear to have no problem authenticating with/for other request types including (presumably) the user switch request. I get useful output around the items that the script is instructed to keep by default.
@KoopmansHome That does seem strange. I haven’t tried the script with the new Plex DVR. Not sure if that has an effect on the library. Just a quick thing to check, but that user has access to the section right?
If so could you try testing using a different section if you have one?
@ngovil21 To be clear, this isn’t the Plex DVR. I’ve named the section DVR, but its just recordings from tvheadend that Plex sees as TV Shows.
I double checked the user, they are permitted to see all sections.
I’ll do some more testing with another section later.
One thing I noticed in my installation, that the URLs that are getting accessed in the Plex Web client sometimes have the X-Plex-* headers added to the query string. So the http://localhost:32400/library/metadata/17924 url that is failing for me in Plex-Cleaner works in the web client as http://localhost:32400/library/metadata/17924?X-Plex-Platform=Linux&... I’ll test that as well when I get the chance.
Can I start by saying how awesome this script has been. I’ve been using it, problem free, for about 10 months now. I found it fairly straight forward to edit the copy of the .conf file and have it go through the relevant sections, deleting TV shows in some while leaving them alone in others. Simple!
However, in the past week or 2 I’d noticed that stuff had stopped deleting. I have a task set on the PC to auto run the script each morning. I went in and manually ran the script to find a series of 401 UNAUTHORISED errors. I haven’t altered the script in any way, the same port is still in use and and I can’t see any logical reason why the script can no longer access the library. Any help would be greatly appreciated.
The log file just shows the below :-
INFO:root:----------------------------------------------------------------------------
INFO:root: Detected Settings
INFO:root:----------------------------------------------------------------------------
INFO:root:Host: http://127.0.0.1
INFO:root:Port: 32400
INFO:root:Section List Mode: User-defined
INFO:root:Operating on user-defined sections: 4,6,7,9
INFO:root:Failed to load Section 4. Skipping…
INFO:root:Failed to load Section 6. Skipping…
INFO:root:Failed to load Section 7. Skipping…
INFO:root:Failed to load Section 9. Skipping…
INFO:root:
INFO:root:----------------------------------------------------------------------------
INFO:root:----------------------------------------------------------------------------
INFO:root: Summary – Script Completed Successfully
INFO:root:----------------------------------------------------------------------------
INFO:root:
INFO:root: Total File Count 0
INFO:root: Kept Show Files 0
INFO:root: On Deck Files 0
INFO:root: Deleted Files 0
INFO:root: Moved Files 0
INFO:root: Copied Files 0
INFO:root: Flagged Files 0
INFO:root: Rescanned Sections
INFO:root:
INFO:root:----------------------------------------------------------------------------
INFO:root:----------------------------------------------------------------------------
I’ve been looking through anything that I even remotely understand and just can’t fathom the issue.
I am using Plex media Server version 2.8.1. I’m running it on a standard PC set up with Windows 8 Evolution (custom build). Other than the Plex server updates, the set up has been unchanged throughout. Default browser is the same, the port is the same. I haven’t altered the script in any way. The Plex sections are still as they were … there is nothing logical that has changed since I started using the script. The last time I altered it at all was October 2015 and it has run flawlessly since then. Am utterly perPLEXed!
I got a chance to poke around a little more. I turned on verbose and debugging in my plex logs. It seems to me that when the script looks to check each of the listed users to see if they have viewed the item, plex is opting to authenticate the user as guest.
There’s also a ton of “Python” devices listed in my server.
@KoopmansHome, That’s odd…I don’t have (and have never had) an entry for Python in my devices. Perhaps that’s relative to Roku or something specifically?
@KoopmansHome. I don’t know if this will help you or not but you never know…
For some reason, I am now required to have my username and password on the config file for it to work. I can only assume that it’s due to some update because I have never entered it previously. However, just gave that a try and the cleaner is now back doing it’s job.
@KoopmansHome Sorry for not responding earlier, I got busy with work. Is your user in your PlexHome a Shared User or a Managed User? I think I have only tested the functionality with Managed Users. Not sure if that makes a difference. The user doesn’t show up as guest in my logs, so that may be a problem.
@Barold13 Glad you were able to figure it out. Check my PM for suggestions on using a token for authentication if you want. Either way works.
@PureKiwi Do you have the correct username and password set or a working Token? One of those are required on newer versions of Plex Media Server.
I am using version 1.9.3. Had been using for a long time without any issue and then recently have run into the issue of not being able to get access. The problem is that I have put in my username and password and still get the error message:
Error getting token, trying without…
Detected Settings
Host: http://127.0.0.1
Port: 32400
Section List Mode: User-defined
Operating on user-defined sections: 1
Failed to load Section 1. Skipping…
That’s with my correct username and password in the hardcoded settings of the .py file I’m running. I’ve tried both my username and e-mail address. Any other ideas?
@facted said:
I am using version 1.9.3. Had been using for a long time without any issue and then recently have run into the issue of not being able to get access. The problem is that I have put in my username and password and still get the error message:
Error getting token, trying without…
Detected Settings
Host: http://127.0.0.1
Port: 32400
Section List Mode: User-defined
Operating on user-defined sections: 1
Failed to load Section 1. Skipping…
That’s with my correct username and password in the hardcoded settings of the .py file I’m running. I’ve tried both my username and e-mail address. Any other ideas?
Interesting that it stopped working, I am using that version and it still works with Plex, so not sure what could have changed. Try running the script with --test flag set and see if it prints out a Token in the output. It is preferred that you copy the Cleaner.conf.default file to Cleaner.conf, put your settings there and not edit the main script. This will make any updates easier.
@facted said:
I am using version 1.9.3. Had been using for a long time without any issue and then recently have run into the issue of not being able to get access. The problem is that I have put in my username and password and still get the error message:
Error getting token, trying without…
Detected Settings
Host: http://127.0.0.1
Port: 32400
Section List Mode: User-defined
Operating on user-defined sections: 1
Failed to load Section 1. Skipping…
That’s with my correct username and password in the hardcoded settings of the .py file I’m running. I’ve tried both my username and e-mail address. Any other ideas?
Same here, v1.93. Same get up, stopped working an undefined period of time ago. I suspect that this is related to the Plex auth, although I have added localhost to Plex > Settings > Network > List of IP addresses and networks that are allowed without auth, although this hasn’t helped. It does state that When the server is signed out and this value is set, only localhost and addresses on this list will be allowed.
Have tried with User/Pass, and also a validated token [printed from --test]. Mine fails on every section.
Absolutely gutted as this was the answer to so many of my problems, including the auth issue on pre 2011 LG TV’s (MediaLink does not have a user/pass method).
Has anyone thought about how the script translates these section headers? Perhaps it strips it from a string and the string has changed? I’m no code monkey so I will probably just skim over it, but I’ll have a look as I’m not lazy and I want to find the solution!
@CriticalPoint From what you are saying it looks like authorization still works, but perhaps the Library sections may have changed. Could you check the Library Section ID? You can find it by going to the section in Plex Web and looking at the number at the end of the URL. Then the numbers will go in the SectionList option divided by commas.
Is there anyway to run with more verbose logging? I’ve tried just about everything without success and would love to help find the problem. I tried with --test mode but it didn’t generate a token for me as far as I could tell. In the log file, the “token” field was left blank.
@facted Ya there is, try running with the argument --debug. If it doesn’t print a token, then there is some problem with your login or connection, the debug log may give more information on that.