simpler
Add only the devices that you want to kill on playback start.
This commit is contained in:
parent
8ffdbbb939
commit
ce12c4a1bf
@ -13,20 +13,16 @@ from plexapi.server import PlexServer
|
|||||||
|
|
||||||
|
|
||||||
## EDIT THESE SETTINGS ##
|
## EDIT THESE SETTINGS ##
|
||||||
PLEX_TOKEN = 'xxxx'
|
PLEX_TOKEN = 'xxxxxx'
|
||||||
PLEX_URL = 'http://localhost:32400'
|
PLEX_URL = 'http://localhost:32400'
|
||||||
|
|
||||||
DEFAULT_REASON = 'This stream has ended due to your device type.'
|
DEFAULT_REASON = 'This stream has ended due to your device type.'
|
||||||
|
|
||||||
# Find platforms that have history in PlexPy in Play count by platform and stream type Graph
|
# Find platforms that have history in PlexPy in Play count by platform and stream type Graph
|
||||||
DEVICES = {'Android':
|
DEVICES = {'Android': 'Andriod message',
|
||||||
{ 'message': 'Andriod message', 'kill': False},
|
'Chrome': 'Chrome message',
|
||||||
'Chrome':
|
'Plex Media Player': 'PMP message',
|
||||||
{ 'message': 'Chrome message', 'kill': True},
|
'Chromecast': 'Chromecast message'}
|
||||||
'Plex Media Player':
|
|
||||||
{ 'message': 'PMP message', 'kill': False},
|
|
||||||
'Chromecast':
|
|
||||||
{ 'message': 'Chromecast message', 'kill': True}}
|
|
||||||
|
|
||||||
USER_IGNORE = ('') # ('Username','User2')
|
USER_IGNORE = ('') # ('Username','User2')
|
||||||
##/EDIT THESE SETTINGS ##
|
##/EDIT THESE SETTINGS ##
|
||||||
@ -35,20 +31,21 @@ sess = requests.Session()
|
|||||||
sess.verify = False
|
sess.verify = False
|
||||||
plex = PlexServer(PLEX_URL, PLEX_TOKEN, session=sess)
|
plex = PlexServer(PLEX_URL, PLEX_TOKEN, session=sess)
|
||||||
|
|
||||||
|
|
||||||
def kill_session():
|
def kill_session():
|
||||||
|
|
||||||
for session in plex.sessions():
|
for session in plex.sessions():
|
||||||
user = session.usernames[0]
|
user = session.usernames[0]
|
||||||
if user in USER_IGNORE:
|
if user in USER_IGNORE:
|
||||||
print('Ignoring {}\'s stream.'.format(user))
|
print('Ignoring {}\'s stream from platform check.'.format(user))
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
platform = session.players[0].platform
|
platform = session.players[0].platform
|
||||||
if DEVICES[platform]['kill'] is True:
|
if DEVICES[platform]:
|
||||||
MESSAGE = DEVICES[platform].get('message', DEFAULT_REASON)
|
MESSAGE = DEVICES.get(platform, DEFAULT_REASON)
|
||||||
print('Killing {user}\'s stream on {plat}.'.format(user=user, plat=platform))
|
print('Killing {user}\'s stream on {plat}.'.format(user=user, plat=platform))
|
||||||
session.stop(reason=MESSAGE)
|
session.stop(reason=MESSAGE)
|
||||||
|
else:
|
||||||
|
print('{user}\'s stream on {plat} is allowed to play.'.format(user=user, plat=platform))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
kill_session()
|
kill_session()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user