zSeriesGuy / Tautulli

A Python based monitoring and tracking tool for Plex Media Server.
http://tautulli.com
GNU General Public License v3.0
27 stars 9 forks source link

Help with getting kill_stream.py to work #40

Closed ExDominatus closed 3 years ago

ExDominatus commented 3 years ago

This is most likely user error, but I can't seem to figure out how to get kill_stream.py to work with this branch of Tautulli. Is there something else I need to specify like the server I'm trying to kill, or can I just use kill_stream.py normally?

Version: V4.1.02

Branch: master

Operating system: Linux (Debian 10)

Python version: Python 3.7.3

Installation Steps I followed:

1) Download kill_stream.py python3 version from official JBOPS. (Also tried the one linked in here: https://github.com/zSeriesGuy/Tautulli/issues/27). 2) Ensure user permissions and ownership for script is correct. 3) Add script under notification agent. 4) Argument Used for "Playback Start"

--jbop stream --username {username} --sessionId {session_id} --killMessage '4K transcoding test.'

Screenshots of other config settings:

ScriptTriggers ScriptConditions

Am I missing some sort of {server} condition that this fork needs?

Result:

Stream that is 4K transcoding doesn't get killed.

Logs

  Tautulli Notifiers :: Trying to run notify script, action: change, arguments: ['--jbop', 'stream', '--username', 'CoreyRando', '--sessionId', 'qus90z1s9ije6x579yu2x5cf', '--killMessage', '4K transcoding test']

  Tautulli Notifiers :: Full script is: ['python', '/home/kore/apps/scripts/kill_stream.py', '--jbop', 'stream', '--username', 'CoreyRando', '--sessionId', 'qus90z1s9ije6x579yu2x5cf', '--killMessage', '4K transcoding test']

  Tautulli Notifiers :: Executing script in a new thread.

  Uncaught exception: Traceback (most recent call last):
  File "/home/kore/apps/Tautulli/plexpy/logger.py", line 341, in new_run
      old_run(*args, **kwargs)
  File "/usr/lib/python3.7/threading.py", line 865, in run
      self._target(*self._args, **self._kwargs)
  File "/home/kore/apps/Tautulli/plexpy/notifiers.py", line 3049, in run_script
      'PLEX_TOKEN': plexpy.CONFIG.PMS_TOKEN,
  File "/home/kore/apps/Tautulli/plexpy/config.py", line 746, in __getattr__
      return self.check_setting(name)
  File "/home/kore/apps/Tautulli/plexpy/config.py", line 698, in check_setting
      key, definition_type, section, ini_key, default = self._define(key)
  File "/home/kore/apps/Tautulli/plexpy/config.py", line 681, in _define
      definition = self._CONFIG_DEFINITIONS[key]
KeyError: 'PMS_TOKEN'

I noticed this: 'python', '/home/kore/apps/scripts/kill_stream.py, and was wondering if the issue was that the script wasn't getting executed with python3? How can I change this?

zSeriesGuy commented 3 years ago

I think what the problem is is that notifiers.py line 3049 needs to be deleted. PMS_TOKEN is no longer in the config.ini file. I can see how that would throw a keyerror. I think I removed PMS_TOKEN from config.ini when I implemented the multi-account support. I guess I missed this.

Try deleting that line and let me know if that resolves it for you. If so, I'll push an update.

Save a copy of the original notifiers.py code though so that the update from github won't fail after I push the update. I will try to recreate this issue also if you would rather not mess with the code.

zSeriesGuy commented 3 years ago

Hold off on making the change to the code. I have recreated the issue. Turned out to be easy to recreate. :) I'll be pushing code shortly.

zSeriesGuy commented 3 years ago

I pushed the update. Let me know if it works for you.

ExDominatus commented 3 years ago

Thank you for the update. It still seems to fail with the following error:

Tautulli Notifiers :: Script error:
        File "/usr/lib/python3.7/site.py", line 183
            file=sys.stderr)
                    ^
    SyntaxError: invalid syntax
zSeriesGuy commented 3 years ago

From research, I think this has to do with when you have multiple versions of Python installed. The script is probably being invoked with the wrong version of python. I updated the release. Run the update again and see if that fixes it.

ExDominatus commented 3 years ago
Tautulli Notifiers :: Failed to run script: [Errno 2] No such file or directory: 'python': 'python'
--

Hmm, how can I make sure the script is being invoked with the right version of python?

My default version of python seems to be Python 2.7.16 at /usr/bin/python while I want to be using /usr/bin/python3 which is Python 3.7.3.

For reference, I am using this this kill_stream.py from the python3 branch: https://github.com/blacktwin/JBOPS/blob/python3/killstream/kill_stream.py. If I should be using something else, let me know.

zSeriesGuy commented 3 years ago

Look in your Tautulli VENV/bin directory and see if there is a python module. If not and only a python3 module, then add python3 to the beginning of your notifier arguments before the --JBOPS.

ExDominatus commented 3 years ago

Both python and python3 exist in my Tautulli's bin directory. I still tried to put python3 in front of the --JBOPS argument just in case to no effect.

zSeriesGuy commented 3 years ago

Please paste in the messages you got when it failed.

ExDominatus commented 3 years ago

Apologies, same exact error just with the the new python3 argument included.

Tautulli Notifiers :: Trying to run notify script, action: change, arguments: ['python3', '--jbop', 'stream', '--username', 'SomeUser', '--sessionId', 'qus90z1s9ije6x579yu2x5cf', '--killMessage', '4K transcoding test']

Tautulli Notifiers :: Full script is: ['python3', '/home/ExD/apps/scripts/kill_stream.py', '--jbop', 'stream', '--username', 'SomeUser', '--sessionId', 'qus90z1s9ije6x579yu2x5cf', '--killMessage', '4K transcoding test']

Tautulli Notifiers :: Failed to run script: [Errno 2] No such file or directory: 'python3': 'python3'
zSeriesGuy commented 3 years ago

I have recreated the problem. Turns out this works fine on Windows. But on Ubuntu, I get the same error you are. I'll see what I can do to fix it.

zSeriesGuy commented 3 years ago

Dohh...Senior moment. :( Path separator difference between Windows and Linux. Do the update again. I pushed a change.

ExDominatus commented 3 years ago

Just tested, it works!!