diff --git a/iSponsorBlockTV/config_setup.py b/iSponsorBlockTV/config_setup.py index e462230..c0a8749 100644 --- a/iSponsorBlockTV/config_setup.py +++ b/iSponsorBlockTV/config_setup.py @@ -121,42 +121,41 @@ def main(config, config_file, debug): except: channel_whitelist = [] - if channel_whitelist != []: - if input("Do you want to whitelist any channels from being ad-blocked? (y/n) ") == "y": - web_session = aiohttp.ClientSession() - while True: - channel_info = {} - channel = input("Enter a channel name or \"/exit to exit\": ") - if channel == "/exit": - break + if input("Do you want to whitelist any channels from being ad-blocked? (y/n) ") == "y": + web_session = aiohttp.ClientSession() + while True: + channel_info = {} + channel = input("Enter a channel name or \"/exit to exit\": ") + if channel == "/exit": + break - results = asyncio.run(api_helpers.search_channels(channel, apikey, web_session)) - if len(results) == 0: - print("No channels found") - continue - - for i in range(len(results)): - print(f"{i}: {results[i][1]} - Subs: {results[i][2]}") - print("5: Enter a custom channel ID") - print("6: Go back") + results = asyncio.run(api_helpers.search_channels(channel, apikey, web_session)) + if len(results) == 0: + print("No channels found") + continue + + for i in range(len(results)): + print(f"{i}: {results[i][1]} - Subs: {results[i][2]}") + print("5: Enter a custom channel ID") + print("6: Go back") - choice = -1 + choice = -1 + choice = input("Select one option of the above [0-6]: ") + while choice not in [str(x) for x in range(7)]: + print("Invalid choice") choice = input("Select one option of the above [0-6]: ") - while choice not in [str(x) for x in range(7)]: - print("Invalid choice") - choice = input("Select one option of the above [0-6]: ") - if choice == "5": - channel_info["id"] = input("Enter a channel ID: ") - channel_info["name"] = input("Enter the channel name: ") - channel_whitelist.append(channel_info) - continue - elif choice == "6": - continue - - channel_info["id"] = results[int(choice)][0] - channel_info["name"] = results[int(choice)][1] + if choice == "5": + channel_info["id"] = input("Enter a channel ID: ") + channel_info["name"] = input("Enter the channel name: ") channel_whitelist.append(channel_info) + continue + elif choice == "6": + continue + + channel_info["id"] = results[int(choice)][0] + channel_info["name"] = results[int(choice)][1] + channel_whitelist.append(channel_info) config["channel_whitelist"] = channel_whitelist