Commits

Anonymous committed c794b89

* Metadata MKV: skip negative duration
* Metadata ID3: convert tag to Unicode if needed

  • Participants
  • Parent commits 1a51bcb

Comments (0)

Files changed (2)

File hachoir-metadata/hachoir_metadata/audio.py

 from hachoir_parser.container import OggFile, RealMediaFile
 from hachoir_core.i18n import _
 from hachoir_core.error import warning
+from hachoir_core.tools import makePrintable
 
 class OggMetadata(MultipleMetadata):
     key_to_attr = {
         tag = field["tag"].value
         if tag not in self.tag_to_key:
             if tag:
+                if isinstance(tag, str):
+                    tag = makePrintable(tag, "ISO-8859-1", to_unicode=True)
                 warning("Skip ID3v2 tag %s: %s" % (tag, value))
             return
         setattr(self, self.tag_to_key[tag], value)

File hachoir-metadata/hachoir_metadata/video.py

         setattr(self, key, value)
 
     def processInfo(self, info):
-        if "Duration/float" in info and "TimecodeScale/unsigned" in info:
-            self.duration = (info["Duration/float"].value * info["TimecodeScale/unsigned"].value) / 1000000
+        if "Duration/float" in info \
+        and "TimecodeScale/unsigned" in info \
+        and 0 < info["Duration/float"].value:
+            self.duration = (info["Duration/float"].value * info["TimecodeScale/unsigned"].value) // 1000000
         if "DateUTC/date" in info:
             self.creation_date = info["DateUTC/date"].display
         if "WritingApp/unicode" in info: