diff --git a/iSponsorBlockTV/api_helpers.py b/iSponsorBlockTV/api_helpers.py index 6f7f5a1..81d06ce 100644 --- a/iSponsorBlockTV/api_helpers.py +++ b/iSponsorBlockTV/api_helpers.py @@ -57,7 +57,7 @@ async def search_channels(channel, api_key, web_session): else: subCount = channelData["items"][0]["statistics"]["subscriberCount"] - channel.append((i["snippet"]["channelId"], i["snippet"]["channelTitle"], subCount)) + channels.append((i["snippet"]["channelId"], i["snippet"]["channelTitle"], subCount)) return channels diff --git a/iSponsorBlockTV/config_setup.py b/iSponsorBlockTV/config_setup.py index c0a8749..ece5ed5 100644 --- a/iSponsorBlockTV/config_setup.py +++ b/iSponsorBlockTV/config_setup.py @@ -125,11 +125,13 @@ def main(config, config_file, debug): web_session = aiohttp.ClientSession() while True: channel_info = {} - channel = input("Enter a channel name or \"/exit to exit\": ") + 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)) + task = loop.create_task(api_helpers.search_channels(channel, apikey, web_session)) + loop.run_until_complete(task) + results = task.result() if len(results) == 0: print("No channels found") continue @@ -156,6 +158,8 @@ def main(config, config_file, debug): channel_info["id"] = results[int(choice)][0] channel_info["name"] = results[int(choice)][1] channel_whitelist.append(channel_info) + # Close web session asynchronously + loop.run_until_complete(web_session.close()) config["channel_whitelist"] = channel_whitelist diff --git a/iSponsorBlockTV/main.py b/iSponsorBlockTV/main.py index dd09c69..439716c 100644 --- a/iSponsorBlockTV/main.py +++ b/iSponsorBlockTV/main.py @@ -63,8 +63,9 @@ async def process_playstatus( print(f"ID: {vid_id[0]}, Channel ID: {vid_id[1]}") for i in whitelist: if vid_id[1] == i["id"]: + print("Channel whitelisted, skipping.") return - segments = await api_helpers.get_segments(vid_id, web_session, categories) + segments = await api_helpers.get_segments(vid_id[0], web_session, categories) print(segments) await time_to_segment( segments, playstatus.position, rc, time_start, web_session