clean up and removed try/exceptions
This commit is contained in:
parent
4305a1190b
commit
0a831fa07e
@ -165,7 +165,7 @@ class Plex(object):
|
|||||||
"""All collections from server
|
"""All collections from server
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
sections: dict
|
collections: dict
|
||||||
{collection title: collection object}
|
{collection title: collection object}
|
||||||
"""
|
"""
|
||||||
collections = {}
|
collections = {}
|
||||||
@ -309,7 +309,6 @@ if __name__ == '__main__':
|
|||||||
plex_server = Plex(PLEX_TOKEN, PLEX_URL)
|
plex_server = Plex(PLEX_TOKEN, PLEX_URL)
|
||||||
for user in opts.users:
|
for user in opts.users:
|
||||||
user_server = plex_server.server.switchUser(user)
|
user_server = plex_server.server.switchUser(user)
|
||||||
user_server._history = []
|
|
||||||
user_server._username = user
|
user_server._username = user
|
||||||
user_servers.append(user_server)
|
user_servers.append(user_server)
|
||||||
|
|
||||||
@ -322,7 +321,6 @@ if __name__ == '__main__':
|
|||||||
source_dict[library] = section_total
|
source_dict[library] = section_total
|
||||||
print("Section: {}, has {} items.".format(library, section_total))
|
print("Section: {}, has {} items.".format(library, section_total))
|
||||||
for user_server in user_servers:
|
for user_server in user_servers:
|
||||||
try:
|
|
||||||
section = user_server.library.section(library)
|
section = user_server.library.section(library)
|
||||||
if section.type == 'movie':
|
if section.type == 'movie':
|
||||||
section_watched_lst = section.search(unwatched=False)
|
section_watched_lst = section.search(unwatched=False)
|
||||||
@ -338,12 +336,6 @@ if __name__ == '__main__':
|
|||||||
user_dict[user_server._username].update({library: section_watched_total})
|
user_dict[user_server._username].update({library: section_watched_total})
|
||||||
else:
|
else:
|
||||||
user_dict[user_server._username] = {library: section_watched_total}
|
user_dict[user_server._username] = {library: section_watched_total}
|
||||||
except Exception as e:
|
|
||||||
print((user_server._username, e))
|
|
||||||
if user_dict.get(user_server._username):
|
|
||||||
user_dict[user_server._username].update({library: 0})
|
|
||||||
else:
|
|
||||||
user_dict[user_server._username] = {library: 0}
|
|
||||||
|
|
||||||
if opts.collections:
|
if opts.collections:
|
||||||
title = "User's Watch Percentage by Collection\nFrom: {}"
|
title = "User's Watch Percentage by Collection\nFrom: {}"
|
||||||
@ -362,7 +354,7 @@ if __name__ == '__main__':
|
|||||||
if album.viewedLeafCount:
|
if album.viewedLeafCount:
|
||||||
user_server._history.append(album)
|
user_server._history.append(album)
|
||||||
collection_watched_lst.append(album)
|
collection_watched_lst.append(album)
|
||||||
collection_watched_total = len(user_server._history)
|
collection_watched_total = len(collection_watched_lst)
|
||||||
percent_watched = 100 * (float(collection_watched_total) / float(collection_total))
|
percent_watched = 100 * (float(collection_watched_total) / float(collection_total))
|
||||||
print(" {} has listened {} items ({}%).".format(user_server._username, collection_watched_total,
|
print(" {} has listened {} items ({}%).".format(user_server._username, collection_watched_total,
|
||||||
int(percent_watched)))
|
int(percent_watched)))
|
||||||
@ -378,7 +370,6 @@ if __name__ == '__main__':
|
|||||||
# image = rget(thumb_url, stream=True)
|
# image = rget(thumb_url, stream=True)
|
||||||
image = urllib.request.urlretrieve(thumb_url)
|
image = urllib.request.urlretrieve(thumb_url)
|
||||||
for user_server in user_servers:
|
for user_server in user_servers:
|
||||||
try:
|
|
||||||
collection_watched_lst = []
|
collection_watched_lst = []
|
||||||
for item in collection_items:
|
for item in collection_items:
|
||||||
user_item = user_server.fetchItem(item.ratingKey)
|
user_item = user_server.fetchItem(item.ratingKey)
|
||||||
@ -392,12 +383,6 @@ if __name__ == '__main__':
|
|||||||
user_dict[user_server._username].update({collection: collection_watched_total})
|
user_dict[user_server._username].update({collection: collection_watched_total})
|
||||||
else:
|
else:
|
||||||
user_dict[user_server._username] = {collection: collection_watched_total}
|
user_dict[user_server._username] = {collection: collection_watched_total}
|
||||||
except Exception as e:
|
|
||||||
print((user_server._username, e))
|
|
||||||
if user_dict.get(user_server._username):
|
|
||||||
user_dict[user_server._username].update({collection: 0})
|
|
||||||
else:
|
|
||||||
user_dict[user_server._username] = {collection: 0}
|
|
||||||
|
|
||||||
if opts.shows:
|
if opts.shows:
|
||||||
title = "User's Watch Percentage by Shows\nFrom: {}"
|
title = "User's Watch Percentage by Shows\nFrom: {}"
|
||||||
@ -411,7 +396,6 @@ if __name__ == '__main__':
|
|||||||
source_dict[show_title] = len(show.episodes())
|
source_dict[show_title] = len(show.episodes())
|
||||||
print("Show: {}, has {} episodes.".format(show_title, episode_total))
|
print("Show: {}, has {} episodes.".format(show_title, episode_total))
|
||||||
for user_server in user_servers:
|
for user_server in user_servers:
|
||||||
try:
|
|
||||||
user_show = user_server.fetchItem(show.ratingKey)
|
user_show = user_server.fetchItem(show.ratingKey)
|
||||||
source_watched_lst = user_show.watched()
|
source_watched_lst = user_show.watched()
|
||||||
source_watched_total = len(source_watched_lst)
|
source_watched_total = len(source_watched_lst)
|
||||||
@ -423,12 +407,6 @@ if __name__ == '__main__':
|
|||||||
user_dict[user_server._username].update({show_title: source_watched_total})
|
user_dict[user_server._username].update({show_title: source_watched_total})
|
||||||
else:
|
else:
|
||||||
user_dict[user_server._username] = {show_title: source_watched_total}
|
user_dict[user_server._username] = {show_title: source_watched_total}
|
||||||
except Exception as e:
|
|
||||||
print((user_server._username, e))
|
|
||||||
if user_dict.get(user_server._username):
|
|
||||||
user_dict[user_server._username].update({show_title: 0})
|
|
||||||
else:
|
|
||||||
user_dict[user_server._username] = {show_title: 0}
|
|
||||||
|
|
||||||
elif opts.tautulli:
|
elif opts.tautulli:
|
||||||
# Create a Tautulli instance
|
# Create a Tautulli instance
|
||||||
|
Loading…
Reference in New Issue
Block a user