예제 #1
0
 def add_if_exist(obj, tag_key):
     if obj is None:
         return
     if isinstance(obj, str):
         ape_meta.tags[tag_key] = APEValue(obj, TEXT)
     elif isinstance(obj, bytes):
         ape_meta.tags[tag_key] = APEValue(obj, BINARY)
     else:
         raise ValueError("Unknown tag value type")
예제 #2
0
파일: test_apev2.py 프로젝트: ruipin/picard
 def test_invalid_coverart(self):
     metadata = {
         'Cover Art (Front)': APEValue(b'filename.png\0NOTPNGDATA',
                                       BINARY)
     }
     save_raw(self.filename, metadata)
     loaded_metadata = load_metadata(self.filename)
     self.assertEqual(0, len(loaded_metadata.images))
예제 #3
0
 def test_binary_ignore(self):
     m = mutagen.apev2.APEv2(self.f)
     m["foo"] = APEValue(b"bar", BINARY)
     m.save()
     self.s.reload()
     self.failUnlessEqual(self.s.get("foo"), None)
     self.s.write()
     m = mutagen.apev2.APEv2(self.f)
     self.failUnless("foo" in m)
예제 #4
0
def pic_to_bin(pic):
    desc = pic[util.DESCRIPTION].encode('utf8')
    data = pic[util.DATA]
    covertype = pic[util.IMAGETYPE]

    key = 'Cover Art (Back)' if covertype == 4 else 'Cover Art (Front)'

    if data:
        return {key: APEValue(''.join((desc, '\x00', data)), BINARY)}
    return {}
예제 #5
0
파일: test_apev2.py 프로젝트: ruipin/picard
 def test_clear_tags_preserve_images_all(self):
     imagedata = APEValue(b'filename.png\0' + create_fake_png(b'a'),
                          BINARY)
     save_raw(
         self.filename, {
             'Cover Art (Front)': imagedata,
             'Cover Art': imagedata,
             'Cover Art (foo)': imagedata,
             'cover art (bar)': imagedata,
         })
     config.setting['clear_existing_tags'] = True
     config.setting['preserve_images'] = True
     metadata = save_and_load_metadata(self.filename, Metadata())
     self.assertEqual(4, len(metadata.images))
     config.setting['preserve_images'] = False
     metadata = save_and_load_metadata(self.filename, Metadata())
     self.assertEqual(0, len(metadata.images))