Add the advanced settings section;
Implement the checkboxes for badge and emote mining toggle, and the extra available drops check toggle
This commit is contained in:
1 parent
165f9eccb3
commit
5f54c26f4a
6 files changed
+112
-44
No files matched your search
@@ -1562,7 +1562,7 @@ class Twitch:
|
||||
async def bulk_check_online(self, channels: abc.Iterable[Channel]):
|
||||
"""
|
||||
Utilize batch GQL requests to check ONLINE status for a lot of channels at once.
|
||||
Also handles the drops_enabled check.
|
||||
Also handles the drops_enabled check (if enabled).
|
||||
"""
|
||||
acl_streams_map: dict[int, JsonType] = {}
|
||||
stream_gql_ops: list[GQLOperation] = [channel.stream_gql for channel in channels]
|
||||
@@ -1587,29 +1587,30 @@ class Twitch:
|
||||
task.cancel()
|
||||
raise
|
||||
# for all channels with an active stream, check the available drops as well
|
||||
# acl_available_drops_map: dict[int, list[JsonType]] = {}
|
||||
# available_gql_ops: list[GQLOperation] = [
|
||||
# GQL_OPERATIONS["AvailableDrops"].with_variables({"channelID": str(channel_id)})
|
||||
# for channel_id, channel_data in acl_streams_map.items()
|
||||
# if channel_data["stream"] is not None # only do this for ONLINE channels
|
||||
# ]
|
||||
# available_gql_tasks: list[asyncio.Task[list[JsonType]]] = [
|
||||
# asyncio.create_task(self.gql_request(available_gql_chunk))
|
||||
# for available_gql_chunk in chunk(available_gql_ops, 20)
|
||||
# ]
|
||||
# try:
|
||||
# for coro in asyncio.as_completed(available_gql_tasks):
|
||||
# response_list = await coro
|
||||
# for response_json in response_list:
|
||||
# available_info: JsonType = response_json["data"]["channel"]
|
||||
# acl_available_drops_map[int(available_info["id"])] = (
|
||||
# available_info["viewerDropCampaigns"] or []
|
||||
# )
|
||||
# except Exception:
|
||||
# # asyncio.as_completed doesn't cancel tasks on errors
|
||||
# for task in available_gql_tasks:
|
||||
# task.cancel()
|
||||
# raise
|
||||
acl_available_drops_map: dict[int, list[JsonType]] = {}
|
||||
if self.settings.available_drops_check:
|
||||
available_gql_ops: list[GQLOperation] = [
|
||||
GQL_OPERATIONS["AvailableDrops"].with_variables({"channelID": str(channel_id)})
|
||||
for channel_id, channel_data in acl_streams_map.items()
|
||||
if channel_data["stream"] is not None # only do this for ONLINE channels
|
||||
]
|
||||
available_gql_tasks: list[asyncio.Task[list[JsonType]]] = [
|
||||
asyncio.create_task(self.gql_request(available_gql_chunk))
|
||||
for available_gql_chunk in chunk(available_gql_ops, 20)
|
||||
]
|
||||
try:
|
||||
for coro in asyncio.as_completed(available_gql_tasks):
|
||||
response_list = await coro
|
||||
for response_json in response_list:
|
||||
available_info: JsonType = response_json["data"]["channel"]
|
||||
acl_available_drops_map[int(available_info["id"])] = (
|
||||
available_info["viewerDropCampaigns"] or []
|
||||
)
|
||||
except Exception:
|
||||
# asyncio.as_completed doesn't cancel tasks on errors
|
||||
for task in available_gql_tasks:
|
||||
task.cancel()
|
||||
raise
|
||||
for channel in channels:
|
||||
channel_id = channel.id
|
||||
if channel_id not in acl_streams_map:
|
||||
@@ -1617,6 +1618,5 @@ class Twitch:
|
||||
channel_data = acl_streams_map[channel_id]
|
||||
if channel_data["stream"] is None:
|
||||
continue
|
||||
# available_drops: list[JsonType] = acl_available_drops_map[channel_id]
|
||||
# channel.external_update(channel_data, available_drops)
|
||||
channel.external_update(channel_data, [])
|
||||
available_drops: list[JsonType] = acl_available_drops_map.get(channel_id, [])
|
||||
channel.external_update(channel_data, available_drops)
|
||||
Reference in new issue
Block a user