This commit is contained in:
Blacktwin 2018-04-09 08:36:12 -04:00
parent e8feab3b18
commit cb0368f18b
3 changed files with 17 additions and 16 deletions

View File

@ -124,7 +124,7 @@ def get_users_tables(users='', length=''):
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
payload = {'apikey': TAUTULLI_APIKEY,
'cmd': 'get_user_ips',
@ -191,8 +191,8 @@ def get_geo_dict(length, users):
'ip': REPLACEMENT_WAN_IP, 'play_count': 0, 'platform': SERVER_PLATFORM,
'location_count': 0}]}
for i in get_users_tables(users):
user_ip = get_users_ips(user_id=i, length=length)
for user in get_users_tables(users=users, length=length):
user_ip = get_users_ips(user_id=user)
city_cnt = 0
for a in user_ip:
try:
@ -445,8 +445,7 @@ if __name__ == '__main__':
'Content-Type': 'application/json'
})
print(r.json()['html_url'])
webbrowser.open(r.json()['html_url'])
else:
print(geo_json)
# print(geo_json)
draw_map(opts.location, geo_json, filename, opts.headless)

View File

@ -1,6 +1,8 @@
"""
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.
Add deletion via Plex.
"""
import requests

View File

@ -282,15 +282,15 @@ if __name__ == "__main__":
BAN = 1
UNBAN = 0
for i in user_lst:
history = get_history(i, BAN_RATING)
mail_add, friendly = get_user(i)
for user in user_lst:
history = get_history(user, BAN_RATING)
mail_add, friendly = get_user(user)
try:
if act_lst.count(i) >= LIMIT:
if act_lst.count(user) >= LIMIT:
# Trigger for first and next violation
unshare(i) # Remove libraries
share(i, BAN) # Share banned library
unshare(user) # Remove libraries
share(user, BAN) # Share banned library
sys.stdout.write("Shared BAN_LIBRARY with user {0}".format(i))
if type(history) is int:
# Next violation, history of banned video.
@ -301,16 +301,16 @@ if __name__ == "__main__":
# email address, friendly name, violation number, violation limit, message
elif type(history) is int:
# 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.
else:
unshare(i) # Remove banned library
share(i, UNBAN) # Restore libraries
unshare(user) # Remove banned library
share(user, UNBAN) # Restore libraries
elif history == 'ban':
# Trigger for ban
unshare(i)
unshare(user)
send_notification(mail_add, friendly, VIOLATION_LIMIT, VIOLATION_LIMIT, FINAL_WARN)
# 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:
sys.stderr.write("Share_unshare failed: {0}.".format(e))