Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 authored December 11, 2011

Showing 1 changed file with 17 additions and 8 deletions. Show diff stats Hide diff stats

  1. 25  picard/mbxml.py
25  picard/mbxml.py
@@ -174,17 +174,26 @@ def label_info_from_node(node):
174 174
 
175 175
 
176 176
 def media_formats_from_node(node):
177  
-    formats = {}
  177
+    formats_count = {}
  178
+    formats_order = []
178 179
     for medium in node.medium:
179 180
         if "format" in medium.children:
180 181
             text = medium.format[0].text
181  
-            formats[text] = formats.get(text, 0) + 1
182  
-    if formats:
183  
-        return " + ".join([
184  
-            (str(j) + u"×" if j > 1 else "") + RELEASE_FORMATS.get(i, i)
185  
-            for i, j in formats.items()])
186  
-    else:
187  
-        return ""
  182
+        else:
  183
+            text = "(unknown)"
  184
+        if text in formats_count:
  185
+            formats_count[text] += 1
  186
+        else:
  187
+            formats_count[text] = 1
  188
+            formats_order.append(text)
  189
+    formats = []
  190
+    for format in formats_order:
  191
+        format = RELEASE_FORMATS.get(format, format)
  192
+        count = formats_count[format]
  193
+        if count > 1:
  194
+            format = str(count) + u"×" + format
  195
+        formats.append(format)
  196
+    return " + ".join(formats)
188 197
 
189 198
 
190 199
 def track_to_metadata(node, track, config):

0 notes on commit 2111508

Please sign in to comment.
Something went wrong with that request. Please try again.