File tree 1 file changed +18
-4
lines changed
1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -195,13 +195,27 @@ def get_prio(frame):
195
195
try :
196
196
return order .index (frame .FrameID )
197
197
except ValueError :
198
- return len (order )
198
+ # Pictures are placed last due to their presumed size.
199
+ if frame .FrameID == "APIC" :
200
+ return len (order ) + 1
201
+ else :
202
+ return len (order )
199
203
200
204
def sort_key (items ):
201
- frame , data = items
202
- return (get_prio (frame ), len (data ), frame .HashKey )
205
+ i , (frame , data ) = items
206
+
207
+ if frame .FrameID == "APIC" :
208
+ # The order among APIC frames is preserved, as their order
209
+ # can influence, say, what image is chosen as cover image
210
+ # in many players.
211
+ secondary_key = i
212
+ else :
213
+ secondary_key = len (data )
214
+
215
+ return (get_prio (frame ), secondary_key , frame .HashKey )
203
216
204
- framedata = [d for (f , d ) in sorted (framedata , key = sort_key )]
217
+ framedata = [
218
+ d for (i , (f , d )) in sorted (enumerate (framedata ), key = sort_key )]
205
219
206
220
# only write unknown frames if they were loaded from the version
207
221
# we are saving with. Theoretically we could upgrade frames
You can’t perform that action at this time.
0 commit comments