-
Notifications
You must be signed in to change notification settings - Fork 4
/
watch.html
195 lines (174 loc) · 5.26 KB
/
watch.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Anime Streaming Page</title>
<!-- Link to Vue.js via CDN -->
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
<style>
/* Reset styles */
body, html {
margin: 0;
padding: 0;
font-family: 'Arial', sans-serif;
height: 100%;
background-color: #181818;
color: #fff;
}
#app {
display: flex;
flex-direction: column;
height: 100%;
}
/* Player Section */
#player {
background-color: #000;
width: 100%;
height: 60vh;
position: relative;
}
.oplayer-container {
width: 100%;
height: 100%;
}
#message {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: rgba(0, 0, 0, 0.8);
color: #fff;
padding: 20px;
font-size: 18px;
border-radius: 10px;
display: none;
}
/* Episode List Section */
#episodeList {
flex-grow: 1;
padding: 20px;
background-color: #2c2c2c;
overflow-y: auto;
max-height: 40vh;
border-top: 2px solid #444;
}
.episode-item {
padding 0;
cursor: pointer;
font-size: 16px;
border-radius: 5px;
transition: background-color 0.3s ease-in-out;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}
.episode-item:hover {
background-color: #444;
}
/* Center loading message */
.loading {
text-align: center;
color: #888;
}
/* Responsive Design */
@media (max-width: 768px) {
#episodeList {
max-height: 50vh;
}
}
</style>
</head>
<body>
<!-- Vue.js App -->
<div id="app">
<!-- Streaming Player Section -->
<div id="player">
<div class="oplayer-container" id="oplayerContainer"></div>
<div id="message">Please select an episode to continue watching!</div>
</div>
<!-- Episode List Section -->
<div id="episodeList">
<div v-if="loading" class="loading">Loading episodes...</div>
<div v-else>
<button v-for="episode in episodes" :key="episode.episodeId" class="episode-item" @click="handleEpisodeClick(episode.episodeId)">
Episode {{ episode.number }}: {{ episode.title }}
</button>
</div>
</div>
</div>
<!-- OPlayer & Playlist Plugins -->
<script src="https://cdn.jsdelivr.net/npm/@oplayer/core@latest/dist/player.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@oplayer/ui@latest/dist/ui.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@oplayer/plugins@latest/dist/playlist.min.js"></script>
<!-- Eruda for Debugging -->
<script src="https://cdn.jsdelivr.net/npm/eruda"></script>
<script>eruda.init();</script>
<script>
// Initialize Vue.js app
new Vue({
el: '#app',
data: {
episodes: [],
loading: true,
currentEpisodeId: null,
animeId: '',
},
methods: {
// Get animeId from URL query parameters
getAnimeIdFromUrl() {
const urlParams = new URLSearchParams(window.location.search);
this.animeId = urlParams.get('id'); // Example: ?id=steinsgate
},
async fetchEpisodes(animeId) {
try {
const response = await fetch(`https://aniwatch-api-net.vercel.app/api/v2/hianime/anime/${animeId}/episodes`);
const data = await response.json();
if (data.success) {
this.episodes = data.data.episodes;
this.loading = false;
} else {
this.loading = false;
}
} catch (error) {
console.error('Error fetching episodes }
},
async fetchStreamLink(episodeId) {
try {
const response = await fetch(`https://anime-api-zeta-lac.vercel.app/api/stream?id=${episodeId}`);
const data = await response.json();
if (data.success) {
const streamingLink = data.results.streamingLink[0];
const playlist = [{
title: `${data.results.server} - ${streamingLink.type}`,
src: streamingLink.link.file,
type: 'hls',
poster: 'https://via.placeholder.com/400x225',
}];
OPlayer.make('#oplayerContainer')
.use([new OPlaylist({
sources: playlist,
autoNext: false,
initialIndex: 0,
})])
.create();
}
} catch (error) {
console.error('Error fetching streaming data:', error);
}
},
handleEpisodeClick(episodeId) {
this.currentEpisodeId = episodeId;
document.getElementById('message').style.display = 'block';
document.getElementById('episodeList').style.display = 'none';
this.fetchStreamLink(episodeId);
}
},
created() {
this.getAnimeIdFromUrl(); // Fetch the anime ID from the URL query parameter
if (this.animeId) {
this.fetchEpisodes(this.animeId); // Fetch episodes based on the anime ID
}
},
});
</script>
</body>
</html>