code: def data_size(metadata):
      
      info = metadata['info']
  
      if 'length' in info:
          # Single file
          total_size = info['length']
      else:
          # Directory structure
          total_size = sum([f['length'] for f in info['files']])
  
      return total_size
docs: Calculate the size of a torrent based on parsed metadata.