-
Notifications
You must be signed in to change notification settings - Fork 0
/
episodes.html
133 lines (122 loc) · 4.61 KB
/
episodes.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Season Episodes</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;
}
h1 {
text-align: center;
}
#episodes-results {
margin-top: 20px;
display: flex;
flex-wrap: wrap;
list-style-type: none;
padding: 0;
justify-content: center;
}
.episode-item {
width: 200px;
height: 200px;
padding: 10px;
border: 1px solid #333;
margin: 10px;
text-align: center;
position: relative;
margin-bottom: 60px;
background-color: #1e1e1e;
border-radius: 5px;
transition: background-color 0.3s;
}
.episode-item:hover {
background-color: #333;
}
.episode-title {
font-size: 16px;
font-weight: bold;
margin-top: 5px;
}
.episode-number {
font-size: 14px;
color: #ff9900; /* Color for the episode number */
margin-bottom: 5px; /* Space between number and title */
}
.episode-poster {
width: 100%;
height: 140px;
object-fit: contain;
border-radius: 5px;
}
.play-button {
background-color: #ff9900;
color: white;
border: none;
padding: 10px 0;
cursor: pointer;
font-size: 14px;
width: 100%;
position: absolute;
bottom: -40px;
left: 0;
border-radius: 5px;
}
</style>
</head>
<body>
<h1>Episodes for Season</h1>
<ul id="episodes-results"></ul>
<script>
const apiKey = '250ff9ec7e817d6a95d10b822de9e227'; // Your TMDB API key
const urlParams = new URLSearchParams(window.location.search);
const seasonNumber = urlParams.get('season');
const tmdbId = urlParams.get('id'); // Now using TMDB ID directly
// Function to fetch episodes for a given season and TMDB ID
function fetchEpisodes(seasonNumber, tmdbId) {
const url = `/api/fetchEpisodes?id=${tmdbId}&season=${seasonNumber}`; // Use server-side fetching
$.get(url, function(data) {
if (data && data.episodes) {
displayEpisodes(data.episodes);
} else {
$('#episodes-results').html('<p>No episodes found.</p>');
}
}).fail(function() {
$('#episodes-results').html('<p>Error fetching episodes.</p>');
});
}
// Function to display the episodes
function displayEpisodes(episodes) {
$('#episodes-results').html(''); // Clear previous results
episodes.forEach(episode => {
const posterUrl = episode.still_path ? `https://image.tmdb.org/t/p/w200${episode.still_path}` : 'https://via.placeholder.com/200x300?text=No+Image';
// Get the episode number
const episodeNumber = episode.episode_number;
const episodeHtml = `
<li class="episode-item">
<img src="${posterUrl}" alt="${episode.name} poster" class="episode-poster">
<div class="episode-number">Ep - ${episodeNumber}</div> <!-- Episode number -->
<div class="episode-title">${episode.name}</div>
<button class="play-button" onclick="playEpisode(${seasonNumber}, ${episode.episode_number})">Play</button>
</li>
`;
$('#episodes-results').append(episodeHtml);
});
}
// Function to play the episode
function playEpisode(season, episode) {
const playUrl = `https://moviee.tv/embed/tv/${tmdbId}?season=${season}&episode=${episode}`; // Use TMDB ID for embed URL
window.open(playUrl, '_blank'); // Open in a new tab
}
// Fetch episodes on page load using the TMDB ID directly
fetchEpisodes(seasonNumber, tmdbId);
</script>
</body>
</html>