Last active 1633467305

A script to download all twitch emotes for a given channel. pipe to bash or something idk

twitch_emotes.py Raw
1#!/usr/bin/env python3
2import requests
3from bs4 import BeautifulSoup as Soup
4from sys import argv
5
6headers = {
7'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:92.0) Gecko/20100101 Firefox/92.0' ,
8'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' ,
9'Accept-Language': 'en-US,en;q=0.5',
10'Content-Type': 'application/x-www-form-urlencoded' ,
11'Origin': 'https://twitchemotes.com' ,
12'Alt-Used': 'twitchemotes.com' ,
13'Connection': 'keep-alive' ,
14'Referer': 'https://twitchemotes.com/channels/8683614' ,
15'Upgrade-Insecure-Requests': '1' ,
16'Sec-Fetch-Dest': 'document' ,
17'Sec-Fetch-Mode': 'navigate' ,
18'Sec-Fetch-Site': 'same-origin' ,
19'Sec-Fetch-User': '?1' ,
20'TE': 'trailers'
21}
22
23channel = argv[1] if len(argv) > 1 else 'zfg1'
24channel_page = requests.post("https://twitchemotes.com/search/channel", data={"query": channel, "source": "nav-bar"}, headers=headers).text
25soup = Soup(channel_page, "html.parser")
26
27print(f"mkdir {channel}")
28for img in soup.find_all("img", {"class": "emote"}):
29 print(f"curl {img['src']} -o {channel}/{img['data-regex']}.png")