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).
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`
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.
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.
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 ;)
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.
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.
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.
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).
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.