-
Notifications
You must be signed in to change notification settings - Fork 0
/
tvguide.html
157 lines (140 loc) · 3.96 KB
/
tvguide.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>teamsonic2011's super cool website</title>
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=DynaPuff">
<style>
.image-row {
display: flex;
justify-content: center;
}
body {
font-family: DynaPuff, sans-serif;
background-color: #0491FF;
color: #FFF;
margin: 0;
padding: 0;
text-align: center;
}
body {
background-image: url('5028.png');
background-repeat: repeat;
}
header {
background-color: #fff;
padding: 20px;
}
header h1 {
margin: 0;
color: #fff;
}
main {
padding: 20px;
}
.link-button:hover {
background-color: #ff6347;
}
/* Additional styles for the TV guide */
table {
width: 100%;
border-collapse: collapse;
margin: 20px 0;
}
th, td {
padding: 10px;
border: 1px solid #000;
text-align: left;
}
th {
background: #000;
color: #fff;
}
.channel {
font-weight: bold;
background: #000000;
}
.time-slot {
white-space: nowrap;
}
</style>
<script type="text/javascript" src="scripts/downcheck.js"></script>
</head>
<body>
<div class="image-row">
<a href="/"><img src="assets/1000001462.png" width="100%" height="75%"></a>
<a href="about.html"><img src="assets/about.png" width="100%" height="75%"></a>
<a href="stuff.html"><img src="assets/stuff.png" width="100%" height="75%"></a>
</div>
<header>
<img src="assets/why.gif" width=75%>
</header>
<div class="container">
<table id="tvGuide">
<thead>
<tr>
<th>Channel</th>
<th>Show</th>
<th>Time</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<script>
async function fetchTVListings() {
try {
const response = await fetch('https://api.tvmaze.com/schedule?country=US');
const data = await response.json();
console.log("Fetched data:", data);
const tableBody = document.getElementById('tvGuide').getElementsByTagName('tbody')[0];
tableBody.innerHTML = '';
const currentTime = new Date();
const channels = {};
data.forEach(show => {
if (!show.show.network) return;
const network = show.show.network.name;
const airtime = new Date(`${show.airdate}T${show.airtime}`);
console.log("Processing show:", show.show.name, "on", network, "at", airtime);
if (airtime < currentTime) return; // Skip shows that have already aired
if (!channels[network]) {
channels[network] = [];
}
channels[network].push({
name: show.show.name,
time: airtime
});
});
console.log("Channels:", channels);
for (const channel in channels) {
channels[channel].sort((a, b) => a.time - b.time);
const row = tableBody.insertRow();
const cell = row.insertCell(0);
cell.textContent = channel;
cell.className = "channel";
channels[channel].forEach(show => {
const timeCell = row.insertCell(row.cells.length);
timeCell.textContent = `${show.time.toLocaleTimeString('en-US', {
hour: '2-digit',
minute: '2-digit'
})} - ${show.name}`;
});
}
if (Object.keys(channels).length === 0) {
const row = tableBody.insertRow();
const cell = row.insertCell(0);
cell.colSpan = 3;
cell.textContent = "No listings available.";
}
} catch (error) {
console.error('Error fetching TV listings:', error);
}
}
fetchTVListings();
setInterval(fetchTVListings, 60000);
</script>
</body>
</html>