diff --git a/plexpy/datafactory.py b/plexpy/datafactory.py index 5c9ff6f4..4f1afefd 100644 --- a/plexpy/datafactory.py +++ b/plexpy/datafactory.py @@ -587,23 +587,25 @@ class DataFactory(object): times = sorted(times, key=lambda k: k['time']) count = 0 + last_count = 0 last_start = 0 - most_concurrent = {'count': count} + most_concurrent = [] for d in times: if d['count'] == 1: count += d['count'] - if count >= most_concurrent['count']: + if count >= last_count: last_start = d['time'] else: - if count >= most_concurrent['count']: - most_concurrent = {'count': count, - 'started': last_start[:-1], - 'stopped': d['time'][:-1]} + if count >= last_count: + last_count = count + most_concurrent = [{'count': count, + 'started': last_start[:-1], + 'stopped': d['time'][:-1]}] count += d['count'] home_stats.append({'stat_id': stat, - 'rows': [most_concurrent]}) + 'rows': most_concurrent}) return home_stats @@ -1087,4 +1089,4 @@ class DataFactory(object): for item in result: total_duration = item['total_duration'] - return total_duration \ No newline at end of file + return total_duration