updated
This commit is contained in:
parent
e8feab3b18
commit
cb0368f18b
@ -124,7 +124,7 @@ def get_users_tables(users='', length=''):
|
|||||||
sys.stderr.write("Tautulli API 'get_users_tables' request failed: {0}.".format(e))
|
sys.stderr.write("Tautulli API 'get_users_tables' request failed: {0}.".format(e))
|
||||||
|
|
||||||
|
|
||||||
def get_users_ips(user_id, length):
|
def get_users_ips(user_id):
|
||||||
# Get the user IP list from Tautulli
|
# Get the user IP list from Tautulli
|
||||||
payload = {'apikey': TAUTULLI_APIKEY,
|
payload = {'apikey': TAUTULLI_APIKEY,
|
||||||
'cmd': 'get_user_ips',
|
'cmd': 'get_user_ips',
|
||||||
@ -191,8 +191,8 @@ def get_geo_dict(length, users):
|
|||||||
'ip': REPLACEMENT_WAN_IP, 'play_count': 0, 'platform': SERVER_PLATFORM,
|
'ip': REPLACEMENT_WAN_IP, 'play_count': 0, 'platform': SERVER_PLATFORM,
|
||||||
'location_count': 0}]}
|
'location_count': 0}]}
|
||||||
|
|
||||||
for i in get_users_tables(users):
|
for user in get_users_tables(users=users, length=length):
|
||||||
user_ip = get_users_ips(user_id=i, length=length)
|
user_ip = get_users_ips(user_id=user)
|
||||||
city_cnt = 0
|
city_cnt = 0
|
||||||
for a in user_ip:
|
for a in user_ip:
|
||||||
try:
|
try:
|
||||||
@ -445,8 +445,7 @@ if __name__ == '__main__':
|
|||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
})
|
})
|
||||||
|
|
||||||
print(r.json()['html_url'])
|
|
||||||
webbrowser.open(r.json()['html_url'])
|
webbrowser.open(r.json()['html_url'])
|
||||||
else:
|
else:
|
||||||
print(geo_json)
|
# print(geo_json)
|
||||||
draw_map(opts.location, geo_json, filename, opts.headless)
|
draw_map(opts.location, geo_json, filename, opts.headless)
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
"""
|
"""
|
||||||
From a list of TV shows, check if users in a list has watched shows episodes.
|
From a list of TV shows, check if users in a list has watched shows episodes.
|
||||||
If all users in list have watched an episode of listed show, then delete episode.
|
If all users in list have watched an episode of listed show, then delete episode.
|
||||||
|
|
||||||
|
Add deletion via Plex.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
@ -282,15 +282,15 @@ if __name__ == "__main__":
|
|||||||
BAN = 1
|
BAN = 1
|
||||||
UNBAN = 0
|
UNBAN = 0
|
||||||
|
|
||||||
for i in user_lst:
|
for user in user_lst:
|
||||||
history = get_history(i, BAN_RATING)
|
history = get_history(user, BAN_RATING)
|
||||||
mail_add, friendly = get_user(i)
|
mail_add, friendly = get_user(user)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if act_lst.count(i) >= LIMIT:
|
if act_lst.count(user) >= LIMIT:
|
||||||
# Trigger for first and next violation
|
# Trigger for first and next violation
|
||||||
unshare(i) # Remove libraries
|
unshare(user) # Remove libraries
|
||||||
share(i, BAN) # Share banned library
|
share(user, BAN) # Share banned library
|
||||||
sys.stdout.write("Shared BAN_LIBRARY with user {0}".format(i))
|
sys.stdout.write("Shared BAN_LIBRARY with user {0}".format(i))
|
||||||
if type(history) is int:
|
if type(history) is int:
|
||||||
# Next violation, history of banned video.
|
# Next violation, history of banned video.
|
||||||
@ -301,16 +301,16 @@ if __name__ == "__main__":
|
|||||||
# email address, friendly name, violation number, violation limit, message
|
# email address, friendly name, violation number, violation limit, message
|
||||||
elif type(history) is int:
|
elif type(history) is int:
|
||||||
# Trigger to share
|
# Trigger to share
|
||||||
if share(i, UNBAN) == 400:
|
if share(user, UNBAN) == 400:
|
||||||
exit() # User has history of watching banned video but libraries are already restored.
|
exit() # User has history of watching banned video but libraries are already restored.
|
||||||
else:
|
else:
|
||||||
unshare(i) # Remove banned library
|
unshare(user) # Remove banned library
|
||||||
share(i, UNBAN) # Restore libraries
|
share(user, UNBAN) # Restore libraries
|
||||||
elif history == 'ban':
|
elif history == 'ban':
|
||||||
# Trigger for ban
|
# Trigger for ban
|
||||||
unshare(i)
|
unshare(user)
|
||||||
send_notification(mail_add, friendly, VIOLATION_LIMIT, VIOLATION_LIMIT, FINAL_WARN)
|
send_notification(mail_add, friendly, VIOLATION_LIMIT, VIOLATION_LIMIT, FINAL_WARN)
|
||||||
# email address, friendly name, violation number, violation limit, message
|
# email address, friendly name, violation number, violation limit, message
|
||||||
sys.stdout.write("User {0} has been banned".format(i))
|
sys.stdout.write("User {0} has been banned".format(user))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
sys.stderr.write("Share_unshare failed: {0}.".format(e))
|
sys.stderr.write("Share_unshare failed: {0}.".format(e))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user