From 0c6fbd9b1afe8e5967a127bffa68570ee88bfe92 Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.me>
Date: Sun, 22 Oct 2023 14:03:08 -0700
Subject: feat(tools): episode discussion collector

---
 src/lib/Tools/EpisodeDiscussionCollector.svelte | 44 +++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 src/lib/Tools/EpisodeDiscussionCollector.svelte

(limited to 'src/lib/Tools/EpisodeDiscussionCollector.svelte')

diff --git a/src/lib/Tools/EpisodeDiscussionCollector.svelte b/src/lib/Tools/EpisodeDiscussionCollector.svelte
new file mode 100644
index 00000000..a9acd8ae
--- /dev/null
+++ b/src/lib/Tools/EpisodeDiscussionCollector.svelte
@@ -0,0 +1,44 @@
+<script lang="ts">
+	import { threads } from '$lib/AniList/forum';
+
+	let searchInput = '';
+	let searchInputFinal = '';
+</script>
+
+<p>
+	<input type="text" placeholder="Username" bind:value={searchInput} />
+	<a href={`#`} on:click={() => (searchInputFinal = searchInput)}>Search</a>
+</p>
+
+{#if searchInputFinal !== ''}
+	{#await threads(searchInputFinal)}
+		Loading ...
+	{:then threads}
+		<ul>
+			{#each threads
+				.filter((thread) => thread.title.includes('[Spoilers]') && thread.title.includes('Episode'))
+				.sort((a, b) => b.createdAt - a.createdAt) as thread}
+				<li>
+					<a href={`https://anilist.co/forum/thread/${thread.id}`} target="_blank">
+						{thread.title.replace('[Spoilers]', '')}
+					</a>
+				</li>
+			{/each}
+		</ul>
+	{:catch}
+		<p>
+			Threads could not be loaded. You might have been <a
+				href="https://en.wikipedia.org/wiki/Rate_limiting"
+				target="_blank">rate limited</a
+			>.
+		</p>
+		<p>
+			Try again in a few minutes. If the problem persists, please contact <a
+				href="https://anilist.co/user/fuwn"
+				target="_blank">@fuwn</a
+			> on AniList.
+		</p>
+	{/await}
+{:else}
+	<p>Enter a username to search for to continue.</p>
+{/if}
-- 
cgit v1.2.3

