Exemplo n.º 1
0
			def __read_metadata_block(self, file):
				byte = ord(file.read(1))
				size = to_int_be(file.read(3))
				try:
						data = file.read(size)
						if len(data) != size:
								raise error(
										"file said %d bytes, read %d bytes" % (size, len(data)))
						block = self.METADATA_BLOCKS[byte & 0x7F](data)
				except (IndexError, TypeError):
						block = MetadataBlock(data)
						block.code = byte & 0x7F
						self.metadata_blocks.append(block)
				else:
						self.metadata_blocks.append(block)
						if block.code == VCFLACDict.code:
								if self.tags is None: self.tags = block
								else: raise FLACVorbisError("> 1 Vorbis comment block found")
						elif block.code == CueSheet.code:
								if self.cuesheet is None: self.cuesheet = block
								else: raise error("> 1 CueSheet block found")
						elif block.code == SeekTable.code:
								if self.seektable is None: self.seektable = block
								else: raise error("> 1 SeekTable block found")
				return (byte >> 7) ^ 1
Exemplo n.º 2
0
 def __read_metadata_block(self, file):
     byte = ord(file.read(1))
     size = to_int_be(file.read(3))
     try:
         data = file.read(size)
         if len(data) != size:
             raise Exception("file said %d bytes, read %d bytes" % (size, len(data)))
             block = self.METADATA_BLOCKS[byte & 0x7F](data)
     except (IndexError, TypeError):
         block = MetadataBlock(data)
         block.code = byte & 0x7F
         self.metadata_blocks.append(block)
     else:
         self.metadata_blocks.append(block)
         if block.code == VCFLACDict.code:
             if self.tags is None:
                 self.tags = block
             else:
                 raise FLACVorbisError("> 1 Vorbis comment block found")
         elif block.code == CueSheet.code:
             if self.cuesheet is None:
                 self.cuesheet = block
             else:
                 raise Exception("> 1 CueSheet block found")
         elif block.code == SeekTable.code:
             if self.seektable is None:
                 self.seektable = block
             else:
                 raise Exception("> 1 SeekTable block found")
     return (byte >> 7) ^ 1
Exemplo n.º 3
0
 def test_save_unknown_block(self):
     block = MetadataBlock("test block data")
     block.code = 99
     self.flac.metadata_blocks.append(block)
     self.flac.save()
Exemplo n.º 4
0
 def test_save_unknown_block(self):
     block = MetadataBlock(b"test block data")
     block.code = 99
     self.flac.metadata_blocks.append(block)
     self.flac.save()