Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing write logic for get_metadata.py #54

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions scripts/get_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ def write_show_metadata(output_file, dict_data):
raise ValueError("Provide dict_data parameter!")
if len(dict_data.keys()) == 0:
raise ValueError('Provide a valid dictionary data to write to the output file!')
with open(output_file, 'w', encoding="utf-8") as (outfile, error):
if error:
raise IOError(error)
with open(output_file, 'r+', encoding="utf-8") as outfile:
json.dump(dict_data, outfile, sort_keys=True, indent=2)

def _format_episode_metadata(episode_metadata):
Expand Down Expand Up @@ -158,6 +156,6 @@ def write_episode_metadata(output_file, episodes_data):

if __name__ == "__main__":
data = get_show_metadata(IMDB_GOT_ID)
write_show_metadata('./thronetalk-game-of-thrones-summarizer/data/show_metadata.json', data)
write_show_metadata('thronetalk-game-of-thrones-summarizer/data/show_metadata.json', data)
episodes_metadata = get_episode_metadata()
write_episode_metadata('./thronetalk-game-of-thrones-summarizer/data/episodes_metadata.csv', episodes_metadata)
write_episode_metadata('thronetalk-game-of-thrones-summarizer/data/episodes_metadata.csv', episodes_metadata)
Loading