code: def analyze_dir(stats, parent_dir, rel_filepaths, cover_filename, *, ignore_existing=False):
    
    no_metadata = None, None, None
    metadata = no_metadata
    audio_filepaths = []
    for rel_filepath in rel_filepaths:
      stats["files"] += 1
      try:
        ext = os.path.splitext(rel_filepath)[1][1:].lower()
      except IndexError:
        continue
      if ext in AUDIO_EXTENSIONS:
        audio_filepaths.append(os.path.join(parent_dir, rel_filepath))
    if audio_filepaths:
      stats["albums"] += 1
      if (cover_filename != EMBEDDED_ALBUM_ART_SYMBOL):
        missing = (not os.path.isfile(os.path.join(parent_dir, cover_filename))) or ignore_existing
        if missing:
          metadata = get_metadata(audio_filepaths)
      else:
        metadata = get_metadata(audio_filepaths)
        missing = (not metadata[2]) or ignore_existing
      if missing:
        stats["missing covers"] += 1
        if not all(metadata[:-1]):
          # failed to get metadata for this album
          stats["errors"] += 1
          logging.getLogger("sacad_r").error("Unable to read metadata for album directory '%s'" % (parent_dir))
      else:
        metadata = no_metadata
    return metadata
docs: Analyze a directory (non recursively) to get its album metadata if it is one.