import requests import time emotesetidtocopyfrom = "01FWY8TYBR000ASC1GQNZR3GSV"…
- User
import requests import time
emote_set_id_to_copy_from = "01FWY8TYBR000ASC1GQNZR3GSV" emote_sets_to_copy_to = { # target : Bearer token "01JD0JR2KJH1GR96Z7H873V7ZB": "y175nd8hua7fic7udz4m7y6ibs7c1oeyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiI3dHYuaW8iLCJzdWIiOiIwMUpDWkNYSjJSMkhIOFlURVA1Wk1OMFlXTiIsImV4cCI6MTczNDU1NzE4NiwiaWF0IjoxNzMxOTY1MTg2LCJqdGkiOiIwMUpEMEpQVlpaUFlOUERBRUQ2MDhIR1JISyJ9.a2Qky0zWcxwopTMf3aAoFlzWHvQNNr0MEwAZ9hKYQ8E" }
def get_emote_set(emote_set_id): r = requests.get(f"https://7tv.io/v3/emote-sets/{emote_set_id}") if r.status_code != 200: print("Error getting desired emote set") return [] return r.json().get("emotes", [])
def get_copy_emotes(): emotes = get_emote_set(emote_set_id_to_copy_from) for k, v in emote_sets_to_copy_to.items(): headers = {"Authorization": f"Bearer {v}"} chunk = []
for e in emotes: entry = { "operationName": "ChangeEmoteInSet", "variables": {"action": "ADD", "id": k, "emote_id": e["id"], "name": e["name"]}, "query": "mutation ChangeEmoteInSet($id: ObjectID!, $action: ListItemAction!, $emote_id: ObjectID!, $name: String) {\n emoteSet(id: $id) {\n id\n emotes(id: $emote_id, action: $action, name: $name) {\n id\n name\n __typename\n }\n __typename\n }\n}" } chunk.append(entry) # Send the chunk if it has reached 30 entries or is the last emote if len(chunk) == 10 or e == emotes[-1]: response = requests.post("https://7tv.io/v3/gql", json=chunk, headers=headers) if response.status_code != 200: print(f"Error posting emote chunk: {response.status_code}") else: print(f"Posted emote chunk: {chunk}") chunk = [] # Reset chunk for the next batch time.sleep(10) # Delay between requests in secondsdef main(): start = time.time() get_copy_emotes() print(f"Completed in {time.time() - start} seconds")
if name == "main": main()
fix my code
- Assistant