diff --git a/patrol.py b/patrol.py index 85fbedf..1a4bf09 100755 --- a/patrol.py +++ b/patrol.py @@ -98,6 +98,8 @@ def should_kick_stream(stream): return True, 0, config.KICK_TRANSCODE_MESSAGE if stream.state == 'paused' and config.KICK_PAUSED_TRANSCODES: return True, config.KICK_PAUSED_GRACE_MINS, config.KICK_PAUSED_MESSAGE + if stream.quality == '4K' and config.KICK_4K_TRANSCODE: + return True, 0, config.KICK_4K_TRANSCODE_MESSAGE else: # stream is directplay - check specifics @@ -176,4 +178,4 @@ def check_streams(): while True: log.debug("Checking streams in %d seconds", config.CHECK_INTERVAL) time.sleep(config.CHECK_INTERVAL) - check_streams() + check_streams() \ No newline at end of file diff --git a/settings.ini.default b/settings.ini.default index 0ed61bf..09f2da5 100644 --- a/settings.ini.default +++ b/settings.ini.default @@ -9,6 +9,8 @@ SERVER_TOKEN = your_server_token SERVER_NAME = Your_Server_Name # how often to check the active streams in seconds CHECK_INTERVAL = 90 +# instantly kick 4K transcodes? +KICK_4K_TRANSCODE = true # instantly kick video transcodes? KICK_VIDEO_TRANSCODES = false # instantly kick audio transcodes @@ -26,9 +28,10 @@ KICK_PAUSED_DIRECTPLAY = false # when the KICK_PAUSED* options above are true, the user has this many minutes to resume, otherwise kick KICK_PAUSED_GRACE_MINS = 5 # messages to be displayed for different kick types +KICK_4K_TRANSCODE_MESSAGE = You are not allowed to transcode 4K content, use a better client! KICK_PAUSED_MESSAGE = You are not allowed to pause a stream for that long... cya! KICK_TRANSCODE_MESSAGE = You are not allowed to transcode streams, use a better client! KICK_PLAYER_MESSAGE = You are not allowed to use this trash player. Use the official software from www.plex.tv/downloads -> Get An App!!! KICK_MULTI_IP_MESSAGE = You are not allowed to stream from more than 1 IP address! # user list seperated by a , who are immune from all kicks -WHITELISTED_USERS = User1, User2, User3 +WHITELISTED_USERS = User1, User2, User3 \ No newline at end of file diff --git a/utils/config.py b/utils/config.py index 4ed0eaf..ad79e99 100644 --- a/utils/config.py +++ b/utils/config.py @@ -13,6 +13,8 @@ SERVER_NAME = config('SERVER_NAME') CHECK_INTERVAL = config('CHECK_INTERVAL', 60, cast=int) +KICK_4K_TRANSCODE = config('KICK_4K_TRANSCODE',False,cast=bool) +KICK_4K_TRANSCODE_MESSAGE = config('KICK_4K_TRANSCODE_MESSAGE','You are not allowed to transcode 4K content, use a better client!') KICK_VIDEO_TRANSCODES = config('KICK_VIDEO_TRANSCODES', False, cast=bool) KICK_AUDIO_TRANSCODES = config('KICK_AUDIO_TRANSCODES', False, cast=bool) KICK_CLIENT_PLAYERS = config('KICK_CLIENT_PLAYERS', [], cast=Csv()) @@ -31,4 +33,4 @@ 'Use the official software from www.plex.tv/downloads -> Get An App!!!') KICK_MULTI_IP_MESSAGE = config('KICK_MULTI_IP_MESSAGE', 'You are not allowed to stream from more than 1 IP address!') -WHITELISTED_USERS = config('WHITELISTED_USERS', [], cast=Csv()) +WHITELISTED_USERS = config('WHITELISTED_USERS', [], cast=Csv()) \ No newline at end of file diff --git a/utils/plex.py b/utils/plex.py index b721392..3d316e3 100644 --- a/utils/plex.py +++ b/utils/plex.py @@ -129,6 +129,14 @@ def __init__(self, stream): self.player = 'Unknown' self.ip = 'Unknown' + self.quality = "Unknown" + if 'Media' in stream: + for media in stream['Media']: + if 'Part' in media: + for part in media['Part']: + if 'Stream' in part and 'displayTitle' in part['Stream'][0]: + self.quality = part['Stream'][0]['displayTitle'].split(' ')[0].upper() + if 'Session' in stream: self.session_id = stream['Session']['id'] else: @@ -202,4 +210,4 @@ def __getattr__(self, item): pass # Default behaviour - return 'Unknown' + return 'Unknown' \ No newline at end of file