def parse_header(self, data):
        """ Parse the huge STFS header """
        assert len(data) >= 0x971A, "STFS Data Too Short"
        self.magic = data[0:4]
        if self.magic == "CON ":
            self.console_id = data[6:11]
            self.console_part_number = data[0xB:0x14]
            self.console_type = ord(data[0x1F:0x20]) #0x02 is RETAIL 0x01 is DEVKIT
            self.certificate_date = data[0x20:0x28]
            #Not using the certificate at the moment so this blob has:
            #Exponent, modulus, cert signature, signature
            self.certificate_blob = data[0x28:0x1AC+0x80]
        else:
            self.certificate_blob = data[0x4:0x104]

        self.license_entries = data[0x22C:0x22C:0x100]
        self.content_id = data[0x32C:0x32C+0x14] # Header SHA1 Hash
        self.entry_id = struct.unpack(">I", data[0x340:0x344])[0]
        self.content_type = struct.unpack(">I", data[0x344:0x348])[0]
        self.metadata_version = struct.unpack(">I", data[0x348:0x348+0x4])[0]
        self.content_size = struct.unpack(">Q", data[0x34C:0x34C+0x08])[0]
        self.media_id = struct.unpack(">I", data[0x354:0x354+4])[0]
        self.version = struct.unpack(">I", data[0x358:0x358+4])[0]
        self.base_version = struct.unpack(">I", data[0x35C:0x35C+4])[0]
        self.title_id = struct.unpack(">I", data[0x360:0x360+4])[0]
        self.platform = ord(data[0x364:0x365])
        self.executable_type = ord(data[0x365:0x366])
        self.disc_number = ord(data[0x366:0x367])
        self.disc_in_set = ord(data[0x367:0x368])
        self.save_game_id = struct.unpack(">I", data[0x368:0x368+4])[0]
        if self.magic == "CON ":
            #assert self.console_id == data[0x36C:0x36C+5], "CON Console ID verification failed" 
            pass
        else:
            self.console_id = data[0x36C:0x36C+5]
        self.profile_id = data[0x371:0x376]
        
        self.volume_descriptor_size = ord(data[0x379:0x37A])
        self.block_seperation = ord(data[0x37B])
        self.filetable_blockcount = struct.unpack("<H", data[0x37A+2:0x37A+4])[0] #Little Endian. Why?
        self.filetable_blocknumber = struct.unpack("<I", "%s\x00" % data[0x37A+4:0x37A+7])[0] #Why?!?
        self.tophashtable_hash = data[0x37A+7:0x37A+7+0x14]
        self.allocated_count = struct.unpack(">I", data[0x37A+0x1B:0x37A+0x1B+0x04])[0]
        self.unallocated_count = struct.unpack(">I", data[0x37A+0x1F:0x37A+0x1F+0x4])[0]
        
        self.datafile_count = struct.unpack(">I", data[0x39D:0x39D+0x4])[0]
        self.datafile_size = struct.unpack(">Q", data[0x3A1:0x3A1+8])[0]
        self.device_id = data[0x3FD:0x3FD+0x14]
        
        self.display_name = data[0x411:0x411+0x80] # First locale
        self.display_name_blob = data[0x411:0x411+0x900] # All locales
        self.display_description = data[0xD11:0xD11+0x80] # This offset might be wrong, 1 desc got truncated 
        self.display_description_blob = data[0xD11:0xD11+0x900]
        self.publisher_name = data[0x1611:0x1611+0x80]
        self.title_name = data[0x1691:0x1691+0x80]
        
        self.transfer_flags = data[0x1711:0x1712]
        self.thumbnail_size = struct.unpack(">I", data[0x1712:0x1712+4])[0]
        self.titleimage_size = struct.unpack(">I", data[0x1716:0x1716+4])[0]
        self.thumbnail = data[0x171A:0x171A+self.thumbnail_size]
        self.titleimage = data[0x571A:0x571A+self.titleimage_size]
        
        if self.metadata_version == 2:
            self.series_id = data[0x3B1:0x3B1+0x10]
            self.season_id = data[0x3C1:0x3C1+0x10]
            self.season_number = struct.unpack(">H", data[0x3D1:0x3D1+2])[0]
            self.episode_number = struct.unpack(">H", data[0x3D3:0x3D3+2])[0]
            self.additional_display_names = data[0x541A:0x541A+0x300]
            self.additional_display_descriptions = data[0x941A:0x941A+0x300] 
        
        # Are the hash tables 1 or 2 blocks long?
        if ((self.entry_id + 0xFFF) & 0xF000) >> 0xC == 0xB:
            self.table_size_shift = 0
        else:
            self.table_size_shift = 1
dataset/ETHPy150Open arkem/py360/py360/stfs.py/STFS.parse_header/original