Commit Graph

55 Commits

Author SHA1 Message Date
JonnyWong16
0d1685afed
Run futurize --unicode-literals 2020-07-04 13:31:02 -07:00
JonnyWong16
dc6507ffed
Run futurize --stage2 2020-07-04 13:23:47 -07:00
JonnyWong16
30dbccda77
Run futurize --stage1 2020-07-04 13:08:59 -07:00
blacktwin
36aa2dd3a3 address issue found when running with python3 2020-06-04 21:20:54 -04:00
blacktwin
8a80b7b3ac
Merge pull request #199 from JonnyWong16/master
Remove default subject and body for rich notification
2019-11-25 08:31:28 -05:00
JonnyWong16
55740a099a Remove default subject and body for rich notification 2019-11-24 22:38:04 -08:00
Landon Abney
66ac37b34e
Print raw response when JSON fails to parse
If the response to the Tautulli API fails to parse correctly include the 
raw output in the message to make it easier to diagnose when the 
response isn't actually raw JSON from a Tautulli server (e.g. a proxy 
server).
2019-10-27 20:04:36 -07:00
Landon Abney
2be0e376f8
Massive style cleanup
Adds a basic `setup.cfg` file with configurations for flake8 and pylama, 
fixes some basic issues with essentially every file including:
* Many, many, whitespace line cleanups
* Several unused variables and imports
* Missing coding and shabang lines
* Minor style fixes to more closely align with PEP8
* Turn `print` into function calls for Python 2/3 compat
* A few minor bugs
  * Things like using an undefined `i` in `stream_limiter_ban_email.py`
2019-06-20 23:55:11 -07:00
dirtycajunrice
d9e383f871 removed multipstreams and changed readme to show example of working multi ip stream change 2018-12-23 21:07:46 -06:00
dirtycajunrice
a27056a11f fixed condition in which if user streams is set to more than one, it
would try to kill and notify x times more
2018-12-19 23:49:20 -06:00
dirtycajunrice
79088cf6ce added readme and snuck my name in >.< 2018-12-19 23:47:08 -06:00
dirtycajunrice
93ddee995e fixed rich message pointer from Arc 2018-12-19 23:26:35 -06:00
dirtycajunrice
d1443d2670 final addition to initialize ip_address for linting 2018-12-19 21:18:34 -06:00
dirtycajunrice
758af21ade spacing 2018-12-19 21:17:44 -06:00
dirtycajunrice
457486924e added functionality for dropping multi IP users 2018-12-19 21:15:45 -06:00
dirtycajunrice
f9ce8eae63 removed all instances of shadow of outer scope, made explicit from
implicit inheritance, defined a few docstring params, initialized 2 vars
2018-12-19 19:57:30 -06:00
dirtycajunrice
463586ff29 fixed typos and sams rename 2018-12-19 19:08:27 -06:00
samwiseg00
713f6fbe56 Rewrite Kill_stream.py to add rich message functionality 2018-09-08 20:31:06 -04:00
blacktwin
038c17c41d
Merge pull request #88 from JonnyWong16/kill-pause-username
Add username argument for kill paused
2018-08-14 13:53:16 -04:00
JonnyWong16
ec07cebef9 Add username argument for kill paused 2018-08-13 21:15:31 -07:00
Blacktwin
8c3781728a sessionId check bypass if jbop == allstreams.
sessionId arg not needed for killing all user streams.
2018-08-13 07:03:37 -04:00
Blacktwin
ffa97daeff sessionId no longer required.
check for sessionId is performed later.
2018-08-13 07:01:05 -04:00
Blacktwin
20f79eafa8 doc fix 2018-07-10 08:17:29 -04:00
JonnyWong16
c413526ec3 Return empty list if get_activity fails 2018-06-29 23:58:24 -07:00
JonnyWong16
2bd92acca7 Encode back to UTF-8 2018-06-29 23:50:42 -07:00
JonnyWong16
1e8e96398b Decode script arguments 2018-06-29 13:14:13 -07:00
Landon Abney
bef7be7627
Exit if a sessionID wasn't provided
If the user mistakenly calls the script without a `sessionID`, exit 
early with a warning message and the likely reason.
2018-06-20 10:45:00 -07:00
Landon Abney
98186dec8b
Ensure newlines in output
Although there will only be a single line of output in most cases, 
ensure that newlines are printed in case there are multiple lines, or 
the script is running in a full shell.
2018-06-18 20:49:16 -07:00
Landon Abney
75b4fa3229
Add examples for paused streams
Add a few examples for usage of the new paused stream functionality.
2018-06-18 13:30:41 -07:00
Landon Abney
c976a3dfb1
Cleanup format of examples
Cleans up the examples to all have a standard format that covers all
required settings and gives example messages where appropriate.
2018-06-18 13:22:40 -07:00
Landon Abney
7b07bb314f
Update authors 2018-06-18 12:39:21 -07:00
Landon Abney
0e5c374449
Return instead of forcibly exiting
This makes no difference currently as the script doesn't do anything
after this function finishes, but it allows any cleanup work to happen
at the end.
2018-06-18 12:38:10 -07:00
Landon Abney
ad682f3d1b
Fix time limit on paused stream monitoring
The only way that this could ever be hit is if the stream is still
active on the server, but the state is NOT one of paused, playing, or
buffering. In case Plex decides to change the states in the future
having this working properly is a good idea ;)
2018-06-18 12:37:12 -07:00
Landon Abney
99b36aab88
camelCase -> snake_case 2018-06-18 11:54:17 -07:00
Landon Abney
31ddd97a34
Actually use BODY_TEXT_USER 2018-06-18 11:50:41 -07:00
Landon Abney
98b72f0a62
Cleanup documentation and add examples
Cleanup the documentation on how to set it up to match the current 
Tautulli state. Add a few examples to give people ideas for how to use 
this script.
2018-06-17 00:27:13 -07:00
Landon Abney
c03860ec70
Incorporate waiting to kill paused streams into kill_stream.py
Incorporate the functionality of `wait_kill_paused_notify.py` into 
`kill_stream.py`. A new selector is added of `paused` enabling this 
mode, and adds two additional arguments to control how long to wait for 
paused streams, and how often to check a stream's status. The default 
values are to kill a stream after 20 minutes, checking every 30 seconds.

The Tautulli API is used for all functionality, meaning the `plexapi` 
module is no longer required.
2018-06-17 00:01:00 -07:00
Landon Abney
0ba8e2bda0
Add a docstring for terminate_session 2018-06-16 23:53:17 -07:00
Landon Abney
4ebfaf17bd
Always send a notification if an agent is specified
Whenever a stream is killed, send a notification for that stream if a 
notification agent has been specified. If no username is specified, 
simply list the session ID.
2018-06-16 23:53:15 -07:00
Landon Abney
2116082fd7
List --killMessage at the end
Although argparse should be smart enough to handle this in any order, 
it's generally easier for us poor humans to read the arguments if the 
unstructured one is the last argument. Re-order the listing to make this 
clearer.
2018-06-16 23:53:12 -07:00
Landon Abney
342284173b
Use the same session for all requests
Use the Session created at the start of the script for all requests, 
instead of creating a new one for some of them (which doesn't inherit 
the settings set on it at the start).
2018-06-16 23:51:53 -07:00
Landon Abney
7b0cc2d2a9
Disable InsecureRequestWarning if SSL verify is False
If checking of HTTPS validity is disable, turn off the warning that it 
has been disabled since we have done so explicitly.
2018-06-16 23:51:51 -07:00
Landon Abney
00f4bf26a9
Rename get_user_activity
This function was actually getting _just_ the session IDs, not the whole 
session data.
2018-06-16 23:51:48 -07:00
Landon Abney
e56d23b12d
Refactor get_activity into two functions
Create a new function get_user_activity that returns the same data 
get_activity originally did and use that in main. get_activity now 
actually follows the name and gets all activity on the server.
2018-06-16 23:51:46 -07:00
Landon Abney
f7c555caa7
Add docbloc for send_notification 2018-06-16 23:51:43 -07:00
Landon Abney
36c2ddaaf6
Fix PEP8 issues
Some minor refactoring to follow PEP8 guidlines.
2018-06-16 23:51:32 -07:00
Blacktwin
e70787827d updated arguments comments.
moved examples.txt to readme.md
removed examples.txt
2018-06-15 08:32:28 -04:00
Blacktwin
64f008d1eb Corrected killMessage processing.
updated argument instruction.
2018-06-14 08:56:20 -04:00
Blacktwin
776fe7334b show --jbop choices. 2018-06-14 00:47:21 -04:00
Too Much IO
33c29f4bcc
Format syntax error [ instead of { 2018-06-14 09:04:33 +10:00