Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Fauzanmhr committed Aug 26, 2024
2 parents a3f1b7f + 9b3c3a7 commit 44e90f9
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 80 deletions.
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ const fetchAndStoreAnimeData = async () => {
await fetchAndStoreAnimeData();
})();

// Periodically update all anime data (every 60 minutes)
setInterval(fetchAndStoreAnimeData, 60 * 60 * 1000);

// Use routes
app.use('/', animeRoutes);
app.use('/', genreRoutes);
Expand All @@ -49,4 +46,7 @@ app.use('/', scheduleRoutes);
// Start the server
app.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`);
});
});

// Periodically update all anime data (every 60 minutes)
setInterval(fetchAndStoreAnimeData, 60 * 60 * 1000);
43 changes: 37 additions & 6 deletions views/episode.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@
<h1 class="mt-4"><%= episode.judul %></h1>
<div class="row">
<div class="col-md-12">
<div class="ratio ratio-16x9 mb-4">
<iframe id="streaming-iframe" src="<%= episode.streamingUrl %>" title="Streaming Player" allowfullscreen></iframe>
<div id="iframe-container" class="ratio ratio-16x9 mb-4 position-relative">
<!-- Loading Spinner -->
<div id="loading-spinner" class="d-flex justify-content-center align-items-center position-absolute top-0 bottom-0 start-0 end-0 bg-light">
<div class="spinner-border text-black" role="status">
<span class="visually-hidden">Loading...</span>
</div>
</div>
<!-- Streaming Iframe -->
<iframe id="streaming-iframe" class="d-none" src="<%= episode.streamingUrl %>" title="Streaming Player" allowfullscreen></iframe>
</div>
<div class="mb-4">
<select id="streaming-source" class="form-select">
Expand Down Expand Up @@ -70,6 +77,7 @@
const decodedUrl = await response.text();
return decodedUrl;
} catch (error) {
console.error('Error decoding shortlink:', error);
return shortlink; // Return the original shortlink if decoding fails
}
}
Expand All @@ -96,10 +104,33 @@
document.getElementById('streaming-source').addEventListener('change', async function() {
const selectedUrl = this.value;
const decodedUrl = await decodeShortlink(selectedUrl);
const formattedUrl = formatUrlForEmbedding(decodedUrl);
document.getElementById('streaming-iframe').src = formattedUrl;
let decodedUrl = selectedUrl;
// Only decode if it's not the default source
if (selectedUrl !== "<%= episode.streamingUrl %>") {
decodedUrl = await decodeShortlink(selectedUrl);
}
const iframe = document.getElementById('streaming-iframe');
const spinner = document.getElementById('loading-spinner');
// Show the spinner and hide the iframe
spinner.style.display = 'flex';
iframe.classList.add('d-none');
// Update iframe source
iframe.src = formatUrlForEmbedding(decodedUrl);
});
// Listen for iframe load event to hide spinner
document.getElementById('streaming-iframe').addEventListener('load', function() {
const spinner = document.getElementById('loading-spinner');
const iframe = document.getElementById('streaming-iframe');
// Hide the spinner and show the iframe once loaded
spinner.style.display = 'none';
iframe.classList.remove('d-none');
});
</script>
</body>
</html>
</html>
62 changes: 22 additions & 40 deletions views/genre-anime.ejs
Original file line number Diff line number Diff line change
@@ -1,47 +1,29 @@
<%- include('partials/header', { title: 'Anime by Genre - ZANNIME' }) %>
<div class="container">
<h1 class="mt-4">Anime by Genre: <%= genre %></h1>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Poster</th>
<th>Judul</th>
<th>Rating</th>
<th>Studio</th>
<th>Musim</th>
<th>Genre</th>
<th>Jumlah Episode</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<% animes.forEach(anime => { %>
<tr>
<td><img src="<%= anime.poster %>" alt="<%= anime.judul %>" class="img-fluid" style="max-width: 100px;"></td>
<td><%= anime.judul %></td>
<td><%= anime.rating %></td>
<td><%= anime.studio %></td>
<td><%= anime.musim %></td>
<td>
<ul>
<% anime.genres.forEach(genre => { %>
<li><%= genre.judul %></li>
<% }) %>
</ul>
</td>
<td><%= anime.jumlahEpisode %></td>
<td>
<a href="/anime/<%= anime.slug %>" class="btn btn-dark btn-sm">View</a>
</td>
</tr>
<% }) %>
</tbody>
</table>
<div class="row">
<% animes.forEach(anime => { %>
<div class="col-lg-2 col-md-3 col-sm-4 col-6 mb-3">
<div class="card h-100 d-flex flex-column">
<img src="<%= anime.poster %>" class="card-img-top img-fluid" alt="<%= anime.judul %>" style="max-height: 300px; object-fit: cover;">
<div class="card-body p-2 d-flex flex-column">
<h6 class="card-title text-truncate mb-1" style="font-size: 0.9rem;"><%= anime.judul %></h6>
<p class="card-text small mb-1" style="font-size: 0.8rem;">
<strong>Rating:</strong> <%= anime.rating %><br>
<strong>Studio:</strong> <%= anime.studio %><br>
<strong>Musim:</strong> <%= anime.musim %><br>
<strong>Episodes:</strong> <%= anime.jumlahEpisode %>
</p>
<!-- Button with mt-auto to push it to the bottom -->
<a href="/anime/<%= anime.slug %>" class="btn btn-dark btn-sm w-100 mt-auto" style="font-size: 0.8rem;">View</a>
</div>
</div>
</div>
<% }) %>
</div>
<!-- Pagination -->
<nav aria-label="Anime list pagination">
<ul class="pagination justify-content-center">
<nav aria-label="Anime list pagination" class="d-flex justify-content-center">
<ul class="pagination">
<li class="page-item <%= !pagination.prevPage ? 'disabled' : '' %>">
<a class="page-link" href="?page=<%= pagination.prevPage %>">Previous</a>
</li>
Expand Down Expand Up @@ -69,4 +51,4 @@
<!-- Bootstrap JS -->
<script src="/js/bootstrap.bundle.min.js"></script>
</body>
</html>
</html>
51 changes: 21 additions & 30 deletions views/index.ejs
Original file line number Diff line number Diff line change
@@ -1,37 +1,28 @@
<%- include('partials/header', { title: 'ZANNIME' }) %>
<div class="container">
<h1 class="mt-4">On Going Anime</h1>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Poster</th>
<th>Judul</th>
<th>Hari Rilis</th>
<th>Tanggal Rilis Terbaru</th>
<th>Episode Terbaru</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<% animes.forEach(anime => { %>
<tr>
<td><img src="<%= anime.poster %>" alt="<%= anime.judul %>" class="img-fluid" style="max-width: 100px;"></td>
<td><%= anime.judul %></td>
<td><%= anime.hariRilis %></td>
<td><%= anime.tanggalRilisTerbaru %></td>
<td><%= anime.episodeTerbaru %></td>
<td>
<a href="/anime/<%= anime.slug %>" class="btn btn-dark btn-sm">View</a>
</td>
</tr>
<% }) %>
</tbody>
</table>
<div class="row">
<% animes.forEach(anime => { %>
<div class="col-lg-2 col-md-3 col-sm-4 col-6 mb-3">
<div class="card h-100 d-flex flex-column">
<img src="<%= anime.poster %>" class="card-img-top img-fluid" alt="<%= anime.judul %>" style="max-height: 300px; object-fit: cover;">
<div class="card-body p-2 d-flex flex-column">
<h6 class="card-title text-truncate mb-1" style="font-size: 0.9rem;"><%= anime.judul %></h6>
<p class="card-text small mb-1" style="font-size: 0.8rem;">
<strong>Release:</strong> <%= anime.hariRilis %><br>
<strong>Latest:</strong> <%= anime.tanggalRilisTerbaru %><br>
<strong>Ep:</strong> <%= anime.episodeTerbaru %>
</p>
<!-- Button with mt-auto to push it to the bottom -->
<a href="/anime/<%= anime.slug %>" class="btn btn-dark btn-sm w-100 mt-auto" style="font-size: 0.8rem;">View</a>
</div>
</div>
</div>
<% }) %>
</div>
<!-- Pagination -->
<nav aria-label="Anime list pagination">
<ul class="pagination justify-content-center">
<nav aria-label="Anime list pagination" class="d-flex justify-content-center">
<ul class="pagination">
<li class="page-item <%= !pagination.prevPage ? 'disabled' : '' %>">
<a class="page-link" href="?page=<%= pagination.prevPage %>">Previous</a>
</li>
Expand Down Expand Up @@ -59,4 +50,4 @@
<!-- Bootstrap JS -->
<script src="/js/bootstrap.bundle.min.js"></script>
</body>
</html>
</html>

0 comments on commit 44e90f9

Please sign in to comment.