File tree Expand file tree Collapse file tree 1 file changed +27
-20
lines changed
Expand file tree Collapse file tree 1 file changed +27
-20
lines changed Original file line number Diff line number Diff line change @@ -56,9 +56,32 @@ def shorten(s, width):
5656 if not torrents :
5757 processes .no_media_found ()
5858
59+ interesting_states = [
60+ # 'uploading',
61+ "activeUP" ,
62+ "inactiveUP" ,
63+ "queuedUP" ,
64+ "stoppedUP" ,
65+ # "downloading",
66+ "stoppedDL" ,
67+ "queuedDL" ,
68+ "forcedMetaDL" ,
69+ "metaDL" ,
70+ "inactiveDL" ,
71+ "activeDL" ,
72+ "missingFiles" ,
73+ "error" ,
74+ ]
75+
5976 torrents_by_state = {}
60- for torrent in torrents :
61- torrents_by_state .setdefault (torrent .state , []).append (torrent )
77+ for t in torrents :
78+ state = t .state
79+ if state not in interesting_states :
80+ if t .state_enum .is_complete :
81+ state = "activeUP" if t .uploaded_session > 0 else "inactiveUP"
82+ else :
83+ state = "activeDL" if t .downloaded_session > 0 else "inactiveDL"
84+ torrents_by_state .setdefault (state , []).append (t )
6285
6386 categories = []
6487 for state , state_torrents in torrents_by_state .items ():
@@ -73,27 +96,11 @@ def shorten(s, width):
7396 }
7497 )
7598
76- interesting_states = [
77- "stoppedUP" ,
78- "queuedUP" ,
79- "stoppedDL" ,
80- "forcedMetaDL" ,
81- "metaDL" ,
82- "forcedDL" ,
83- "stalledDL" ,
84- # 'forcedUP', 'stalledUP', 'uploading', # not very interesting
85- "downloading" ,
86- "missingFiles" ,
87- "error" ,
88- ]
89-
9099 categories = sorted (
91100 categories ,
92101 key = lambda d : (
93- d ["state" ].endswith (("missingFiles" , "error" )),
94- d ["state" ].endswith (("downloading" , "DL" )),
95- iterables .safe_index (interesting_states , d ["state" ]),
96- ),
102+ iterables .safe_index (interesting_states , d ["state" ])
103+ )
97104 )
98105
99106 if len (torrents_by_state ) > 1 :
You can’t perform that action at this time.
0 commit comments