fix(main.py): handle case when skip_channel_default setting is provided and is not None, by loading the specified channel instead of prompting the user for input

feat(main.py): add support for skip_channel_default setting to skip the channel selection prompt and load a specific channel automatically
This commit is contained in:
Paillat
2023-07-22 11:36:53 +02:00
parent 0943f61c0b
commit ea0c6968f5

30
main.py
View File

@@ -87,18 +87,28 @@ async def main():
channel = Channel()
await channel.create()
else:
printm("Here are your channels:")
for i, channel in enumerate(channels):
printm(f"{i+1}. {channel}")
printm(f"{len(channels)+1}. Create a new channel")
index = input("Which channel do you want to use : ")
if index == str(len(channels)+1):
channel = Channel()
await channel.create()
else:
channel_name = channels[int(index)-1]
if settings.skip_channel_default != None:
if type(settings.skip_channel_default) == str:
channel_name = settings.skip_channel_default
elif type(settings.skip_channel_default) == int:
channel_name = channels[settings.skip_channel_default]
else:
raise TypeError("The skip_channel_default setting must be either a string or an integer.")
channel = Channel()
await channel.load(channel_name)
else:
printm("Here are your channels:")
for i, channel in enumerate(channels):
printm(f"{i+1}. {channel}")
printm(f"{len(channels)+1}. Create a new channel")
index = input("Which channel do you want to use : ")
if index == str(len(channels)+1):
channel = Channel()
await channel.create()
else:
channel_name = channels[int(index)-1]
channel = Channel()
await channel.load(channel_name)
printm("Now, let's create a video!")
printm("Here are all the ideas you have:")
printm("0. Generate new ideas")