Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Medium formats aren't listed in order (PICARD-91)

Rewrite media_formats_from_node to emulate the mbserver code.
  • Loading branch information...
commit 211150802d2b28199a669f11782cddf844a3322a 1 parent 9c1aff8
Michael Wiencek mwiencek authored
Showing with 17 additions and 8 deletions.
  1. +17 −8 picard/mbxml.py
25 picard/mbxml.py
View
@@ -174,17 +174,26 @@ def label_info_from_node(node):
def media_formats_from_node(node):
- formats = {}
+ formats_count = {}
+ formats_order = []
for medium in node.medium:
if "format" in medium.children:
text = medium.format[0].text
- formats[text] = formats.get(text, 0) + 1
- if formats:
- return " + ".join([
- (str(j) + u"×" if j > 1 else "") + RELEASE_FORMATS.get(i, i)
- for i, j in formats.items()])
- else:
- return ""
+ else:
+ text = "(unknown)"
+ if text in formats_count:
+ formats_count[text] += 1
+ else:
+ formats_count[text] = 1
+ formats_order.append(text)
+ formats = []
+ for format in formats_order:
+ format = RELEASE_FORMATS.get(format, format)
+ count = formats_count[format]
+ if count > 1:
+ format = str(count) + u"×" + format
+ formats.append(format)
+ return " + ".join(formats)
def track_to_metadata(node, track, config):
Please sign in to comment.
Something went wrong with that request. Please try again.