DrTrigon has submitted this change and it was merged.

Change subject: bugfix; StreamException: cannot get a seconds duration when no 
TempoIndication classes are found in or before this Stream.
......................................................................


bugfix; StreamException: cannot get a seconds duration when no TempoIndication 
classes are found in or before this Stream.

Change-Id: Iebaf9af0789f2de41ef4d55b9907f78e64cbc1f8
---
M catimages.py
1 file changed, 7 insertions(+), 1 deletion(-)

Approvals:
  DrTrigon: Verified; Looks good to me, approved



diff --git a/catimages.py b/catimages.py
index b748658..e00bda0 100644
--- a/catimages.py
+++ b/catimages.py
@@ -3049,6 +3049,8 @@
 
     # midi audio stream/feature extraction, detect streams of notes; parts
     def _detect_Streams(self):
+        import _music21 as music21
+
         # like in '_OggFile' (streams) a nice content listing of MIDI (music21)
         d = self._util_get_DataStreams_MUSIC21()
         if not d:
@@ -3064,12 +3066,16 @@
             #print mm.durationToSeconds(part.duration.quarterLength)
             #print sum([item.seconds for item in stream])    # sum over all 
Note(s)
             #print part.metadata
+            try:
+                duration = part.seconds
+            except music21.stream.StreamException:
+                duration = None
             data.append({'ID':        (i + 1),
                           'Format':    u'(audio/midi)',
                           # note rate / noteduration ...??
                           'Rate':      u'%s/-/-' % d["channels"][i],
                           'Dimension': (None, None),
-                          'Duration':  part.seconds,})
+                          'Duration':  duration,})
 
         self._features['Streams'] = data
         return

-- 
To view, visit https://gerrit.wikimedia.org/r/112235
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Iebaf9af0789f2de41ef4d55b9907f78e64cbc1f8
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: DrTrigon <[email protected]>
Gerrit-Reviewer: DrTrigon <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to