blacktwin / JBOPS

Just a Bunch Of Plex Scripts
1.67k stars 307 forks source link

kill_stream.py not working on iOS/Apple TV #300

Closed stickyfin closed 3 years ago

stickyfin commented 3 years ago

kill_stream.py not working on iOS/Apple TV. The kill script is working from tautulli log, but user still able to play.

Tautulli logs:

2021-07-18 18:14:41 - DEBUG :: Thread-2 : Tautulli NotificationHandler :: Checking custom notification conditions for notifier_id 10. 2021-07-18 18:14:41 - DEBUG :: Thread-2 : Tautulli NotificationHandler :: {1} user | is | 'pop' > 'pop' > True 2021-07-18 18:14:41 - DEBUG :: Thread-2 : Tautulli NotificationHandler :: Condition logic [blank]: {1} > True 2021-07-18 18:14:41 - DEBUG :: Thread-2 : Tautulli NotificationHandler :: Custom conditions evaluated to 'True'. Conditions: [True]. 2021-07-18 18:14:41 - INFO :: Thread-2 : Tautulli NotificationHandler :: Preparing notification for notifier_id 10. 2021-07-18 18:14:41 - DEBUG :: Thread-3 : Tautulli NotificationHandler :: Notifiers enabled for notify_action 'on_concurrent'. 2021-07-18 18:14:41 - DEBUG :: Thread-3 : Tautulli NotificationHandler :: Checking global notification conditions. 2021-07-18 18:14:41 - DEBUG :: Thread-2 : Tautulli Notifiers :: Trying to run notify script: /scripts/kill_stream.py, arguments: ['--jbop', 'stream', '--username', 'danialrosli94', '--sessionId', '84A34895-4E32-46AD-A749-C45A43330639', '--killMessage', 'Opsss! Seems like you have been banned from this server. Please contact admin.'], action: play 2021-07-18 18:14:41 - DEBUG :: Thread-2 : Tautulli Notifiers :: Full script is: ['/usr/local/bin/python', '/scripts/kill_stream.py', '--jbop', 'stream', '--username', 'danialrosli94', '--sessionId', '84A34895-4E32-46AD-A749-C45A43330639', '--killMessage', 'Opsss! Seems like you have been banned from this server. Please contact admin.']

To Reproduce

Steps to reproduce the behavior:

  1. Configuration: script --> kill_stream.py
  2. Triggers: Playback Start
  3. Conditions: User is 'Pop'
  4. Argument: --jbop stream --username {username} --sessionId {session_id} --killMessage 'Opsss! Seems like you have been banned from this server. Please contact admin.'
  5. Stream Plex using iOS/AppleTV devices.

Expected behavior Stream will be killed if the user play. Works on other platform like Windows and Android TV. But not working on iOS and AppleTV.

Screenshots image

Desktop (please complete the following information):

blacktwin commented 3 years ago

Can you confirm that you are able to kill the stream via Plex and/or Tautulli? Some clients may not response back to the server properly. That sessionID doesn't look right.

Also with a message like this: "Seems like you have been banned from this server. Please contact admin" you should just unshare or remove them not rely on the script to serve that function.

stickyfin commented 3 years ago

I able to kill stream from Plex/Tautulli manually. Tautulli Pmsconnect :: Terminating session 393 (session_id 5E00A425-CC43-4A77-A3F6-632B5DA59998).

What do you mean by "That sessionID doesn't look right."?

By removing --killMessage parameter, the script able to kill the stream. I tested by creating another kill_stream script to test. Weird

2021-07-27 21:30:59 - DEBUG :: Thread-2 : Tautulli NotificationHandler :: {1} user | is | 'owner' > 'owner' > True 2021-07-27 21:30:59 - DEBUG :: Thread-2 : Tautulli NotificationHandler :: {2} product | contains | 'ios' > 'plex for ios' > True 2021-07-27 21:30:59 - DEBUG :: Thread-2 : Tautulli NotificationHandler :: Condition logic [blank]: {1} and {2} > True 2021-07-27 21:30:59 - DEBUG :: Thread-2 : Tautulli NotificationHandler :: Custom conditions evaluated to 'True'. Conditions: [True, True]. 2021-07-27 21:30:59 - INFO :: Thread-2 : Tautulli NotificationHandler :: Preparing notification for notifier_id 12. 2021-07-27 21:30:59 - DEBUG :: Thread-3 : Tautulli NotificationHandler :: Notifiers enabled for notify_action 'on_concurrent'. 2021-07-27 21:30:59 - DEBUG :: Thread-3 : Tautulli NotificationHandler :: Checking global notification conditions. 2021-07-27 21:31:00 - DEBUG :: Thread-3 : Tautulli NotificationHandler :: Global notification conditions evaluated to 'False'. 2021-07-27 21:31:00 - DEBUG :: Thread-2 : Tautulli Notifiers :: Trying to run notify script: /scripts/kill_stream.py, arguments: ['--jbop', 'stream', '--username', 'owner', '--sessionId', '5E00A425-CC43-4A77-A3F6-632B5DA59998'], action: play 2021-07-27 21:31:00 - DEBUG :: Thread-2 : Tautulli Notifiers :: Full script is: ['/usr/local/bin/python', '/scripts/kill_stream.py', '--jbop', 'stream', '--username', 'owner', '--sessionId', '5E00A425-CC43-4A77-A3F6-632B5DA59998'] 2021-07-27 21:31:00 - DEBUG :: Thread-2 : Tautulli Notifiers :: Executing script in a new thread. 2021-07-27 21:31:01 - INFO :: CP Server Thread-5 : Tautulli Pmsconnect :: Terminating session 404 (session_id 5E00A425-CC43-4A77-A3F6-632B5DA59998).

blacktwin commented 3 years ago

What do you mean by "That sessionID doesn't look right."?

Just me not being familiar with tvOS or iOS. Try the message again but wrapped with "" instead of ''?

stickyfin commented 3 years ago

Yup I can confirm, substitute single quote with double quote on the --killMessage parameter does make it works.

2021-07-28 12:16:30 - DEBUG :: Thread-2 : Tautulli NotificationHandler :: Checking custom notification conditions for notifier_id 12. 2021-07-28 12:16:30 - DEBUG :: Thread-2 : Tautulli NotificationHandler :: {1} user | is | 'owner' > 'owner' > True 2021-07-28 12:16:30 - DEBUG :: Thread-2 : Tautulli NotificationHandler :: {2} product | contains | 'ios' > 'plex for ios' > True 2021-07-28 12:16:30 - DEBUG :: Thread-2 : Tautulli NotificationHandler :: Condition logic [blank]: {1} and {2} > True 2021-07-28 12:16:30 - DEBUG :: Thread-2 : Tautulli NotificationHandler :: Custom conditions evaluated to 'True'. Conditions: [True, True]. 2021-07-28 12:16:30 - INFO :: Thread-2 : Tautulli NotificationHandler :: Preparing notification for notifier_id 12. 2021-07-28 12:16:30 - DEBUG :: Thread-3 : Tautulli NotificationHandler :: Checking global notification conditions. 2021-07-28 12:16:30 - DEBUG :: Thread-2 : Tautulli Notifiers :: Trying to run notify script: /scripts/kill_stream.py, arguments: ['--jbop', 'stream', '--username', 'owner', '--sessionId', '5E00A425-CC43-4A77-A3F6-632B5DA59998', '--killMessage', 'Testing'], action: play 2021-07-28 12:16:30 - DEBUG :: Thread-2 : Tautulli Notifiers :: Full script is: ['/usr/local/bin/python', '/scripts/kill_stream.py', '--jbop', 'stream', '--username', 'owner', '--sessionId', '5E00A425-CC43-4A77-A3F6-632B5DA59998', '--killMessage', 'Testing'] 2021-07-28 12:16:30 - DEBUG :: Thread-2 : Tautulli Notifiers :: Executing script in a new thread. 2021-07-28 12:16:31 - DEBUG :: Thread-2 : Tautulli NotificationHandler :: Notifiers enabled for notify_action 'on_newdevice'. 2021-07-28 12:16:31 - DEBUG :: Thread-2 : Tautulli NotificationHandler :: Checking global notification conditions. 2021-07-28 12:16:31 - DEBUG :: Thread-2 : Tautulli NotificationHandler :: Global notification conditions evaluated to 'False'. 2021-07-28 12:16:32 - INFO :: CP Server Thread-5 : Tautulli Pmsconnect :: Terminating session 6 (session_id 5E00A425-CC43-4A77-A3F6-632B5DA59998). 2021-07-28 12:16:32 - DEBUG :: Thread-517 : Tautulli Notifiers :: Subprocess returned with status code 0. 2021-07-28 12:16:32 - INFO :: Thread-517 : Tautulli Notifiers :: Script notification sent.

image