JBOPS - Just a Bunch Of Plex Scripts

I stream all of the time outside of my network. I have several family members that use my plex.

I figured out a buch of the errors… I needed to update the ips_to_maps.py with my internet facing IP (to substitute for the local IP).

It is not exactly clear what the output of this program is? Where does it put the output, how does it name it, how do you integrate it?

headless did the trick… I see the PNG file in the directory. I assume it is up to me to put this into an HTMP or whatever…

Here is the errors I am getting now

Tautulli API ‘get_geoip_lookup’ request failed: expected string or buffer.Successfully retrieved geolocation data.Successfully retrieved geolocation data.Successfully retrieved geolocation data.Successfully retrieved geolocation data.Successfully retrieved geolocation data.Successfully retrieved geolocation data.Successfully retrieved geolocation data.Successfully retrieved geolocation data.Successfully retrieved geolocation data.Successfully retrieved geolocation data.Successfully retrieved geolocation data.Successfully retrieved geolocation data.Successfully retrieved geolocation data.Successfully retrieved geolocation data.Successfully retrieved geolocation data.User: jwaltrip4 IP: 63.123.140.115 caused error in geo_dict.
Successfully retrieved geolocation data.Successfully retrieved geolocation data.Successfully retrieved geolocation data.Successfully retrieved geolocation data.Successfully retrieved geolocation data.Successfully retrieved geolocation data.Successfully retrieved geolocation data.Traceback (most recent call last):
File “ips_to_maps.py”, line 449, in
draw_map(opts.map, geo_json, filename, opts.headless, opts.legend)
File “ips_to_maps.py”, line 263, in draw_map
plt.figure(figsize=(16, 9), dpi=100, frameon=False)
File “/home/jwaltrip/.local/lib/python2.7/site-packages/matplotlib/pyplot.py”, line 533, in figure
**kwargs)
File “/home/jwaltrip/.local/lib/python2.7/site-packages/matplotlib/backend_bases.py”, line 161, in new_figure_manager
return cls.new_figure_manager_given_figure(num, fig)
File “/home/jwaltrip/.local/lib/python2.7/site-packages/matplotlib/backends/_backend_tk.py”, line 1046, in new_figure_manager_given_figure
window = Tk.Tk(className=“matplotlib”)
File “/usr/lib/python2.7/lib-tk/Tkinter.py”, line 1828, in init
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable

found more info…

dumb questions… Is the assumption that this will be run from a graphical display?

OK… tryoh t fee a list f users at the command line…

please can you lost en example… ?

it says “Space separated list of case sensitive names to process”

so I have "–users steveb Jon.Waltrip etc… and it sasy invalid choice

Yes - which is why it should work using --headless
Much like Plex and Tautulli which tries to open a browser on the server when run.
In server terms, headless means no monitor/graphics output.
When you don’t run in --headless mode, it tries to open the PNG file it creates in a graphic app.

If you are still getting the error in headless mode, see next.

Add the two lines/Edit ip_to_maps.py appropriately as shown in this below link.

You must have exact case sensitivity - if you run ip_to_maps.py --help, it will even show you that list of acceptable usernames.
For instance, this example has one with a capital U, one with lower case. It matters.
>python ips_to_maps.py --users User1 user2 --filename test --headless

1 Like

@jwaltrip4 - Forget what I said about editing the script for that TcLError - in looking at the py script regarding something else, I find that --headless already does that exact same instruction set at around line ~265 (I estimate because I’ve added several lines since earlier in the code)

Ok. I need tonlook at where i am putting the --user switch… I followed the example and got an error

@blacktwin - I’ve spent more time again with the code, and just can’t figure out how to do it.
Your example images seem to show the ‘map’ image on the white background much larger, almost to the edges of the white pyplot ‘figure’.
How does one edit the script to get larger map images and less white frame?

@Blacktwin I was wondering if I could follow up with you on a couple of items as it has been a while since I updated your scripts which work but was wondering if any of these items are addressed to warrant updating:

  1. I was wondering if the issue with large legend for the maps script has been addressed? If I recall, you should have a PM from me on that from last year.

  2. Is there a way to limit the most popular TV Shows so that it does not generate every single episode for every single season of a popular show? List ends up being hundreds of episodes and hundreds of hours long. Perhaps limiting to at least the latest season of a popular show may make the playlist more reasonably sized.

Thanks in advance.

I think it’s here. More information can be found here. Matplotlib has all the answers in regards to how the image creation works and the customization of that image.

  1. I’ve added your suggestions here. Tracking additional feature requests and updates here.

  2. I have this suggestion in my project queue as well.

Keep them coming.

Sounds good. Thanks much!

I’ve tried figure size, and all it does is adjust the white frame size. The map drawn on it always seems to have the same border ratio.
Seems I just don’t understand the parameters enough even when reading the options. I’ve tried aspect and a few other, with no change or sometimes errors

Does your delete_watched_TV.py script work with shared users or just local users? Currently using Plex Cleaner, but it doesn’t appear to be supported any longer. Wish this functionality would be built into Plex.

Any shared user, remote or home.

Great! I will test this script. Couple of questions. Is there a flag to run this as a test only w/o deleting anything? Is there a log output to show what has been deleted? Any documentation for this script? It appears I would need to run multiple copies of this script for various show/user combinations.

Its a very basic script.

Is there a flag to run this as a test only w/o deleting anything?

If you want to dry run it (no deletion) just comment out the last line

#os.remove(meta_dict['file'])

Is there a log output to show what has been deleted?

No just what appears in the terminal.

It appears I would need to run multiple copies of this script for various show/user combinations.

If that is what you want to do.

I’d like to combine all the deletion scripts into one and create a kind of managing watched script. Where you can delete, move, archive, do whatever after something has been watched.

Thanks for the information. Will play around with it.

@Blacktwin Well, quickly realized I won’t be able to use this. Tautulli runs offsite from my Plex server, so it isn’t able to delete the files as it isn’t local. Running the script on the Plex server doesn’t work either as it’s not able to run the imports in the script.

Yeah, as written, script/tautulli need to be on same box as PMS.

@Blacktwin - Does Tautulli have an API feature to delete a Plex item using the Plex API command?
If so, might be a decent feature request - would allow for remote delete script alongside tautulli.

if not Tautulli the plexapi python library can.