JBOPS - Just a Bunch Of Plex Scripts

@klok said:
@JamminR @Blacktwin,
The attached diff will suppress the ‘Unverified HTTPS request is being made’ warnings from wait_kill_paused_notify.py.

(had to zip it or the forum software won’t allow attaching)

or you could have just pasted it in your comment :wink:

49a50,53
> from requests.packages.urllib3.exceptions import InsecureRequestWarning
> 
> requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
> 
66d69
< sess.verify = False

@Blacktwin
I tried; couldn’t get the code block to work.
Now I see I need to include triple backticks, while the editor only outputs one… how did you figure that one out?

@klok here.

I wondered if there were any scripts that could manipulate the EPG? I’ve a few things I’d like to inject into the EPG data after it’s processed but I wouldn’t have a clue where to start scripting such a thing! (I also don’t know if the DVR would pick up these changes in the EPG) - anyone done something like that already, or offer any pointers?

@Blacktwin i just revisted these scripts again after updating to Tautulli. I am seeing the following:
c:\JBOPS-master\maps>python ips_to_maps.py Tautulli API ‘get_users_tables’ request failed: HTTPSConnectionPool(host=‘10.0.100.136’, port=8181): Max retries exceeded with url: /api/v2?cmd=get_users (Caused by SSLError(SSLError(“bad handshake: Error([(‘SSL routines’, ‘tls_process_server_certificate’, ‘certificate verify failed’)],)”,),)).Tautulli API ‘get_users_tables’ request failed: HTTPSConnectionPool(host=‘10.0.100.136’, port=8181): Max retries exceeded with url: /api/v2?cmd=get_users_table&apikey (Caused by SSLError(SSLError(“bad handshake: Error([(‘SSL routines’, ‘tls_process_server_certificate’, ‘certificate verify failed’)],)”,),)).Traceback (most recent call last): File “ips_to_maps.py”, line 377, in user_lst = sorted(get_users_tables(‘friendly_name’, user_count)) TypeError: ‘NoneType’ object is not iterable

I am using https for Tautulli. How do I pass the script my cert? I did not see an option for that in the script itself. Thanks

@almontef What do you have for your TAUTULLI_URL? Assuming it’s

TAUTULLI_URL = 'https://10.0.100.136:8181/'

I do have that as my Tautulli_url do I need to change that? I will say if I disable https and change the Tautulli_url to http is works but I would love to keep https enabled and use this feature.

I do also have a separate question with the maps script. My legend is way too big and larger than my map. It appears I got a lot of omobile user activity with many different remote addresses as they move about. Even if I exclude users it stays as large just with non excluded client entries (appears to be even a limit of 25 enteries in the legend). Is there anyway short of excluding the legend to shorten its length? Thanks.

For the legend, right now, it’s all or none. There is an arg to disable the legend. Legend placement via argument is on the todo list I believe. I’m slowly going through all the scripts and updating or removing. If you want, could you share your map via PM? One to get an idea of how the legend is turning out and two, I like maps :wink:.

I don’t have a TV tuner (yet) so I don’t have a way to test.

@blacktwin - You likely keep up with the Tautulli updates, but, wanted to make sure you saw this in case it’s helpful as you revise/update old to new.

Particular changelogs for v2.1.15-beta that might be of interest.

Notifications:
New: Added PYTHONPATH to script environment variables so scripts can automatically import from Tautulli libraries.
Fix: Proper handling of unicode script arguments.
Fix: Incorrect TAUTULLI_URL environment variable if the HTTP host setting is changed.

So I use the watch_limit.py script and it works great. Although I was wondering if anyone knew if there was an easy way to receive an e-mail as the Plex server owner when a certain user has reached a certain amount of watches in a day?

Basically I’d like to get e-mailed if/when one of my users reaches their daily play/watch limit specified in the watch_limit.py script.

I have combined the limit scripts into one that will have a notification function similar to the kill_stream script. I’ll be adding a readme with examples on how to use the Conditions/Arguments/Parameters to accomplish the same functionality as the separate limit scripts, again similar to the kill_stream script.

1 Like

I can not run any of your scripts, I think the problem comes from myself tautulli, with plexapi and request, on qnap 4.3.4. all my attempts ends with errors, and do not start the scripts, I would like to understand if you could detach the operation and the full implementation of the scripts so that I can take advantage of your creations. I do not understand either the arguments must be edited for our use or just a copy paste. ex: --jbop allStreams --userId {user_id} --notify 1 --killMessage ‘Hey Bob, we need to talk!’
should we replace the user_id with the id of the person? it’s very vague for me the script handling and I’m not a coder, but I would like to integrate your scripts would it be a way to help me.
PS :
tautulli returns the following error Tautulli Notifiers: Trying to run notify script, action: play, arguments: [u ‘- jbop’, u’allStreams ‘, u’ - userId ‘, u’12839010’, u’- -notify ‘, u’1’, u ‘- killMessage’, ‘Hey Bob, we need to talk!’
I do not understand the ‘u’
as well as the Tautulli Notifiers error: Executing script in a new thread.
2018-08-07 19:18:55 ERROR Tautulli Notifiers :: Script error:
File “/ share / CACHEDEV1_DATA / Plex / Plex Scripts / Kills stream / kill_stream.py”, line 1
import requests
^
IndentationError: unexpected indent

which gives the failure of the scripts
thank you

@Blacktwin been out of commission for a while. Just PM’ed you my map. That darn legend makes it pretty hard to see the map. For now, I am using it without the legend.

@Blacktwin the aired_today_playlist.py is a nice little script. Unfortunately, Plex has a limitation where playlists created by the primary user cannot be seen by managed users in a plex home setup. The collections feature does not have this limitation, so I was wondering if this script could be repurposed into a new script that will do exactly the same thing but instead create a collection of what aired today instead of a playlist? That way, managed users can benefit from this goodness.

@almontef Playlists can be shared to other users. There are a couple ways to do it. One is with WebTools. The other way is through a script.

I’m currently working on updating the aired_today_playlist to include other types of playlist (most popular TV or Movie based on Tautulli watch data, popular music tracks based on what Plex’s agent decides, and the aired_today). This will include being able to share and remove playlist to and from any user.

Thanks much, I used that script you linked to. Those enhancements to the aired_today_playlist that you are working on sound perfect. I’ll be on the lookout for that update for sure.

@Blacktwin am I correct that the plexapi_delete_playlists delete all playlists for the primary users and not across all users (managed home users)? I would like to delete all playlists from all users if that is possible.

Is the plex_netflix_check.py script not working with instantwatcher any longer? Below is the execution of that script and the resulting errors:

C:\JBOPS-master\fun>python plex_netflix_check.py -l Movies -site Amazon Running check on The 'Burbs Traceback (most recent call last): File “plex_netflix_check.py”, line 227, in main() File “plex_netflix_check.py”, line 224, in main plex_library_search(opts.library[0], opts.site, opts.episodes, opts.search_limit) File “plex_netflix_check.py”, line 174, in plex_library_search if instantwatch_search(title.title, title.type, site, search_limit) > 0: File “plex_netflix_check.py”, line 68, in instantwatch_search r = requests.get(‘http://instantwatcher.com/a/search’.rstrip(’/’), params=payload) File “C:\Python27\lib\site-packages\requests\api.py”, line 72, in get return request(‘get’, url, params=params, **kwargs) File “C:\Python27\lib\site-packages\requests\api.py”, line 58, in request return session.request(method=method, url=url, **kwargs) File “C:\Python27\lib\site-packages\requests\sessions.py”, line 512, in request resp = self.send(prep, **send_kwargs) File “C:\Python27\lib\site-packages\requests\sessions.py”, line 644, in send history = [resp for resp in gen] if allow_redirects else [] File “C:\Python27\lib\site-packages\requests\sessions.py”, line 222, in resolve_redirects **adapter_kwargs File “C:\Python27\lib\site-packages\requests\sessions.py”, line 622, in send r = adapter.send(request, **kwargs) File “C:\Python27\lib\site-packages\requests\adapters.py”, line 511, in send raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host=‘instantwatcher.com’, port=443): Max retries exceeded with url: /a/search?q=the+%27burbs&content_type=1 (Caused by SSLError(SSLError(“bad handshake: Error([(‘SSL routines’, ‘tls_process_server_certificate’, ‘certificate verify failed’)],)”,),))