From 7c6989161c562e3ab4f36425469909788c86b595 Mon Sep 17 00:00:00 2001 From: Paillat Date: Sun, 28 May 2023 11:26:13 +0200 Subject: [PATCH] feat(main.py): add support for existing ideas in the idea selection process --- main.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 39b2e86..7d4d893 100644 --- a/main.py +++ b/main.py @@ -26,15 +26,29 @@ async def main(): input("It looks like it is the first time you are generating ideas for this subject. The requiered folder has been created. Press enter to continue.") input("Please put all the requiered google credentials files in that folder. Press enter to continue.") input("Please put a file called bcg.png in that folder. It will be used as the background of the thumbnails. Press enter to continue.") - if input("Do you want to generate new ideas? (y/n)") == "y": + if input("Do you want to generate new ideas? (y/N): ") == "y": await generate_ideas(subjectdirpath, subject) with open(subjectdirpath + '/ideas.json', 'r', encoding='utf-8') as f: ideas = json.load(f) f.close() - for i in range(len(ideas)): - print(str(i) + ". " + ideas[i]['title']) + existing = [] + new = [] + for i in ideas: + if os.path.exists(subjectdirpath + "/" + i['title'][:25].replace(" ", "_").replace(":", "") + "/script.json"): + existing.append(i) + else: + new.append(i) + print("Existing ideas:") + for i in range(len(existing)): + print(str(i) + ". " + existing[i]['title']) + print("New ideas:") + for i in range(len(new)): + print(str(i + len(existing)) + ". " + new[i]['title']) idea = int(input("Which idea do you want to generate a script for? (enter the number): ")) - idea = ideas[idea] + if idea < len(existing): + idea = existing[idea] + else: + idea = new[idea - len(existing)] title = idea['title'] title = title[:25] i = 0