JBOPS - Just a Bunch Of Plex Scripts

Love these scripts. Thanks for taking the time to develop them :slight_smile:

During some initial testing I am having an issue with the killstream script. On the first attempt to play a particular show I want to block playback for it does kill the stream based on the conditions I specified. However, if the user acknowledges the alert too quickly and attempts to play the file again the script fails to trigger. If I wait a few seconds and try again it kills the stream as expected.

I set the script timeout to 0 from 30 and this doesn’t seem to fix it. Any ideas? My TV and movie libraries are available in a learning environment and there’s a couple shows I want to block playback on.

Conditions are a set IP address and the Show Name.

1 Like

@liammiller - I’m not certain this would be a jbops/killstream script error, but perhaps more a Tautulli or even Plex one.
You should be able to determine if it’s JBOPS issue though If you look in tautulli logs, does it indicate the script is being executed on that second quick play?
If not, then it may be timing of Tautulli, or worse, Plex API/webhook not telling Tuatulli a different session is playing.

To piggy back on @JamminR reply. I follow Tautulli’s Asking for Support guidlines. Please provide your Tautulli logs so we can see what’s happening.

Also if you want to block certain shows/Movies from a user, the kill script is not the best tool to accomplish this. Create a label and use Plex’s restriction to hide the content from the user.

1 Like

@JamminR and @Blacktwin

Thanks so much. I’ll run a test and check out plex restrictions. Was just testing the script in this case :slight_smile:

Cheers!

@liammiller (or? @oasis-Guest)
I randomly happened across this FAQ question at Tautulli FAQs while looking for other information.
MIGHT be affecting yours.
Question doesn’t seem related, but the answer sure does.

Why don’t my lights turn on when I stop playback?

I’m trying to get the sync_watch_status.py script to work with --ratingKey. I have had success using the script without ratingKey which works to sync the whole library but I would like it to work per file.

This is the error code. What I don’t get is why it decides to add the ratingKey to the end of the port number

Also where should the config.ini file be placed if the scripts/tautulli/requirements are installed in a docker?

python sync_watch_status.py --userFrom "user1"=server1 --userTo user2=server1 --ratingKey 197245
Connecting to admin server(s) for access info...
Request manually triggered to update watch status
Connecting user1 to server1...
Traceback (most recent call last):
  File "/config/scripts/sync_watch_status.py", line 543, in <module>
    watched_item = watchedFrom.fetchItem(opts.ratingKey)
  File "/usr/lib/python2.7/site-packages/plexapi/base.py", line 137, in fetchItem
    for elem in self._server.query(ekey):
  File "/usr/lib/python2.7/site-packages/plexapi/server.py", line 376, in query
    response = method(url, headers=headers, timeout=timeout, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 546, in get
    return self.request('GET', url, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 519, in request
    prep = self.prepare_request(req)
  File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 462, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/usr/lib/python2.7/site-packages/requests/models.py", line 313, in prepare
    self.prepare_url(url, params)
  File "/usr/lib/python2.7/site-packages/requests/models.py", line 381, in prepare_url
    raise InvalidURL(*e.args)
requests.exceptions.InvalidURL: Failed to parse: https://localhost:32400197245

I’ve identified the problem, thanks for reporting it. Looks like there are a couple areas that need to be corrected. I’ll reply back when I have a fix. Thanks again for reporting this.

I’m inexperienced with Python, but is there an easy way to modify your notify_delay script for when someone starts watching a stream? Or would you need an entirely new one?

In a practical sense and for testing, I’d like to be alerted 3 minutes after a user has started a stream, and only if it’s still playing, in an effort to stop too many notifications. Tautulli doesn’t seem to apply delays to triggers effectively in this regard, so it seems I may need a script.

I’ve not used the script, but, could you not use the Tautulli notification trigger ā€œstart playbackā€, not use the concurrent triggers, and set the script’s concurrent_total variable under ā€œedit these settingsā€ to 1?
You may also look at the Tautulli - Notification agents and news letters setting ā€œallow consecutive notificationsā€. If it’s enabled, uncheck it.

@bnevets27 Sorry I never got back to you after applying the fix. Should be good to go. I can’t remember if you were in the Tautulli discord with this issue as well. Please let me know if its working now.

Even if you apply a delay you’re just delaying the same amount of notifications. If a user is triggering 4 events that would result in a notification you’ll still get those 4 notifications just later.

Ok. You probably knew this might come from the response to my question in tautulli thread and new geoip now using plex.tv, i understand for one offs and easier development, but 10s of 100s of lookups from map script look like ddos to plex.
Is there any way to download the maxmind DB a few of us registered for tautulli and use for jbops map (and any other geoip scripts)?

Thank you for the nice scripts.

Hey @Blacktwin!

Not sure if you are aware Tautulli has been updated to support Python 3.
I use the Docker version so upon updating it automatically switched to Python 3.
I think this might have broken your kill_stream script (possibly others, but that is really the only one I use).

In the Tautulli logs I have this error:

Tautulli Notifiers :: Script error:
    Traceback (most recent call last):
        File "/config/scripts/kill_stream.py", line 575, in <module>
            opts = parser.parse_args()
        File "/app/lib/argparse.py", line 1725, in parse_args
            args, argv = self.parse_known_args(args, namespace)
        File "/app/lib/argparse.py", line 1754, in parse_known_args
            namespace, args = self._parse_known_args(args, namespace)
        File "/app/lib/argparse.py", line 1960, in _parse_known_args
            start_index = consume_optional(start_index)
        File "/app/lib/argparse.py", line 1900, in consume_optional
            take_action(action, args, option_string)
        File "/app/lib/argparse.py", line 1812, in take_action
            argument_values = self._get_values(action, argument_strings)
        File "/app/lib/argparse.py", line 2249, in _get_values
            value = self._get_value(action, arg_string)
        File "/app/lib/argparse.py", line 2278, in _get_value
            result = type_func(arg_string)
        File "/config/scripts/kill_stream.py", line 100, in arg_decoding
            return arg.decode(TAUTULLI_ENCODING).encode('UTF-8')
    AttributeError: 'str' object has no attribute 'decode'

I’m not familiar with Python at all, so was hoping you could update your script to work with the Python 3 upgrade for Tautulli?

I’m guessing that’s what those errors are coming from, though I could be wrong.

Let me know if there is anything I can provide to help figure out the errors.

-Shark2k

I had issues with Python 3 too. Found the solution on Blacktwins github (Thanks BTW Blacktwin)

2 Likes

Thanks for the heads up on that @BIFFTAZ!
I’ll check that link out.

-Shark2k

You’ve copied the github page where the script is not the script. Either download the zip of the entire repo or copy/paste the script into a .py file. Or download the raw version of the page.

The main readme.md highlights the python libraries that are regularly used in most of the scripts in the repo. pip install requests

Fantastic, thanks. I hadn’t the need to tinker with python for a while, forgive the naivity :slight_smile:

All good, it’s working now.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.