Fix (#9): don't clobber max/keep in show info file

Change: dump config file when existing file misses one or more settings
This commit is contained in:
Frank de Lange 2022-03-02 21:01:37 +00:00
parent e329c25d2c
commit 140cf50a47
3 changed files with 10 additions and 7 deletions

View file

@ -103,6 +103,7 @@ class Config:
for key in CONFIG_VALUES: for key in CONFIG_VALUES:
if key not in cls.Values: if key not in cls.Values:
cls.Values[key] = cls.parse_arg_value(key, CONFIG_VALUES[key]['default']) cls.Values[key] = cls.parse_arg_value(key, CONFIG_VALUES[key]['default'])
dump_config=True
# Override config from commandline arguments # Override config from commandline arguments

View file

@ -189,12 +189,14 @@ def download_episode(episode_id) -> None:
show_index_file_name = os.path.join(show_directory, f"{RSS_FEED_SHOW_INDEX}.{RSS_FEED_INFO_EXTENSION}") show_index_file_name = os.path.join(show_directory, f"{RSS_FEED_SHOW_INDEX}.{RSS_FEED_INFO_EXTENSION}")
if not os.path.isfile(show_index_file_name) or int(get_index_version(show_index_file_name)) < Spodcast.CONFIG.get_version_int(): if not os.path.isfile(show_index_file_name) or int(get_index_version(show_index_file_name)) < Spodcast.CONFIG.get_version_int():
podcast_name, link, description, image = get_info(episode_id, "show") podcast_name, link, description, image = get_info(episode_id, "show")
show_info = { show_info = {}
"version": str(RSS_FEED_VERSION + Spodcast.CONFIG.get_version_str()), if os.path.isfile(show_index_file_name):
"title": escape(podcast_name), show_info = json_load(show_index_file_name)
"link": link, show_info["version"] = str(RSS_FEED_VERSION + Spodcast.CONFIG.get_version_str())
"description": escape(description), show_info["title"] = escape(podcast_name)
"image": RSS_FEED_SHOW_IMAGE } show_info["link"] = link
show_info["description"] = escape(description)
show_info["image"] = RSS_FEED_SHOW_IMAGE
show_index_file = open(show_index_file_name, "w") show_index_file = open(show_index_file_name, "w")
show_index_file.write(json.dumps(show_info)) show_index_file.write(json.dumps(show_info))
show_index_file.close() show_index_file.close()