-
Notifications
You must be signed in to change notification settings - Fork 0
/
seasons.html
109 lines (100 loc) · 3.47 KB
/
seasons.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TV Show Seasons</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<style>
body {
font-family: Arial, sans-serif;
background-color: #121212;
color: #ffffff;
margin: 0;
padding: 20px;
box-sizing: border-box;
}
h1 {
text-align: center;
font-size: 28px;
}
#seasons-results {
margin-top: 20px;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
list-style-type: none;
}
.season-item {
padding: 15px;
margin: 10px 0;
cursor: pointer;
background-color: #1e1e1e;
border-radius: 5px;
border: 1px solid #333;
width: 90%;
max-width: 600px;
text-align: center;
transition: background-color 0.3s ease;
}
.season-item:hover {
background-color: #333;
}
.season-title {
font-size: 18px;
font-weight: bold;
}
@media (max-width: 768px) {
h1 {
font-size: 22px;
}
.season-title {
font-size: 16px;
}
}
</style>
</head>
<body>
<h1>Seasons for the Show</h1>
<ul id="seasons-results"></ul>
<script>
const apiKey = '250ff9ec7e817d6a95d10b822de9e227'; // Your TMDB API key
const urlParams = new URLSearchParams(window.location.search);
const tmdbId = urlParams.get('id'); // Now fetching the TMDB ID directly from the URL
// Function to fetch seasons for a given TMDB ID
function fetchSeasons(tmdbId) {
const url = `/api/fetchSeasons?id=${tmdbId}`;
$.get(url, function(data) {
if (data && data.seasons) {
displaySeasons(data.seasons);
} else {
$('#seasons-results').html('<p>No seasons found</p>');
}
}).fail(function() {
$('#seasons-results').html('<p>Error fetching seasons</p>');
});
}
// Function to display the seasons
function displaySeasons(seasons) {
$('#seasons-results').html(''); // Clear previous results
seasons.forEach(season => {
const seasonNumber = season.season_number;
const seasonName = season.name && season.name !== `Season ${seasonNumber}` ? `: ${season.name}` : '';
const seasonHtml = `
<li class="season-item" onclick="goToEpisodes(${seasonNumber})">
<div class="season-title">Season ${seasonNumber}${seasonName}</div>
</li>
`;
$('#seasons-results').append(seasonHtml);
});
}
// Function to redirect to episodes.html with selected season
function goToEpisodes(season) {
window.location.href = `episodes.html?season=${season}&id=${tmdbId}`; // Using TMDB ID
}
// Fetch the seasons on page load
fetchSeasons(tmdbId);
</script>
</body>
</html>