def write_tags(filename, tags): """ Writes ID3 tags to a JSON file. :param filename: The input audio file name :param tags: The list of ID3 tags written to the audio file """ with open(update_extension(filename, ".json"), "w") as tags_file: dump(tags, tags_file, indent=4)
def read_tags(filename): """ Reads a JSON file with ID3 tags. :param filename: The input audio file name :return: The name of the ID3 tags file """ try: with open(update_extension(filename, ".json"), "r") as tags_file: tags = load(tags_file) except FileNotFoundError: return None return tags