From 0b76e5d6a8d33e64e67438c10cd3d12e622d042b Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sun, 26 Oct 2025 18:07:48 +0500 Subject: feat: add sounds (wip doe) --- sounds/add.php | 190 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 190 insertions(+) create mode 100644 sounds/add.php (limited to 'sounds') diff --git a/sounds/add.php b/sounds/add.php new file mode 100644 index 0000000..9a008de --- /dev/null +++ b/sounds/add.php @@ -0,0 +1,190 @@ +prepare('SELECT id, code + FROM sounds + WHERE id = ? + '); + $stmt->execute([$_GET['id']]); + $sound = $stmt->fetch(PDO::FETCH_ASSOC) ?: null; + + // TODO: check if user has twitch connection + $twitch = $_SESSION['user']['connections'][0]; + + if ($sound) { + $emotes = []; + + if (EMOTE_FETCH_BETTERTTV) { + // fetching channel emotes + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, "https://api.betterttv.net/3/cached/users/twitch/" . $twitch['user_alias_id']); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + + $response = curl_exec($ch); + curl_close($ch); + + // parsing channel emotes + $response = json_decode($response, true); + $bttvemotes = []; + foreach ($response['channelEmotes'] as $e) { + array_push($bttvemotes, [ + 'code' => $e['code'], + 'eid' => 'betterttv:' . $e['id'], + 'url' => 'https://cdn.betterttv.net/emote/' . $e['id'] . '/2x.webp', + 'uploader' => $twitch['user_alias_name'] + ]); + } + foreach ($response['sharedEmotes'] as $e) { + array_push($bttvemotes, [ + 'code' => $e['code'], + 'eid' => 'betterttv:' . $e['id'], + 'url' => 'https://cdn.betterttv.net/emote/' . $e['id'] . '/2x.webp', + 'uploader' => $e['user']['displayName'] + ]); + } + + // fetching global emotes + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, "https://api.betterttv.net/3/cached/emotes/global"); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + + $response = curl_exec($ch); + curl_close($ch); + + // parsing global emotes + $response = json_decode($response, true); + foreach ($response as $e) { + array_push($bttvemotes, [ + 'code' => $e['code'], + 'eid' => 'betterttv:' . $e['id'], + 'url' => 'https://cdn.betterttv.net/emote/' . $e['id'] . '/2x.webp' + ]); + } + + $emotes['BetterTTV'] = $bttvemotes; + } + + if (EMOTE_FETCH_7TV) { + // fetching channel emotes + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, "https://7tv.io/v3/users/twitch/" . $twitch['user_alias_id']); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + + $response = curl_exec($ch); + curl_close($ch); + + // parsing channel emotes + $response = json_decode($response, true); + $stvemotes = []; + foreach ($response['emote_set']['emotes'] as $e) { + array_push($stvemotes, [ + 'code' => $e['name'], + 'eid' => '7tv:' . $e['id'], + 'url' => 'https://cdn.7tv.app/emote/' . $e['id'] . '/2x.webp', + 'uploader' => $e['data']['owner']['display_name'] + ]); + } + + // fetching global emotes + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, "https://7tv.io/v3/emote-sets/global"); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + + $response = curl_exec($ch); + curl_close($ch); + + // parsing global emotes + $response = json_decode($response, true); + foreach ($response['emotes'] as $e) { + array_push($stvemotes, [ + 'code' => $e['name'], + 'eid' => '7tv:' . $e['id'], + 'url' => 'https://cdn.7tv.app/emote/' . $e['id'] . '/2x.webp', + 'uploader' => $e['data']['owner']['display_name'] + ]); + } + + $emotes['7TV'] = $stvemotes; + } + } +} else { + $stmt = $db->prepare('SELECT * FROM sounds ORDER BY uploaded_at DESC'); + $stmt->execute(); + $sounds = $stmt->fetchAll(PDO::FETCH_ASSOC); +} +?> + + + + + Add sound - <?= INSTANCE_NAME ?> + + + + + + +
+
+
+
+

Adding sound -

+
+
+ +
+
+
+
+

Preview

+
+
+

wip

+
+
+
+
+ $pe): ?> +
+
+

+
+
+ + +
+
+ <?= $e['code'] ?> +
+

+ +

by

+ +
+
+ + +

No emotes.

+ +
+
+ +
+
+ + + + + \ No newline at end of file -- cgit v1.2.3