aboutsummaryrefslogtreecommitdiff
path: root/cmd/_old/sanguisuga/sanguisuga.templ
blob: 55833bbc5130a70d898cfa63884a8ea18fcf7848 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
package main

templ base(title string, body templ.Component) {
	<!DOCTYPE html>
	<html lang="en">
		<head>
			<meta charset="UTF-8"/>
			<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
			<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
			<link rel="stylesheet" href="https://cdn.xeiaso.net/static/pkg/iosevka/family.css"/>
			<link rel="stylesheet" href="/static/styles.css"/>
			<title>{ title }</title>
			<style>
        [x-cloak] {
            display: none
        }
    </style>
			<script src="/static/alpine.js" defer></script>
		</head>
		<body class="flex items-start justify-center h-full bg-gray-50">
			<div class="w-full max-w-4xl px-2">
				<nav class="my-4">
					<a class="font-semibold underline text-gray-900 hover:text-gray-500" href="/">sanguisuga</a> - <a
	class="font-semibold underline text-gray-900 hover:text-gray-500"
	href="/anime"
>Anime</a> - <a
	href="/tv"
	class="font-semibold underline text-gray-900 hover:text-gray-500"
	href="/tv"
>TV</a>
				</nav>
				<h1 class="mb-2 mt-0 text-3xl font-medium leading-tight text-primary">
					{ title }
				</h1>
				@body
				<footer class="mt-2 bg-neutral-200 text-center dark:bg-neutral-700 lg:text-left">
					<div class="p-4 text-neutral-700 dark:text-neutral-200">
						From <a class="text-neutral-800 dark:text-neutral-400" href="https://within.website">Within</a>.
					</div>
				</footer>
			</div>
		</body>
	</html>
}

templ notFoundPage() {
	<p class="my-4">If you expected to find a page here, this ain't it chief. Try <a href="/">going home</a>.</p>
}

templ indexPage() {
	<p class="mt-4 max-w-xl">
		Welcome to sanguisuga. This is a tool that will help you leech content from private trackers
		and XDCC bots. The following options are available:
	</p>
	<ul class="list-disc list-inside mt-4">
		<li><a class="font-semibold underline text-gray-900 hover:text-gray-500" href="/anime">Anime</a></li>
		<li><a class="font-semibold underline text-gray-900 hover:text-gray-500" href="/tv">TV</a> (western TV)</li>
	</ul>
	<p class="my-4 max-w-xl">Thank you for following the development of sanguisuga.</p>
}

templ animePage() {
	<h2 class="my-4 text-2xl font-medium leading-tight text-primary">Shows</h2>
	<div x-data="{ shows: [] }" x-init="shows = await (await fetch('/api/anime/list')).json()">
		<table class="border-collapse w-full border border-slate-400 bg-white text-sm shadow-sm">
			<thead class="bg-slate-50">
				<tr>
					<th class="w-1/2 border border-slate-300 font-semibold p-4 text-slate-900 text-left">Title</th>
					<th class="w-1/2 border border-slate-300 font-semibold p-4 text-slate-900 text-left">Disk Path</th>
					<th class="w-1/2 border border-slate-300 font-semibold p-4 text-slate-900 text-left"></th>
				</tr>
			</thead>
			<template x-for="show in shows">
				<tr>
					<td class="border border-slate-300 p-4 text-slate-500" x-text="show.title"></td>
					<td class="border border-slate-300 p-4 text-slate-500"><code x-text="show.diskPath"></code></td>
					<td class="border border-slate-300 p-4 text-slate-500">
						<button
							class="bg-gray-700 hover:bg-gray-800 disabled:opacity-50 text-white p-2"
							@click="(e) => {
                            fetch('/api/anime/untrack', {
                                method: 'POST',
                                body: JSON.stringify(show),
                            })
                                .then(() => e.target.parentElement.parentElement.remove())
                                .catch((e) => alert(e))
                            }"
						>🗑️</button>
					</td>
				</tr>
			</template>
		</table>
	</div>
	<h2 class="my-4 text-2xl font-medium leading-tight text-primary">Downloads</h2>
	<div x-data="{ open: false }">
		<button
			class="bg-gray-700 hover:bg-gray-800 disabled:opacity-50 text-white p-2 mb-2"
			@click="open = ! open"
		>Show</button>
		<div
			class="bg-neutral-300 p-2"
			x-show="open"
			x-show="open"
			x-transition:enter="transition ease-out duration-300"
			x-transition:leave="transition ease-in duration-300"
		>
			<p class="mb-4">{ "Every one of these files is saved in the snatchlist and should be available on Plex. If a file is not available, you may need to check if someone put RAR files in a torrent. Again." }</p>
			<div x-data="{ downloads: {} }" x-init="downloads = await (await fetch('/api/anime/snatches')).json()">
				<table class="border-collapse w-full border border-slate-400 bg-white text-sm shadow-sm">
					<thead class="bg-slate-50">
						<tr>
							<th class="w-1/2 border border-slate-300 font-semibold p-4 text-slate-900 text-left">Show</th>
							<th class="w-1/2 border border-slate-300 font-semibold p-4 text-slate-900 text-left">
								Episode
							</th>
							<th class="w-1/2 border border-slate-300 font-semibold p-4 text-slate-900 text-left">Method</th>
						</tr>
					</thead>
					<template x-for="download in Object.values(downloads)">
						<tr>
							<td class="border border-slate-300 p-4 text-slate-500" x-text="download.showName"></td>
							<td class="border border-slate-300 p-4 text-slate-500" x-text="download.episode"></td>
							<td class="border border-slate-300 p-4 text-slate-500">DCC</td>
						</tr>
					</template>
				</table>
			</div>
		</div>
	</div>
	<h2 class="my-4 text-2xl font-medium leading-tight text-primary">Track new show</h2>
	<script>
    function trackForm() {
        return {
            formData: {
                title: "",
                diskPath: "/data/TV/",
                quality: "1080p",
            },
            message: '',
            buttonLabel: "Submit",

            submitData() {
                this.message = ''

                fetch('/api/anime/track', {
                    method: 'POST',
                    headers: { 'Content-Type': 'application/json' },
                    body: JSON.stringify(this.formData),
                })
                    .then(() => {
                        this.message = `Tracking ${this.formData.title}.`;
                    })
                    .catch((e) => {
                        this.message = `error: ${e}`;
                    });
            }
        }
    }
</script>
	<div class="w-64 my-4" x-data="trackForm()">
		<div class="mb-4">
			<label class="block mb-2">Title:</label>
			<input type="text" name="title" class="border w-full p-1" x-model="formData.title"/>
		</div>
		<div class="mb-4">
			<label class="block mb-2">Disk Path:</label>
			<input type="text" name="diskPath" class="border w-full p-1" value="/data/TV/" x-model="formData.diskPath"/>
		</div>
		<button
			class="bg-gray-700 hover:bg-gray-800 disabled:opacity-50 text-white w-full p-2"
			x-text="buttonLabel"
			@click="submitData"
		></button>
		<p x-text="message"></p>
	</div>
}

templ tvPage() {
	<h2 class="my-4 text-2xl font-medium leading-tight text-primary">Shows</h2>
	<div
		x-data="{ shows: [] }"
		x-init="shows = await (await fetch('/api/tv/list')).json()"
	>
		<table
			class="border-collapse w-full border border-slate-400 bg-white text-sm shadow-sm"
		>
			<thead class="bg-slate-50">
				<tr>
					<th
						class="w-1/2 border border-slate-300 font-semibold p-4 text-slate-900 text-left"
					>
						Title
					</th>
					<th
						class="w-1/2 border border-slate-300 font-semibold p-4 text-slate-900 text-left"
					>
						Disk Path
					</th>
					<th
						class="w-1/2 border border-slate-300 font-semibold p-4 text-slate-900 text-left"
					></th>
				</tr>
			</thead>
			<template x-for="show in shows">
				<tr>
					<td
						class="border border-slate-300 p-4 text-slate-500"
						x-text="show.title"
					></td>
					<td class="border border-slate-300 p-4 text-slate-500">
						<code x-text="show.diskPath"></code>
					</td>
					<td class="border border-slate-300 p-4 text-slate-500">
						<button
							class="bg-gray-700 hover:bg-gray-800 disabled:opacity-50 text-white p-2"
							@click="(e) => {
                            fetch('/api/tv/untrack', {
                                method: 'POST',
                                body: JSON.stringify(show),
                            })
                                .then(() => e.target.parentElement.parentElement.remove())
                                .catch((e) => alert(e))
                            }"
						>
							🗑️
						</button>
					</td>
				</tr>
			</template>
		</table>
	</div>
	<h2 class="my-4 text-2xl font-medium leading-tight text-primary">Downloads</h2>
	<div x-data="{ open: false }">
		<button
			class="bg-gray-700 hover:bg-gray-800 disabled:opacity-50 text-white p-2 mb-2"
			@click="open = ! open"
		>
			Show
		</button>
		<div
			class="bg-neutral-300 p-2"
			x-show="open"
			x-show="open"
			x-transition:enter="transition ease-out duration-300"
			x-transition:leave="transition ease-in duration-300"
		>
			<p class="mb-4">
				{ "Every one of these files is saved in the snatchlist and should be available on Plex. If a file is not available, you may need to check if someone put RAR files in a torrent. Again." }
			</p>
			<div
				x-data="{ downloads: {} }"
				x-init="downloads = await (await fetch('/api/tv/snatches')).json()"
			>
				<table
					class="border-collapse w-full border border-slate-400 bg-white text-sm shadow-sm"
				>
					<thead class="bg-slate-50">
						<tr>
							<th
								class="w-1/2 border border-slate-300 font-semibold p-4 text-slate-900 text-left"
							>
								Show + Episode
							</th>
							<th
								class="w-1/2 border border-slate-300 font-semibold p-4 text-slate-900 text-left"
							>
								Torrent Link
							</th>
						</tr>
					</thead>
					<template x-for="download in Object.keys(downloads)">
						<tr>
							<td
								class="border border-slate-300 p-4 text-slate-500 mx-auto"
								x-text="download"
							></td>
							<td
								class="border border-slate-300 p-4 text-slate-500"
								x-html="() => `<a href='https://www.torrentleech.org/torrent/${downloads[download].TorrentID}' target='_blank'>🔗</a>`"
							></td>
						</tr>
					</template>
				</table>
			</div>
		</div>
	</div>
	<h2 class="my-4 text-2xl font-medium leading-tight text-primary">
		Track new show
	</h2>
	<script>
  function trackForm() {
    return {
      formData: {
        title: "",
        diskPath: "/data/TV/",
        quality: "1080p",
      },
      message: "",
      buttonLabel: "Submit",

      submitData() {
        this.message = "";

        fetch("/api/tv/track", {
          method: "POST",
          headers: { "Content-Type": "application/json" },
          body: JSON.stringify(this.formData),
        })
          .then(() => {
            this.message = `Tracking ${this.formData.title}.`;
          })
          .catch((e) => {
            this.message = `error: ${e}`;
          });
      },
    };
  }
</script>
	<div class="w-64 my-4" x-data="trackForm()">
		<div class="mb-4">
			<label class="block mb-2">Title:</label>
			<input
				type="text"
				name="title"
				class="border w-full p-1"
				x-model="formData.title"
			/>
		</div>
		<div class="mb-4">
			<label class="block mb-2">Disk Path:</label>
			<input
				type="text"
				name="diskPath"
				class="border w-full p-1"
				value="/data/TV/"
				x-model="formData.diskPath"
			/>
		</div>
		<button
			class="bg-gray-700 hover:bg-gray-800 disabled:opacity-50 text-white w-full p-2"
			x-text="buttonLabel"
			@click="submitData"
		></button>
		<p x-text="message"></p>
	</div>
}