Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write out CHAP frames in start_time order, ref #506 #539

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion mutagen/id3/_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,16 @@ def get_prio(frame):

def sort_key(items):
frame, data = items
return (get_prio(frame), len(data), frame.HashKey)
frame_key = frame.HashKey
frame_size = len(data)

# Let's ensure chapters are always sorted by their 'start_time'
# and not by size/element_id pair.
if frame.FrameID == "CHAP":
frame_key = frame.FrameID
frame_size = frame.start_time

return (get_prio(frame), frame_size, frame_key)

framedata = [d for (f, d) in sorted(framedata, key=sort_key)]

Expand Down