import { Urls, bttvData, ffzData } from "../../../types/scraping/emotes" interface Emote { name: string urls: Urls } export const ffzEmotesHandler = (emoteData: ffzData) => { const sets = emoteData.sets[emoteData.room.set] const emotes: Emote[] = [] for (let emote of sets.emoticons) { const data: Emote = { name: emote.name, urls: emote.urls } emotes.push(data) } return emotes } const generateBttvEmoteUrls = (id: string) => { const bttvApi = 'https://cdn.betterttv.net/emote/' const urls: Urls = {} // Creates urls like "https://cdn.betterttv.net/emote/6368b11b9013520589f5ac0c/3x" from 1x to 3x for (let i = 1; i < 4; i++) { urls[i] = `${bttvApi}${id}/${i}x` } return urls } export const bttvEmotesHandler = (emoteData: bttvData) => { const rawEmoteArray = emoteData console.log(emoteData.length) const emotes: Emote[] = [] for (let rawEmote of rawEmoteArray) { const formattedEmote: Emote = { name: rawEmote.code, urls: generateBttvEmoteUrls(rawEmote.id) } emotes.push(formattedEmote) } console.log(emotes.length) console.log(emotes) return emotes }