-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
684 lines (609 loc) · 34.7 KB
/
Copy pathindex.html
File metadata and controls
684 lines (609 loc) · 34.7 KB
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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HarryPotterArchiv</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<style>
:root {
--spotify-green: #1DB954;
--spotify-black: #121212;
--spotify-dark-grey: #181818;
--spotify-light-grey: #282828;
--spotify-text: #b3b3b3;
}
body {
background-color: var(--spotify-black);
color: white;
font-family: 'Inter', sans-serif;
margin: 0;
overflow: hidden;
height: 100vh;
}
/* Sidebar Logic */
.sidebar {
background-color: black;
width: 280px;
transition: transform 0.3s ease;
z-index: 100;
display: flex;
flex-direction: column;
}
@media (max-width: 768px) {
.sidebar {
position: fixed;
top: 0;
left: 0;
bottom: 0;
transform: translateX(-100%);
width: 85%;
max-width: 300px;
}
.sidebar.open {
transform: translateX(0);
}
}
.main-content {
background: linear-gradient(to bottom, #222222 0%, var(--spotify-black) 40%);
flex: 1;
overflow-y: auto;
position: relative;
}
.player-bar {
background-color: var(--spotify-dark-grey);
border-top: 1px solid #282828;
padding: 12px 16px;
z-index: 80;
position: relative;
}
.book-card {
background-color: var(--spotify-dark-grey);
transition: background-color 0.3s ease, transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
cursor: pointer;
}
.book-card:hover {
background-color: var(--spotify-light-grey);
transform: translateY(-8px);
}
.track-row {
display: grid;
grid-template-columns: 30px 1fr 50px;
align-items: center;
padding: 12px 16px;
border-radius: 4px;
transition: background-color 0.2s;
cursor: pointer;
}
@media (min-width: 640px) {
.track-row {
grid-template-columns: 40px 1fr 100px;
}
}
.track-row:hover {
background-color: rgba(255, 255, 255, 0.1);
}
.track-row.active {
color: var(--spotify-green);
}
.progress-bar-container {
height: 4px;
background-color: #4f4f4f;
border-radius: 2px;
width: 100%;
cursor: pointer;
position: relative;
}
.progress-bar-fill {
height: 100%;
background-color: white;
border-radius: 2px;
transition: background-color 0.1s;
}
.progress-bar-container:hover .progress-bar-fill {
background-color: var(--spotify-green);
}
.view-transition {
transition: opacity 0.6s cubic-bezier(0.23, 1, 0.32, 1), transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
will-change: opacity, transform;
}
.fade-out {
opacity: 0 !important;
transform: translateY(20px) scale(0.98);
pointer-events: none;
}
.fade-in {
opacity: 1 !important;
transform: translateY(0) scale(1);
pointer-events: auto;
}
.custom-scrollbar::-webkit-scrollbar {
width: 8px;
}
.custom-scrollbar::-webkit-scrollbar-track {
background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
background: rgba(255, 255, 255, 0.2);
border-radius: 4px;
}
.loading-overlay {
display: none;
position: fixed;
inset: 0;
background: rgba(0,0,0,0.9);
z-index: 200;
place-items: center;
}
.btn-play-hero {
background-color: var(--spotify-green);
color: black;
width: 56px;
height: 56px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color 0.1s;
}
.btn-play-hero:hover {
transform: scale(1.1);
background-color: #1ed760;
}
#dlProgressBox {
position: fixed;
bottom: 180px;
left: 50%;
transform: translateX(-50%);
background: var(--spotify-dark-grey);
border: 1px solid var(--spotify-light-grey);
padding: 16px;
border-radius: 12px;
box-shadow: 0 15px 35px rgba(0,0,0,0.6);
width: calc(100% - 40px);
max-width: 340px;
z-index: 150;
display: none;
}
.visualizer {
display: flex;
align-items: flex-end;
gap: 2px;
height: 14px;
}
.vis-bar {
width: 3px;
background: var(--spotify-green);
height: 20%;
}
.playing .vis-bar {
animation: bounce 0.8s ease infinite alternate;
}
@keyframes bounce {
from { height: 20%; }
to { height: 100%; }
}
input[type="range"] {
accent-color: var(--spotify-green);
cursor: pointer;
}
#sidebarOverlay {
display: none;
position: fixed;
inset: 0;
background: rgba(0,0,0,0.8);
z-index: 90;
}
.sidebar-footer {
margin-top: auto;
border-top: 1px solid #282828;
padding: 20px 24px 30px 24px;
background-color: black;
}
</style>
</head>
<body class="flex flex-col">
<div id="loader" class="loading-overlay">
<div class="text-center">
<div class="w-12 h-12 border-4 border-white border-t-transparent rounded-full animate-spin mb-4 mx-auto"></div>
<p id="loaderText" class="font-medium text-lg text-white">Archive werden geladen...</p>
</div>
</div>
<div id="sidebarOverlay" onclick="toggleSidebar()"></div>
<div id="dlProgressBox">
<div class="flex justify-between items-start mb-3">
<div>
<p class="text-[10px] font-bold uppercase opacity-50 tracking-wider">Download Manager</p>
<p id="dlBookTitle" class="text-xs font-bold truncate max-w-[150px]">Buchname</p>
</div>
<button id="cancelDownloadBtn" class="bg-red-500 hover:bg-red-600 text-white text-[10px] px-2 py-1 rounded font-bold transition-colors">
ABBRECHEN
</button>
</div>
<p id="dlStatus" class="text-xs truncate mb-2 text-white/70">Bereite vor...</p>
<div class="progress-bar-container h-1.5 mb-2">
<div id="dlBarFill" class="progress-bar-fill" style="width: 0%; background-color: var(--spotify-green); transition: width 0.3s ease;"></div>
</div>
<div class="flex justify-between items-center">
<p id="dlRetryStatus" class="text-[9px] text-yellow-500 font-medium"></p>
<p id="dlPercentage" class="text-[10px] opacity-60 font-mono">0%</p>
</div>
</div>
<div class="flex flex-1 overflow-hidden relative">
<!-- Mobile Menu Trigger -->
<header class="md:hidden absolute top-0 left-0 right-0 h-16 flex items-center px-4 z-40">
<button onclick="toggleSidebar()" class="bg-black/60 p-2.5 rounded-full text-white backdrop-blur-md border border-white/10 shadow-lg">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"></path></svg>
</button>
</header>
<aside id="sidebar" class="sidebar p-6">
<div class="flex items-center justify-between mb-6">
<div class="flex items-center gap-2">
<div class="bg-white p-1 rounded-full text-black">
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 24 24"><path d="M12 3L4 9v12h16V9l-8-6zm0 2.2L18 10.2V19H6V10.2l6-5z"/></svg>
</div>
<h1 class="font-bold text-lg">HP-Archiv</h1>
</div>
<button onclick="toggleSidebar()" class="md:hidden text-white opacity-60 hover:opacity-100">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path></svg>
</button>
</div>
<div class="relative mb-6">
<input type="text" id="sidebarSearch" placeholder="Suche..." class="w-full bg-[#242424] text-xs py-2.5 px-4 pl-10 rounded-full border-none focus:ring-1 focus:ring-white outline-none">
<svg class="w-4 h-4 absolute left-3.5 top-3 text-[#b3b3b3]" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path></svg>
</div>
<div class="flex-1 overflow-y-auto custom-scrollbar">
<p class="text-[10px] font-bold text-[#b3b3b3] uppercase tracking-[0.15em] mb-4">Bibliothek</p>
<div id="sidebarList" class="space-y-1 pb-8"></div>
</div>
<div class="sidebar-footer">
<div class="mb-4 space-y-3">
<a href="https://github.com/redretep/HarryPotterArchiv/tree/main" target="_blank" class="flex items-center gap-2 text-[#b3b3b3] hover:text-white transition-colors text-[11px] font-bold uppercase tracking-wider">
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 24 24"><path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"/></svg>
GitHub
</a>
<div class="text-[9px] text-[#b3b3b3] leading-tight opacity-60">
<p class="font-bold mb-1 uppercase">Disclaimer</p>
Diese Webseite hostet keine Audio-Dateien. Alle Inhalte werden über externe URLs eingebunden.
</div>
</div>
<p class="text-[10px] text-[#b3b3b3] tracking-widest font-bold uppercase mb-1">Besucher</p>
<p class="text-2xl font-mono text-white tracking-tighter">{{COUNT}}</p>
</div>
</aside>
<main class="main-content custom-scrollbar p-6 pt-20 md:pt-6">
<div id="gridView" class="view-transition fade-in">
<h1 class="text-2xl md:text-3xl font-bold mb-6">Alle Hörbücher</h1>
<div id="bookGrid" class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4 md:gap-6"></div>
</div>
<div id="detailView" class="view-transition hidden fade-out">
<button id="backBtn" class="mb-6 flex items-center gap-2 text-sm font-bold opacity-70 hover:opacity-100 transition-opacity">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"></path></svg>
Zurück
</button>
<div class="flex flex-col md:flex-row gap-6 md:gap-8 items-center md:items-end mb-10">
<img id="detailCover" src="" class="w-48 h-48 md:w-64 md:h-64 shadow-2xl rounded-lg object-cover" alt="Cover">
<div class="flex-1 text-center md:text-left">
<p class="text-[10px] md:text-xs font-bold uppercase tracking-widest mb-2 text-[#b3b3b3]">Hörbuch</p>
<h2 id="detailTitle" class="text-2xl md:text-5xl font-black mb-3 tracking-tight leading-tight">Titel</h2>
<div class="flex items-center justify-center md:justify-start gap-2 text-xs md:text-sm font-medium">
<span class="text-white">Rufus Beck</span>
<span class="opacity-30">•</span>
<span id="detailTrackCount" class="opacity-60">0 Kapitel</span>
</div>
</div>
</div>
<div class="flex items-center justify-center md:justify-start gap-6 mb-8">
<button id="detailPlayBtn" class="btn-play-hero shadow-xl">
<svg class="w-8 h-8 ml-1" fill="currentColor" viewBox="0 0 24 24"><path d="M8,5.14V19.14L19,12.14L8,5.14Z" /></svg>
</button>
<button id="downloadAll" class="w-12 h-12 flex items-center justify-center rounded-full border border-white border-opacity-20 opacity-60 hover:opacity-100 hover:border-opacity-100 transition-all">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a2 2 0 002 2h12a2 2 0 002-2v-1m-4-4l-4 4m0 0l-4-4m4 4V4"></path></svg>
</button>
</div>
<div class="border-b border-white/10 mb-4 pb-2 grid grid-cols-[30px_1fr_50px] md:grid-cols-[40px_1fr_100px] px-4 text-[10px] font-bold text-[#b3b3b3] uppercase tracking-widest">
<span>#</span>
<span>Titel</span>
<span class="text-right">Aktion</span>
</div>
<div id="trackList" class="space-y-1 mb-32"></div>
</div>
</main>
</div>
<!-- Player Bar -->
<footer class="player-bar flex flex-col gap-3">
<div class="flex items-center justify-between gap-4">
<!-- Track Info -->
<div class="flex items-center gap-3 w-[45%] md:w-[30%]">
<div class="relative flex-shrink-0">
<img id="playerCover" src="" class="w-10 h-10 md:w-14 md:h-14 rounded shadow-md object-cover bg-white/5" alt="">
<div id="playerVisualizer" class="visualizer absolute bottom-0.5 right-0.5 hidden">
<div class="vis-bar" style="animation-delay: 0.1s"></div>
<div class="vis-bar" style="animation-delay: 0.3s"></div>
<div class="vis-bar" style="animation-delay: 0.2s"></div>
</div>
</div>
<div class="overflow-hidden">
<div id="playerTrackName" class="text-[11px] md:text-sm font-semibold truncate">Kapitel wählen</div>
<div id="playerBookName" class="text-[9px] md:text-[11px] text-[#b3b3b3] truncate">Harry Potter Archiv</div>
</div>
</div>
<!-- Controls -->
<div class="flex flex-col items-center flex-1 md:max-w-[40%] gap-1.5">
<div class="flex items-center gap-5 md:gap-8">
<button id="prevBtn" class="text-[#b3b3b3] hover:text-white active:scale-90 transition-all"><svg class="w-6 h-6 md:w-5 md:h-5" fill="currentColor" viewBox="0 0 24 24"><path d="M6,18L14.5,12L6,6V18M16,6V18H18V6H16Z" /></svg></button>
<button id="playBtn" class="bg-white text-black rounded-full w-9 h-9 md:w-8 md:h-8 flex items-center justify-center hover:scale-110 active:scale-95 transition-transform">
<svg id="playIcon" class="w-6 h-6 md:w-5 md:h-5 ml-0.5" fill="currentColor" viewBox="0 0 24 24"><path d="M8,5.14V19.14L19,12.14L8,5.14Z" /></svg>
<svg id="pauseIcon" class="w-6 h-6 md:w-5 md:h-5 hidden" fill="currentColor" viewBox="0 0 24 24"><path d="M14,19H18V5H14M6,19H10V5H6V19Z" /></svg>
</button>
<button id="nextBtn" class="text-[#b3b3b3] hover:text-white active:scale-90 transition-all"><svg class="w-6 h-6 md:w-5 md:h-5" fill="currentColor" viewBox="0 0 24 24"><path d="M16,18H18V6H16M6,18L14.5,12L6,6V18Z" /></svg></button>
</div>
<div class="flex items-center gap-2 w-full text-[9px] md:text-[10px] text-[#b3b3b3] font-mono">
<span id="currentTime">0:00</span>
<div class="progress-bar-container" id="progressBar"><div class="progress-bar-fill" id="progressFill" style="width: 0%"></div></div>
<span id="duration">0:00</span>
</div>
</div>
<!-- Extra Tools -->
<div class="hidden md:flex items-center justify-end gap-4 w-[30%]">
<button id="speedBtn" class="text-[10px] font-bold border border-white/20 rounded px-1.5 py-0.5 hover:bg-white hover:text-black">1x</button>
<button id="timerBtn" class="text-[#b3b3b3] hover:text-white" title="Sleep Timer"><svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg></button>
<div class="flex items-center gap-2">
<svg class="w-4 h-4 text-[#b3b3b3]" fill="currentColor" viewBox="0 0 24 24"><path d="M14,3.23V5.29C16.89,6.15 19,8.83 19,12C19,15.17 16.89,17.85 14,18.71V20.77C18.01,19.86 21,16.28 21,12C21,7.72 18.01,4.14 14,3.23M16.5,12C16.5,10.23 15.5,8.71 14,7.97V16.02C15.5,15.29 16.5,13.77 16.5,12M3,9V15H7L12,20V4L7,9H3Z"/></svg>
<input type="range" id="volumeSlider" min="0" max="1" step="0.05" value="1" class="w-20 h-1">
</div>
<button id="downloadEpisode" class="text-[#b3b3b3] hover:text-white"><svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a2 2 0 002 2h12a2 2 0 002-2v-1m-4-4l-4 4m0 0l-4-4m4 4V4"></path></svg></button>
</div>
</div>
<!-- Mobile Controls Row -->
<div class="md:hidden flex items-center justify-between gap-4 pt-1 border-t border-white/5">
<div class="flex items-center gap-5">
<button id="speedBtnMobile" class="text-[10px] font-bold border border-white/20 rounded px-2 py-0.5 active:bg-white active:text-black">1x</button>
<button id="timerBtnMobile" class="text-[#b3b3b3] active:text-white"><svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg></button>
<button id="downloadEpisodeMobile" class="text-[#b3b3b3] active:text-white"><svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a2 2 0 002 2h12a2 2 0 002-2v-1m-4-4l-4 4m0 0l-4-4m4 4V4"></path></svg></button>
</div>
<div class="flex items-center gap-2 flex-1 justify-end max-w-[120px]">
<svg class="w-3.5 h-3.5 text-[#b3b3b3]" fill="currentColor" viewBox="0 0 24 24"><path d="M3,9V15H7L12,20V4L7,9H3Z"/></svg>
<input type="range" id="volumeSliderMobile" min="0" max="1" step="0.05" value="1" class="w-full h-1">
</div>
</div>
</footer>
<audio id="audioElement"></audio>
<script>
const baseUrl = "https://redretep.github.io/HarryPotterArchiv/";
const imgUrl = "https://redretep.github.io/HarryPotterArchiv/images/";
const proxyBase = "https://api.pidi.workers.dev/?url=";
const csvFiles = [
{ id: 1, file: "1 - Harry Potter und der Stein der Weisen.csv" },
{ id: 2, file: "2 - Harry Potter und die Kammer des Schreckens.csv" },
{ id: 3, file: "3 - Harry Potter und der Gefangene von Askaban.csv" },
{ id: 4, file: "4 - Harry Potter und der Feuerkelch.csv" },
{ id: 5, file: "5 - Harry Potter und der Orden des Phönix.csv" },
{ id: 6, file: "6 - Harry Potter und der Halbblutprinz.csv" },
{ id: 7, file: "7 - Harry Potter und die Heiligtümer des Todes.csv" }
];
let collections = {};
let activeBook = null;
let currentTrackIndex = -1;
let _playingBookId = -1;
let isDownloading = false;
let sleepTimer = null;
const audio = document.getElementById('audioElement');
async function init() {
document.getElementById('loader').style.display = 'grid';
for (let entry of csvFiles) {
try {
const response = await fetch(baseUrl + encodeURIComponent(entry.file));
const text = await response.text();
const shortTitle = entry.file.split('-')[1]?.split('.')[0]?.trim();
collections[entry.id] = {
id: entry.id,
shortTitle: shortTitle,
image: `${imgUrl}${entry.id}.jpg`,
tracks: parseCSV(text)
};
} catch (err) { console.error(err); }
}
renderUI();
document.getElementById('loader').style.display = 'none';
handleRouting();
}
window.addEventListener('hashchange', handleRouting);
function handleRouting() {
const hash = window.location.hash;
if (hash.startsWith('#book-')) {
const bookId = parseInt(hash.replace('#book-', ''));
if (collections[bookId]) showDetail(bookId);
} else {
hideDetail();
}
if (window.innerWidth < 768) {
const sidebar = document.getElementById('sidebar');
if (sidebar.classList.contains('open')) toggleSidebar();
}
}
function toggleSidebar() {
const sidebar = document.getElementById('sidebar');
const overlay = document.getElementById('sidebarOverlay');
const isOpen = sidebar.classList.contains('open');
sidebar.classList.toggle('open', !isOpen);
overlay.style.display = !isOpen ? 'block' : 'none';
if (!isOpen) document.body.style.overflow = 'hidden';
else document.body.style.overflow = '';
}
function parseCSV(text) {
const lines = text.split('\n');
const result = [];
for (let i = 1; i < lines.length; i++) {
if (!lines[i].trim()) continue;
const matches = lines[i].match(/(".*?"|[^",\s]+)(?=\s*,|\s*$)/g) || [];
const clean = matches.map(p => p.replace(/^"|"$/g, '').trim());
if (clean.length >= 3) result.push({ podcast: clean[0], name: clean[1], url: clean[2] });
}
return result;
}
function renderUI() {
const bookGrid = document.getElementById('bookGrid');
const sidebarList = document.getElementById('sidebarList');
bookGrid.innerHTML = ''; sidebarList.innerHTML = '';
Object.values(collections).forEach(book => {
const card = document.createElement('div');
card.className = 'book-card p-4 rounded-lg shadow-lg';
card.innerHTML = `<img src="${book.image}" class="w-full aspect-square object-cover rounded-md mb-3 shadow-md"><h3 class="font-bold text-[11px] md:text-sm truncate mb-0.5">${book.shortTitle}</h3><p class="text-[9px] md:text-xs text-[#b3b3b3]">Rufus Beck</p>`;
card.onclick = () => window.location.hash = `book-${book.id}`;
bookGrid.appendChild(card);
const sideItem = document.createElement('div');
sideItem.className = 'px-4 py-2 text-sm text-[#b3b3b3] hover:text-white hover:bg-white/5 rounded-md cursor-pointer truncate transition-all sidebar-entry';
sideItem.innerText = book.shortTitle;
sideItem.dataset.title = book.shortTitle.toLowerCase();
sideItem.onclick = () => window.location.hash = `book-${book.id}`;
sidebarList.appendChild(sideItem);
});
}
document.getElementById('sidebarSearch').oninput = (e) => {
const term = e.target.value.toLowerCase();
document.querySelectorAll('.sidebar-entry').forEach(el => {
el.style.display = el.dataset.title.includes(term) ? 'block' : 'none';
});
};
function showDetail(id) {
activeBook = collections[id];
const gv = document.getElementById('gridView');
const dv = document.getElementById('detailView');
if (!gv.classList.contains('hidden')) {
gv.classList.replace('fade-in', 'fade-out');
setTimeout(() => {
gv.classList.add('hidden');
dv.classList.remove('hidden');
dv.classList.remove('fade-in', 'fade-out');
void dv.offsetWidth;
dv.classList.add('fade-in');
}, 400);
} else {
dv.classList.remove('hidden', 'fade-out');
dv.classList.add('fade-in');
}
document.getElementById('detailCover').src = activeBook.image;
document.getElementById('detailTitle').innerText = activeBook.shortTitle;
document.getElementById('detailTrackCount').innerText = `${activeBook.tracks.length} Kapitel`;
renderTracks();
}
function hideDetail() {
const gv = document.getElementById('gridView');
const dv = document.getElementById('detailView');
if (dv.classList.contains('hidden')) return;
dv.classList.replace('fade-in', 'fade-out');
setTimeout(() => {
dv.classList.add('hidden');
gv.classList.remove('hidden');
gv.classList.remove('fade-in', 'fade-out');
void gv.offsetWidth;
gv.classList.add('fade-in');
}, 400);
}
function renderTracks() {
const list = document.getElementById('trackList');
list.innerHTML = '';
activeBook.tracks.forEach((track, index) => {
const isActive = activeBook.id === _playingBookId && index === currentTrackIndex;
const div = document.createElement('div');
div.className = `track-row group ${isActive ? 'active' : ''}`;
div.innerHTML = `
<span class="text-xs opacity-50 font-mono">${index + 1}</span>
<div class="overflow-hidden">
<div class="text-[11px] md:text-sm font-semibold truncate">${track.name}</div>
<div class="text-[8px] md:text-[10px] opacity-50 truncate tracking-tight lowercase font-medium">${track.podcast}</div>
</div>
<div class="text-right">
<button onclick="event.stopPropagation(); downloadSingle(${index})" class="p-2 text-[#b3b3b3] hover:text-white transition-all">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a2 2 0 002 2h12a2 2 0 002-2v-1m-4-4l-4 4m0 0l-4-4m4 4V4"></path></svg>
</button>
</div>`;
div.onclick = () => playTrack(activeBook.id, index);
list.appendChild(div);
});
}
function playTrack(bookId, index) {
const book = collections[bookId];
if (!book || index < 0 || index >= book.tracks.length) return;
_playingBookId = bookId; currentTrackIndex = index;
const track = book.tracks[index];
audio.src = track.url; audio.play();
document.getElementById('playerTrackName').innerText = track.name;
document.getElementById('playerBookName').innerText = book.shortTitle;
document.getElementById('playerCover').src = book.image;
document.getElementById('playerVisualizer').classList.remove('hidden');
updatePlayStateUI(); renderTracks();
}
function updatePlayStateUI() {
const isPlaying = !audio.paused;
document.getElementById('playIcon').classList.toggle('hidden', isPlaying);
document.getElementById('pauseIcon').classList.toggle('hidden', !isPlaying);
document.getElementById('playerVisualizer').classList.toggle('playing', isPlaying);
const detailBtn = document.getElementById('detailPlayBtn');
if (detailBtn) detailBtn.innerHTML = isPlaying ? `<svg class="w-8 h-8" fill="currentColor" viewBox="0 0 24 24"><path d="M14,19H18V5H14M6,19H10V5H6V19Z"/></svg>` : `<svg class="w-8 h-8 ml-1" fill="currentColor" viewBox="0 0 24 24"><path d="M8,5.14V19.14L19,12.14L8,5.14Z"/></svg>`;
}
function formatTime(s) { const m = Math.floor(s / 60); const sec = Math.floor(s % 60); return `${m}:${sec < 10 ? '0' : ''}${sec}`; }
audio.ontimeupdate = () => {
if (!audio.duration) return;
document.getElementById('progressFill').style.width = `${(audio.currentTime / audio.duration) * 100}%`;
document.getElementById('currentTime').innerText = formatTime(audio.currentTime);
document.getElementById('duration').innerText = formatTime(audio.duration);
};
audio.onended = () => { if (currentTrackIndex + 1 < collections[_playingBookId].tracks.length) playTrack(_playingBookId, currentTrackIndex + 1); };
document.getElementById('playBtn').onclick = () => { if (audio.src) { audio.paused ? audio.play() : audio.pause(); updatePlayStateUI(); } else if (activeBook) playTrack(activeBook.id, 0); };
document.getElementById('prevBtn').onclick = () => playTrack(_playingBookId, currentTrackIndex - 1);
document.getElementById('nextBtn').onclick = () => playTrack(_playingBookId, currentTrackIndex + 1);
document.getElementById('backBtn').onclick = () => window.location.hash = '';
document.getElementById('progressBar').onclick = (e) => { const rect = document.getElementById('progressBar').getBoundingClientRect(); audio.currentTime = ((e.clientX - rect.left) / rect.width) * audio.duration; };
// Tools
const setVolume = (val) => { audio.volume = val; document.getElementById('volumeSlider').value = val; document.getElementById('volumeSliderMobile').value = val; };
document.getElementById('volumeSlider').oninput = (e) => setVolume(e.target.value);
document.getElementById('volumeSliderMobile').oninput = (e) => setVolume(e.target.value);
const toggleSpeed = () => { const s = [1, 1.25, 1.5, 2]; let n = s[(s.indexOf(audio.playbackRate) + 1) % s.length]; audio.playbackRate = n; document.getElementById('speedBtn').innerText = n + 'x'; document.getElementById('speedBtnMobile').innerText = n + 'x'; };
document.getElementById('speedBtn').onclick = toggleSpeed;
document.getElementById('speedBtnMobile').onclick = toggleSpeed;
const setTimer = () => { let m = prompt("Minuten bis Stopp?", "30"); if (m) { if (sleepTimer) clearTimeout(sleepTimer); sleepTimer = setTimeout(() => audio.pause(), m * 60000); } };
document.getElementById('timerBtn').onclick = setTimer;
document.getElementById('timerBtnMobile').onclick = setTimer;
window.downloadSingle = (idx) => { const t = activeBook.tracks[idx]; saveFile(t.url, `${t.name}.mp3`); };
const dlCurrent = () => { if (currentTrackIndex !== -1) downloadSingle(currentTrackIndex); };
document.getElementById('downloadEpisode').onclick = dlCurrent;
document.getElementById('downloadEpisodeMobile').onclick = dlCurrent;
document.getElementById('downloadAll').onclick = async () => {
if (!activeBook || isDownloading) return;
isDownloading = true;
const db = document.getElementById('dlProgressBox');
db.style.display = 'block';
document.getElementById('dlBookTitle').innerText = activeBook.shortTitle;
try {
const zip = new JSZip();
const folder = zip.folder(activeBook.shortTitle);
for (let i = 0; i < activeBook.tracks.length; i++) {
if (!isDownloading) break;
const t = activeBook.tracks[i];
document.getElementById('dlStatus').innerText = `Lade: ${t.name}`;
try {
const r = await fetch(proxyBase + encodeURIComponent(t.url));
const blob = await r.blob();
folder.file(`${i+1}. ${t.name}.mp3`, blob);
} catch(e) {}
const p = ((i + 1) / activeBook.tracks.length) * 100;
document.getElementById('dlBarFill').style.width = p + '%';
document.getElementById('dlPercentage').innerText = Math.round(p) + '%';
}
if (isDownloading) {
const content = await zip.generateAsync({type:"blob"});
saveFile(URL.createObjectURL(content), `${activeBook.shortTitle}.zip`);
}
} catch(e) {}
isDownloading = false;
setTimeout(() => db.style.display = 'none', 3000);
};
function saveFile(url, name) { const a = document.createElement('a'); a.href = url; a.download = name; a.click(); }
init();
</script>
</body>
</html>