-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebplayer.php
More file actions
1378 lines (1209 loc) · 49.6 KB
/
webplayer.php
File metadata and controls
1378 lines (1209 loc) · 49.6 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
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
// IPTV Web Player (get.php only • jPlayer) - PHP deploy-ready (Option C)
// - Auto-detects get.php/xmltv.php base path
// - Auto-fills creds from storefront session if present
// - Uses ONLY get.php + xmltv.php (no player_api)
session_start();
// Storefront session keys (adjust here if your storefront uses different names)
$autoUser = $_SESSION['store_user_username'] ?? $_SESSION['iptv_username'] ?? '';
$autoPass = $_SESSION['store_pass_plain'] ?? $_SESSION['iptv_password_plain'] ?? '';
// Optional: allow querystring autologin when you need it (kept off by default)
// $autoUser = $autoUser ?: ($_GET['username'] ?? '');
// $autoPass = $autoPass ?: ($_GET['password'] ?? '');
function h($s){ return htmlspecialchars($s ?? '', ENT_QUOTES, 'UTF-8'); }
?>
<!doctype html>
<html lang="en">
<head>
<link rel="icon" href="/favicon.ico">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>IPTV Web Player (get.php only • jPlayer)</title>
<!-- jQuery + jPlayer -->
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jplayer@2.9.2/dist/jplayer/jquery.jplayer.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jplayer@2.9.2/dist/skin/blue.monday/jplayer.blue.monday.min.css">
<!-- HLS.js bridge -->
<script src="https://cdn.jsdelivr.net/npm/hls.js@1.5.18/dist/hls.min.js"></script>
<style>
:root{
--player-h: clamp(320px, 72vh, 760px);
--bg:#0b0d12;
--panel:#121621;
--panel2:#0f1320;
--text:#e6e9ef;
--muted:#9aa3b2;
--accent:#4dd2ff;
--accent2:#7cffb2;
--danger:#ff6b6b;
--border:rgba(255,255,255,.08);
font-synthesis: style;
}
*{box-sizing:border-box}
body{
margin:0; background:var(--bg); color:var(--text);
font-family:system-ui,Segoe UI,Roboto,Helvetica,Arial,sans-serif;
height:100vh; display:grid; grid-template-columns:360px 1fr; grid-template-rows:auto 1fr;
}
header{
grid-column:1/-1; padding:12px 16px; display:flex; gap:12px; align-items:center; justify-content:space-between;
background:linear-gradient(180deg,#0f1220,#0b0d12); border-bottom:1px solid var(--border);
}
header h1{font-size:18px;margin:0;font-weight:700;letter-spacing:.4px}
header .pill{font-size:12px;color:var(--muted);padding:4px 8px;border:1px solid var(--border);border-radius:999px}
aside{
border-right:1px solid var(--border); background:var(--panel);
display:flex; flex-direction:column; min-height:0;
}
.section{padding:12px;border-bottom:1px solid var(--border)}
.section h2{
margin:0 0 8px; font-size:13px; color:var(--muted);
font-weight:700; text-transform:uppercase; letter-spacing:.8px;
}
.login-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}
label{font-size:12px;color:var(--muted);display:block;margin-bottom:4px}
.ui input,.ui select,.ui button{
width:100%; padding:9px 10px; border-radius:10px; border:1px solid var(--border);
background:var(--panel2); color:var(--text); outline:none;
}
.ui input::placeholder{color:#657089}
.ui button{
cursor:pointer; font-weight:700; letter-spacing:.3px; transition:.15s ease;
background:linear-gradient(180deg,#1b2240,#10162b);
border:1px solid rgba(77,210,255,.35);
box-shadow:0 0 0 1px rgba(77,210,255,.1) inset;
}
.ui button:hover{transform:translateY(-1px)}
.ui button.secondary{border-color:var(--border);box-shadow:none;font-weight:600}
.status{font-size:12px;color:var(--muted);margin-top:8px;min-height:18px;white-space:pre-wrap}
.status.ok{color:var(--accent2)}
.status.err{color:var(--danger)}
.search-row{display:flex;gap:8px}
.search-row input{flex:1}
.groups{display:flex;flex-wrap:wrap;gap:6px;max-height:140px;overflow:auto;padding-right:4px}
.group-chip{
font-size:12px;padding:6px 8px;border-radius:999px;border:1px solid var(--border);
background:#0c1020;cursor:pointer;user-select:none;white-space:nowrap;
}
.group-chip.active{
border-color:rgba(77,210,255,.6);color:#bfefff;box-shadow:0 0 0 1px rgba(77,210,255,.15) inset;
}
.channel-list{overflow:auto;padding:6px;display:flex;flex-direction:column;gap:6px;min-height:0}
.channel{
display:grid;grid-template-columns:40px 1fr auto;gap:8px;align-items:center;padding:8px;
border-radius:12px;border:1px solid var(--border);background:var(--panel2);cursor:pointer;transition:.08s ease;
}
.channel:hover{transform:translateY(-1px)}
.channel.active{border-color:rgba(124,255,178,.6);box-shadow:0 0 0 1px rgba(124,255,178,.2) inset}
.logo{
width:40px;height:40px;border-radius:8px;object-fit:cover;background:#0a0d18;border:1px solid var(--border);
}
.ch-name{font-size:14px;font-weight:700;line-height:1.1}
.ch-meta{font-size:11px;color:var(--muted)}
main{display:flex;flex-direction:column;min-height:0}
.player-wrap{
background:#000;border-bottom:1px solid var(--border);padding:0;position:relative;
/* Lock player height so it NEVER jumps and never overlaps the EPG panel */
height:var(--player-h);
min-height:var(--player-h);
max-height:var(--player-h);
flex:0 0 var(--player-h);
overflow:hidden;
display:flex;align-items:stretch;justify-content:stretch;
}
#jp_container{width:100%;height:100%;position:relative}
#jquery_jplayer, #jquery_jplayer video{
width:100% !important; height:100% !important; background:#000;
}
/* --- Lock jPlayer size classes so the player never resizes on load/change --- */
#jp_container.jp-video,
#jp_container.jp-video-270p,
#jp_container.jp-video-360p,
#jp_container.jp-video-full,
#jp_container.jp-video-screen{
width:100% !important;
height:100% !important;
max-height:100% !important;
}
#jp_container .jp-type-single{height:100% !important;}
#jp_container .jp-gui{
position:absolute;left:0;right:0;bottom:0;padding:8px;
background:linear-gradient(180deg,rgba(0,0,0,0),rgba(0,0,0,.7));
}
#jp_container .jp-interface{
background:#000;border:1px solid var(--border);border-radius:12px;
}
/* --- User tweak: kill bottom black bar + timestamps, keep only channel name overlay --- */
#jp_container .jp-gui{
background: transparent !important;
padding: 0 !important;
opacity: 0;
transition: opacity .15s ease;
pointer-events: none;
}
/* show controls only when hovering player */
.player-wrap:hover #jp_container .jp-gui{
opacity: 1;
pointer-events: auto;
padding: 8px !important;
background: linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,.35)) !important;
}
#jp_container .jp-interface{
background: transparent !important;
border: none !important;
box-shadow: none !important;
}
#jp_container .jp-progress,
#jp_container .jp-volume-controls,
#jp_container .jp-time-holder,
#jp_container .jp-current-time,
#jp_container .jp-duration{
display: none !important;
}
/* jPlayer buttons must NOT inherit our UI button styles */
#jp_container button{
width:auto !important; padding:0 !important; margin:0 !important;
background:transparent !important; border:none !important; box-shadow:none !important;
border-radius:0 !important; font-weight:normal !important; letter-spacing:0 !important;
transform:none !important; color:transparent !important; text-indent:-9999px; overflow:hidden;
}
#jp_container .jp-play-bar{background:var(--accent)}
#jp_container .jp-volume-bar-value{background:var(--accent2)}
.now-playing{
position:absolute;left:12px;bottom:12px;background:rgba(0,0,0,.55);padding:8px 10px;border-radius:10px;font-size:13px;
backdrop-filter:blur(6px);border:1px solid rgba(255,255,255,.12);max-width:calc(100% - 24px);
white-space:nowrap;overflow:hidden;text-overflow:ellipsis;pointer-events:none;
}
.info{padding:12px;color:var(--muted);font-size:13px;overflow:auto;flex:1 1 auto;min-height:0}
@media (max-width:900px){
:root{--player-h: clamp(240px, 38vh, 460px);}
body{grid-template-columns:1fr;grid-template-rows:auto auto 1fr}
aside{height:48vh;border-right:none;border-bottom:1px solid var(--border)}
}
/* --- XMLTV EPG styling --- */
#epgPanel{line-height:1.35}
.epg-item{
padding:8px;
border:1px solid var(--border);
background:var(--panel2);
border-radius:10px;
margin-bottom:6px;
}
.epg-title{font-weight:700; font-size:14px}
.epg-time{font-size:12px; color:var(--muted)}
.epg-desc{font-size:12px; color:#c7cbd6; margin-top:4px}
/* --- Header tabs --- */
.tabs{display:flex;gap:8px;align-items:center}
.tab{
padding:8px 10px;border-radius:999px;border:1px solid var(--border);
background:rgba(15,19,32,.6);color:var(--text);cursor:pointer;
font-weight:700;font-size:12px;letter-spacing:.3px;
}
.tab.active{
border-color:rgba(77,210,255,.6);
box-shadow:0 0 0 1px rgba(77,210,255,.15) inset;
color:#bfefff;
}
/* --- Fullscreen EPG modal --- */
body.epg-open{overflow:hidden}
.epg-modal{
position:fixed;inset:0;z-index:9999;display:none;
background:rgba(0,0,0,.72);
backdrop-filter:blur(10px);
}
.epg-modal .inner{
position:absolute;inset:12px;
border:1px solid var(--border);
border-radius:16px;
background:linear-gradient(180deg,#0f1320,#0b0d12);
display:flex;flex-direction:column;overflow:hidden;
}
.epg-topbar{
display:flex;gap:10px;align-items:center;
padding:10px;border-bottom:1px solid var(--border);
flex-wrap:wrap;
}
.epg-topbar .title{font-weight:800;letter-spacing:.4px}
.epg-topbar .mini{font-size:12px;color:var(--muted);white-space:nowrap}
.epg-topbar .spacer{flex:1}
.epg-topbar input,.epg-topbar select{
padding:9px 10px;border-radius:10px;border:1px solid var(--border);
background:var(--panel2);color:var(--text);outline:none
}
.epg-topbar button{
padding:9px 10px;border-radius:10px;border:1px solid var(--border);
background:linear-gradient(180deg,#1b2240,#10162b);
color:var(--text);cursor:pointer;font-weight:800
}
.epg-topbar button.ghost{background:transparent}
.epg-wrap{flex:1;overflow:auto;background:rgba(0,0,0,.15)}
.epg-table{min-width:900px}
.epg-head{
position:sticky;top:0;z-index:30;display:flex;
border-bottom:1px solid var(--border);
background:rgba(11,13,18,.95);
backdrop-filter:blur(8px);
}
.epg-head .left{
width:280px;min-width:280px;
position:sticky;left:0;z-index:40;
border-right:1px solid var(--border);
padding:10px;font-weight:800;
}
.epg-timebar{flex:1;display:flex}
.epg-time-slot{
height:44px;display:flex;align-items:flex-end;
justify-content:flex-start;padding:6px 8px;
border-right:1px solid rgba(255,255,255,.06);
font-size:12px;color:var(--muted);white-space:nowrap
}
.epg-row{display:flex;min-height:58px;border-bottom:1px solid rgba(255,255,255,.06)}
.epg-chcell{
width:280px;min-width:280px;
position:sticky;left:0;z-index:20;
border-right:1px solid var(--border);
background:rgba(15,19,32,.95);
padding:8px 10px;cursor:pointer;
}
.epg-chcell:hover{background:rgba(15,19,32,1)}
.epg-chname{font-weight:800;font-size:13px;line-height:1.15}
.epg-chmeta{font-size:11px;color:var(--muted)}
.epg-line{position:relative;flex:1}
.epg-prog{
position:absolute;top:7px;bottom:7px;
border-radius:12px;border:1px solid rgba(77,210,255,.25);
background:linear-gradient(180deg,rgba(77,210,255,.18),rgba(16,22,43,.8));
padding:8px;overflow:hidden;cursor:pointer;
}
.epg-prog:hover{transform:translateY(-1px)}
.epg-prog .t{
font-weight:800;font-size:12px;
white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.epg-prog .tm{font-size:11px;color:var(--muted);margin-top:2px}
.epg-prog.now{
border-color:rgba(124,255,178,.45);
background:linear-gradient(180deg,rgba(124,255,178,.18),rgba(16,22,43,.8));
}
.epg-empty{position:absolute;left:8px;top:18px;font-size:12px;color:var(--muted)}
.epg-details{border-top:1px solid var(--border);padding:10px;display:none}
.epg-details .dtitle{font-weight:900}
.epg-details .dmeta{font-size:12px;color:var(--muted);margin-top:4px}
.epg-details .ddesc{
font-size:12px;color:#c7cbd6;margin-top:6px;
max-height:90px;overflow:auto;
}
.epg-details .actions{margin-top:8px;display:flex;gap:8px;flex-wrap:wrap}
.epg-details .actions button{
padding:9px 10px;border-radius:10px;
border:1px solid rgba(124,255,178,.35);
background:linear-gradient(180deg,#122b1c,#0b0d12);
color:var(--text);cursor:pointer;font-weight:900
}
.epg-details .actions button.secondary{
border-color:var(--border);background:transparent;font-weight:700
}
/* --- Auth (Login) modal --- */
body.auth-open{overflow:hidden}
.auth-modal{
position:fixed;inset:0;z-index:10000;display:none;
background:rgba(0,0,0,.72);
backdrop-filter:blur(10px);
}
.auth-modal .inner{
width:min(520px, calc(100% - 24px));
margin:10vh auto 0;
border:1px solid var(--border);
border-radius:16px;
background:linear-gradient(180deg,#0f1320,#0b0d12);
padding:14px;
box-shadow:0 20px 80px rgba(0,0,0,.55);
overflow:hidden;
}
.auth-title{font-weight:900;letter-spacing:.4px;font-size:16px}
.auth-sub{font-size:12px;color:var(--muted);margin-top:4px;margin-bottom:10px}
.auth-actions{display:flex;gap:6px;margin-top:10px}
.auth-actions button{flex:1}
/* SVG icons */
#epgPrev svg.ico,#epgNext svg.ico,#epgClose svg.ico{width:18px;height:18px;display:block;}
</style>
</head>
<body>
<header>
<div style="display:flex;align-items:center;gap:12px;min-width:0">
<h1>IPTV Web Player</h1>
<div id="counts" class="pill" style="display:none"></div>
</div>
<div class="tabs" role="tablist" aria-label="Views">
<button id="tabPlayer" class="tab active" role="tab" aria-selected="true" type="button">Player</button>
<button id="tabEpg" class="tab" role="tab" aria-selected="false" type="button">Guide</button>
</div>
</header>
<aside class="ui">
<div class="section" id="accountSection" style="display:none">
<h2>Account</h2>
<div style="display:flex;gap:8px;align-items:center;justify-content:space-between">
<div style="font-size:12px;color:var(--muted)" id="accountLabel">Signed in</div>
<button class="secondary" id="logoutBtn" type="button">Logout</button>
</div>
<div class="status" id="status" style="margin-top:8px"></div>
</div>
<div class="section">
<h2>Filter</h2>
<div style="display:flex; flex-direction:column; gap:8px;">
<input id="search" placeholder="search channels...">
<select id="groupSelect">
<option value="">All Groups</option>
</select>
</div>
<div class="groups" id="groupChips"></div>
</div>
<div class="channel-list" id="channelList"></div>
</aside>
<main>
<div class="player-wrap">
<div id="jp_container" class="jp-video jp-video-360p" role="application" aria-label="media player">
<div class="jp-type-single">
<div id="jquery_jplayer" class="jp-jplayer"></div>
<div class="jp-gui">
<div class="jp-interface">
<div class="jp-controls">
<button class="jp-play">play</button>
<button class="jp-pause">pause</button>
<button class="jp-stop">stop</button>
<button class="jp-mute">mute</button>
<button class="jp-unmute">unmute</button>
<button class="jp-volume-max">max volume</button>
</div>
<div class="jp-progress">
<div class="jp-seek-bar"><div class="jp-play-bar"></div></div>
</div>
<div class="jp-volume-controls">
<div class="jp-volume-bar"><div class="jp-volume-bar-value"></div></div>
</div>
<div class="jp-time-holder">
<div class="jp-current-time"> </div>
<div class="jp-duration"> </div>
</div>
<div class="jp-toggles">
<button class="jp-full-screen">full screen</button>
<button class="jp-restore-screen">restore screen</button>
</div>
</div>
</div>
<div class="jp-no-solution">
<span>Update Required</span>
Your browser can’t play this stream.
</div>
</div>
</div>
<div class="now-playing" id="nowPlaying">Nothing playing</div>
</div>
<div class="info" id="epgPanel">
<div style="font-weight:700; margin-bottom:6px;">TV Guide (XMLTV)</div>
<div id="epgStatus" style="font-size:12px; color:var(--muted); margin-bottom:6px;">EPG not loaded yet.</div>
<div id="epgNow" style="margin-bottom:8px;"></div>
<div id="epgNextList"></div>
</div>
</main>
<!-- Fullscreen EPG (OTT-style grid) -->
<div class="epg-modal" id="epgModal" aria-hidden="true">
<div class="inner">
<div class="epg-topbar">
<div class="title">TV Guide</div>
<div class="mini" id="epgRange"></div>
<div class="spacer"></div>
<input id="epgSearch" placeholder="search channels or shows...">
<select id="epgCategory">
<option value="">All Categories</option>
</select>
<button class="ghost" id="epgPrev" title="Back 30 min" type="button"><svg class="ico" viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M15 18l-6-6 6-6"/></svg></button>
<button class="ghost" id="epgNowBtn" type="button">Now</button>
<button class="ghost" id="epgNext" title="Forward 30 min" type="button"><svg class="ico" viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 18l6-6-6-6"/></svg></button>
<button id="epgClose" title="Close" type="button"><svg class="ico" viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6L6 18"/><path d="M6 6l12 12"/></svg></button>
</div>
<div class="epg-wrap" id="epgWrap">
<div class="epg-table" id="epgTable">
<div class="epg-head">
<div class="left">Channels</div>
<div class="epg-timebar" id="epgTimeHeader"></div>
</div>
<div id="epgBody"></div>
</div>
</div>
<div class="epg-details" id="epgDetails"></div>
</div>
</div>
<!-- Login modal (blocks page until validated) -->
<div class="auth-modal" id="authModal" aria-hidden="true">
<div class="inner ui">
<div class="auth-title">Sign in</div>
<div class="auth-sub">Enter your account to load channels + guide.</div>
<form id="authForm" autocomplete="on">
<div class="login-grid">
<div>
<label>Username</label>
<input id="username" placeholder="your username" autocomplete="username">
</div>
<div>
<label>Password</label>
<input id="password" placeholder="your password" type="password" autocomplete="current-password">
</div>
<div style="grid-column:1/-1">
<label>Output (browser needs HLS)</label>
<select id="outputMode">
<option value="hls" selected>hls (web compatible)</option>
<option value="ts">ts (VLC / apps)</option>
</select>
</div>
<div class="auth-actions" style="grid-column:1/-1">
<button id="loadBtn" type="submit">Login</button>
<button class="secondary" id="clearBtn" type="button">Clear</button>
</div>
</div>
<div class="status" id="authStatus"></div>
</form>
</div>
</div>
<script>
(() => {
const els = {
username: document.getElementById('username'),
password: document.getElementById('password'), outputMode: document.getElementById('outputMode'),
loadBtn: document.getElementById('loadBtn'),
clearBtn: document.getElementById('clearBtn'),
status: document.getElementById('status'),
authModal: document.getElementById('authModal'),
authForm: document.getElementById('authForm'),
authStatus: document.getElementById('authStatus'),
accountSection: document.getElementById('accountSection'),
logoutBtn: document.getElementById('logoutBtn'),
accountLabel: document.getElementById('accountLabel'),
search: document.getElementById('search'),
groupSelect: document.getElementById('groupSelect'),
groupChips: document.getElementById('groupChips'),
channelList: document.getElementById('channelList'),
nowPlaying: document.getElementById('nowPlaying'),
counts: document.getElementById('counts'),
tabPlayer: document.getElementById('tabPlayer'),
tabEpg: document.getElementById('tabEpg'),
epgModal: document.getElementById('epgModal'),
epgSearch: document.getElementById('epgSearch'),
epgCategory: document.getElementById('epgCategory'),
epgPrev: document.getElementById('epgPrev'),
epgNext: document.getElementById('epgNext'),
epgNowBtn: document.getElementById('epgNowBtn'),
epgClose: document.getElementById('epgClose'),
epgRange: document.getElementById('epgRange'),
epgTimeHeader: document.getElementById('epgTimeHeader'),
epgBody: document.getElementById('epgBody'),
epgDetails: document.getElementById('epgDetails'),
};
let channels = [];
let groups = [];
let activeGroup = '';
let activeChannelId = null;
let favorites = new Set(JSON.parse(localStorage.getItem('iptv_favs') || '[]'));
let hls = null;
let isAuthed = false;
// ----------- base-path autodetect (get.php / xmltv.php) -----------
let baseCache = null;
async function probe(url){
try{
const r = await fetch(url, {method:"GET", cache:"no-store"});
// get.php/xmltv.php return 400/401 when called without creds; treat as "exists"
return r && (r.ok || [400,401,403].includes(r.status));
}catch(e){ return false; }
}
async function detectBase(){
if (baseCache) return baseCache;
const here = window.location.pathname.replace(/\/[^\/]*$/, "/");
const candidates = [
here,
here.replace(/\/$/, "") + "/../",
"/"
];
for (const c of candidates){
const clean = c.replace(/\/\.\.\//g, "/");
if (await probe(clean + "get.php")){
baseCache = clean;
return baseCache;
}
}
baseCache = "/";
return baseCache;
}
async function getPhpUrl(u,p){
const base = await detectBase();
return `${base}get.php?username=${encodeURIComponent(u)}&password=${encodeURIComponent(p)}&type=m3u_plus&output=hls&link=auto`;
}
async function xmltvUrl(u,p){
const base = await detectBase();
return `${base}xmltv.php?username=${encodeURIComponent(u)}&password=${encodeURIComponent(p)}`;
}
// ---------------------------------------------------------------
// ---------------- XMLTV EPG ----------------
let epgXmlText = null;
let epgMap = null; // channelId -> array of programmes
let epgAlias = null; // normalized alias -> channelId
function epgSetStatus(msg, type=''){
const el = document.getElementById('epgStatus');
if (!el) return;
el.style.color = type==='err' ? 'var(--danger)' : 'var(--muted)';
el.textContent = msg;
}
function normalizeKey(s){
return (s||"")
.toLowerCase()
.replace(/&/g,"&")
.replace(/[^a-z0-9]+/g,"")
.trim();
}
function fmtTimeRange(startDate, stopDate){
const opts = { hour: '2-digit', minute: '2-digit' };
return `${startDate.toLocaleTimeString([], opts)} - ${stopDate.toLocaleTimeString([], opts)}`;
}
function parseXmltvDate(s){
const m = (s||"").match(/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/);
if (!m) return null;
const [_,Y,Mo,D,H,Mi,S] = m;
return new Date(+Y, +Mo-1, +D, +H, +Mi, +S);
}
function buildEpgMapFromXml(xmlText){
const parser = new DOMParser();
const xml = parser.parseFromString(xmlText, "text/xml");
const map = new Map();
const alias = new Map();
// Build alias map from <channel> entries
const chans = Array.from(xml.getElementsByTagName("channel"));
for (const ch of chans){
const id = ch.getAttribute("id") || "";
if (!id) continue;
if (!alias.has(normalizeKey(id))) alias.set(normalizeKey(id), id);
const dnames = Array.from(ch.getElementsByTagName("display-name")).map(x=>x.textContent.trim());
for (const dn of dnames){
if (!dn) continue;
alias.set(normalizeKey(dn), id);
const stripped = dn.replace(/^\s*[A-Z]{2,3}\s*\|\s*/i, "").trim();
if (stripped && stripped !== dn){
alias.set(normalizeKey(stripped), id);
}
}
}
// Programmes
const progs = Array.from(xml.getElementsByTagName("programme"));
for (const p of progs){
const chId = p.getAttribute("channel") || "";
if (!chId) continue;
const start = parseXmltvDate(p.getAttribute("start") || "");
const stop = parseXmltvDate(p.getAttribute("stop") || "");
const titleEl = p.getElementsByTagName("title")[0];
const descEl = p.getElementsByTagName("desc")[0];
const title = titleEl ? titleEl.textContent.trim() : "Untitled";
const desc = descEl ? descEl.textContent.trim() : "";
const item = { start, stop, title, desc, channel: chId };
if (!map.has(chId)) map.set(chId, []);
map.get(chId).push(item);
}
for (const [k, arr] of map){
arr.sort((a,b)=> (a.start||0) - (b.start||0));
}
return { map, alias };
}
async function loadEpg(u, p){
try{
epgSetStatus("Loading EPG...");
const epgUrl = await xmltvUrl(u,p);
const res = await fetch(epgUrl, { cache:"no-store" });
const text = await res.text();
if (!res.ok || !text.includes("<tv")){
epgSetStatus("EPG load failed (bad response).", "err");
return;
}
epgXmlText = text;
const built = buildEpgMapFromXml(text);
epgMap = built.map;
epgAlias = built.alias;
epgSetStatus("EPG loaded.");
if (document.body.classList.contains("epg-open")) { renderEpgGrid(); }
}catch(e){
epgSetStatus("EPG load error: " + e.message, "err");
}
}
function findBestEpgIdForChannel(ch){
if (!epgMap || !epgAlias) return null;
const candidates = [ch.tvgId, ch.tvgName, ch.name]
.filter(Boolean)
.map(x=>x.trim());
for (const c of candidates){
if (epgMap.has(c)) return c;
}
for (const c of candidates){
const nk = normalizeKey(c);
if (epgAlias.has(nk)) return epgAlias.get(nk);
const stripped = c.replace(/^\s*[A-Z]{2,3}\s*\|\s*/i, "").trim();
const nk2 = normalizeKey(stripped);
if (epgAlias.has(nk2)) return epgAlias.get(nk2);
}
return null;
}
function renderEpgForChannel(ch){
const nowBox = document.getElementById("epgNow");
const nextBox = document.getElementById("epgNextList");
if (!nowBox || !nextBox) return;
nowBox.innerHTML = "";
nextBox.innerHTML = "";
if (!epgMap){
epgSetStatus("EPG not loaded.");
return;
}
const id = findBestEpgIdForChannel(ch);
if (!id){
epgSetStatus("No EPG match for this channel.");
return;
}
const list = epgMap.get(id) || [];
const now = new Date();
const upcoming = list.filter(it => it.start && it.stop && it.stop > now).slice(0, 8);
if (!upcoming.length){
epgSetStatus("No upcoming programmes.");
return;
}
const current = upcoming.find(it => it.start <= now && it.stop >= now) || upcoming[0];
epgSetStatus(`Guide for: ${id}`);
const curPct = (current.start && current.stop)
? Math.min(100, Math.max(0, ((now-current.start)/(current.stop-current.start))*100))
: 0;
nowBox.innerHTML = `
<div class="epg-item">
<div class="epg-title">Now: ${escapeHtml(current.title)}</div>
<div class="epg-time">${current.start && current.stop ? fmtTimeRange(current.start, current.stop) : ""}</div>
<div style="height:6px;background:#111;border-radius:999px;overflow:hidden;margin-top:6px;">
<div style="height:100%;width:${curPct}%;background:var(--accent);"></div>
</div>
${current.desc ? `<div class="epg-desc">${escapeHtml(current.desc)}</div>` : ""}
</div>
`;
const rest = upcoming.filter(it => it !== current);
nextBox.innerHTML = rest.map(it => `
<div class="epg-item">
<div class="epg-title">${escapeHtml(it.title)}</div>
<div class="epg-time">${it.start && it.stop ? fmtTimeRange(it.start, it.stop) : ""}</div>
${it.desc ? `<div class="epg-desc">${escapeHtml(it.desc)}</div>` : ""}
</div>
`).join("");
}
// -------------- /XMLTV EPG --------------
// ---------------- Fullscreen OTT-style EPG ----------------
const EPG_SLOT_MIN = 30; // step
const EPG_WINDOW_MIN = 240; // 4 hours visible
const EPG_PPM = 4; // pixels per minute (controls density)
const EPG_MAX_ROWS = 220;
let epgViewStart = null;
function setActiveTab(which){
if (!els.tabPlayer || !els.tabEpg) return;
const isPlayer = which === 'player';
els.tabPlayer.classList.toggle('active', isPlayer);
els.tabEpg.classList.toggle('active', !isPlayer);
els.tabPlayer.setAttribute('aria-selected', isPlayer ? 'true' : 'false');
els.tabEpg.setAttribute('aria-selected', !isPlayer ? 'true' : 'false');
}
function floorToStep(d, stepMin){
const ms = d.getTime();
const step = stepMin * 60_000;
return new Date(Math.floor(ms / step) * step);
}
function addMinutes(d, mins){ return new Date(d.getTime() + mins*60_000); }
function minsBetween(a,b){ return (a.getTime() - b.getTime()) / 60_000; }
function renderTimeHeader(start){
if (!els.epgTimeHeader) return;
const slotW = EPG_SLOT_MIN * EPG_PPM;
let html = "";
for (let m = 0; m < EPG_WINDOW_MIN; m += EPG_SLOT_MIN){
const t = addMinutes(start, m);
const label = (t.getMinutes() === 0)
? t.toLocaleTimeString([], {hour:'numeric'})
: "";
html += `<div class="epg-time-slot" style="width:${slotW}px">${escapeHtml(label)}</div>`;
}
els.epgTimeHeader.innerHTML = html;
}
function filterEpgChannels(start, end){
const q = (els.epgSearch?.value || "").toLowerCase().trim();
const g = (els.epgCategory?.value || "");
let list = channels;
if (g) list = list.filter(c => c.group === g);
if (!q) return list;
return list.filter(c => {
if ((c.name||"").toLowerCase().includes(q)) return true;
if (!epgMap) return false;
const id = findBestEpgIdForChannel(c);
if (!id) return false;
const arr = epgMap.get(id) || [];
for (const it of arr){
if (!it.start || !it.stop) continue;
if (it.stop < start) continue;
if (it.start > end) break; // list is sorted
if ((it.title||"").toLowerCase().includes(q)) return true;
}
return false;
});
}
function renderEpgGrid(){
if (!els.epgBody) return;
if (!epgViewStart) epgViewStart = floorToStep(new Date(), EPG_SLOT_MIN);
const start = epgViewStart;
const end = addMinutes(start, EPG_WINDOW_MIN);
const now = new Date();
if (els.epgRange){
const day = start.toLocaleDateString([], {weekday:'short', month:'short', day:'numeric'});
const a = start.toLocaleTimeString([], {hour:'2-digit', minute:'2-digit'});
const b = end.toLocaleTimeString([], {hour:'2-digit', minute:'2-digit'});
els.epgRange.textContent = `${day} • ${a} - ${b}`;
}
renderTimeHeader(start);
if (!epgMap){
els.epgBody.innerHTML = `<div style="padding:14px;color:var(--muted)">EPG not loaded yet. Load the playlist first (or wait a second).</div>`;
return;
}
const visible = filterEpgChannels(start, end);
const list = visible.slice(0, EPG_MAX_ROWS);
const trimmed = visible.length > list.length;
const lineW = EPG_WINDOW_MIN * EPG_PPM;
els.epgBody.innerHTML = list.map(c => {
const epgId = findBestEpgIdForChannel(c);
const arr = epgId ? (epgMap.get(epgId) || []) : [];
const blocks = [];
if (epgId && arr.length){
for (const it of arr){
if (!it.start || !it.stop) continue;
if (it.stop <= start) continue;
if (it.start >= end) break;
const s = it.start < start ? start : it.start;
const e = it.stop > end ? end : it.stop;
const left = Math.max(0, minsBetween(s, start) * EPG_PPM);
const width = Math.max(12, minsBetween(e, s) * EPG_PPM);
const isNow = it.start <= now && it.stop >= now;
const timeStr = (it.start && it.stop) ? fmtTimeRange(it.start, it.stop) : "";
blocks.push(`
<div class="epg-prog ${isNow?'now':''}"
style="left:${left}px;width:${width}px"
data-ch="${c.id}"
data-epgid="${escapeAttr(epgId)}"
data-s="${it.start.getTime()}"
data-e="${it.stop.getTime()}">
<div class="t">${escapeHtml(it.title || 'Untitled')}</div>
<div class="tm">${escapeHtml(timeStr)}</div>
</div>
`);
}
}
const empty = (!blocks.length)
? `<div class="epg-empty">${epgId ? "No data in this window" : "No EPG match"}</div>`
: "";
return `
<div class="epg-row" data-id="${c.id}">
<div class="epg-chcell" title="Click to play">
<div class="epg-chname">${escapeHtml(c.name)}</div>
<div class="epg-chmeta">${escapeHtml(c.group || '')}</div>
</div>
<div class="epg-line" style="width:${lineW}px">
${empty}
${blocks.join("")}
</div>
</div>
`;
}).join('') + (trimmed ? `<div style="padding:10px;color:var(--muted);font-size:12px">Showing first ${EPG_MAX_ROWS} channels (use search/category to narrow).</div>` : "");
}
function showEpgDetails(channelObj, programme){
if (!els.epgDetails) return;
if (!channelObj){
els.epgDetails.style.display = "none";
return;
}
const title = programme?.title ? programme.title : "No programme info";
const meta = (programme?.start && programme?.stop) ? fmtTimeRange(programme.start, programme.stop) : "";
const desc = programme?.desc ? programme.desc : "";
els.epgDetails.innerHTML = `
<div class="dtitle">${escapeHtml(title)}</div>
<div class="dmeta">${escapeHtml(channelObj.name)} • ${escapeHtml(meta)}</div>
${desc ? `<div class="ddesc">${escapeHtml(desc)}</div>` : `<div class="ddesc" style="color:var(--muted)">No description.</div>`}
<div class="actions">
<button type="button" id="epgPlayBtn">Play Channel</button>
<button type="button" class="secondary" id="epgHideBtn">Hide</button>
</div>
`;
els.epgDetails.style.display = "block";
const playBtn = document.getElementById("epgPlayBtn");
const hideBtn = document.getElementById("epgHideBtn");
playBtn && playBtn.addEventListener("click", () => {
playChannel(channelObj);
closeEpg();
});
hideBtn && hideBtn.addEventListener("click", () => { els.epgDetails.style.display = "none"; });
}
function openEpg(){
if (!els.epgModal) return;
if (!isAuthed){ showAuth("Sign in to continue."); return; }
document.body.classList.add("epg-open");
els.epgModal.style.display = "block";
els.epgModal.setAttribute("aria-hidden", "false");
setActiveTab("epg");
if (!epgViewStart) epgViewStart = floorToStep(new Date(), EPG_SLOT_MIN);
renderEpgGrid();
}
function closeEpg(){
if (!els.epgModal) return;
document.body.classList.remove("epg-open");
els.epgModal.style.display = "none";
els.epgModal.setAttribute("aria-hidden", "true");
setActiveTab("player");
if (els.epgDetails) els.epgDetails.style.display = "none";
}
// -------------- /Fullscreen OTT-style EPG --------------
// Init jPlayer once
$("#jquery_jplayer").jPlayer({
supplied: "m3u8, m4v, webmv, ogv, oga, mp3",
solution: "html, flash",
cssSelectorAncestor: "#jp_container",
size: { width: "100%", height: "100%" },
useStateClassSkin: true,
autoBlur: false,
smoothPlayBar: true,
keyEnabled: true,
preload: "metadata",
muted: false,
errorAlerts: false,
warningAlerts: false
});
// Restore creds (but force HLS default for web)
els.username.value = localStorage.getItem('iptv_user') || '';
els.password.value = localStorage.getItem('iptv_pass') || ''; els.outputMode.value = localStorage.getItem('iptv_out') || 'hls';
if (els.outputMode.value !== 'hls') {
els.outputMode.value = 'hls'; // force sane default
}