|
1 | 1 | import { GoogleGenerativeAI, HarmBlockThreshold, HarmCategory } from "@google/generative-ai";
|
2 | 2 |
|
3 |
| -const chatbotInput = document.getElementById("chatbotInput"); |
4 | 3 | const chatbotBody = document.getElementById("chatbotBody");
|
5 | 4 | const movieee = `https://${getMovieVerseData()}/3`;
|
6 | 5 |
|
@@ -31,13 +30,8 @@ document.addEventListener('DOMContentLoaded', function() {
|
31 | 30 | document.getElementById('clear-search-btn').style.display = 'none';
|
32 | 31 | });
|
33 | 32 |
|
34 |
| -const search = document.getElementById("search"); |
35 |
| -const searchButton = document.getElementById("button-search"); |
36 | 33 | const searchTitle = document.getElementById("search-title");
|
37 |
| -const otherTitle = document.getElementById("other1"); |
38 | 34 | const SEARCHPATH = `https://${getMovieVerseData()}/3/search/movie?&${generateMovieNames()}${getMovieCode()}&query=`;
|
39 |
| -const IMGPATH = "https://image.tmdb.org/t/p/w1280"; |
40 |
| -const main = document.getElementById("main"); |
41 | 35 |
|
42 | 36 | async function ensureGenreMapIsAvailable() {
|
43 | 37 | if (!localStorage.getItem('genreMap')) {
|
@@ -171,24 +165,6 @@ async function rotateUserStats() {
|
171 | 165 | });
|
172 | 166 | }
|
173 | 167 |
|
174 |
| -function updateMovieVisitCount(movieId, movieTitle) { |
175 |
| - let movieVisits = JSON.parse(localStorage.getItem('movieVisits')) || {}; |
176 |
| - let uniqueMoviesViewed = JSON.parse(localStorage.getItem('uniqueMoviesViewed')) || []; |
177 |
| - |
178 |
| - if (!movieVisits[movieId]) { |
179 |
| - movieVisits[movieId] = { count: 0, title: movieTitle }; |
180 |
| - } |
181 |
| - |
182 |
| - movieVisits[movieId].count += 1; |
183 |
| - |
184 |
| - if (!uniqueMoviesViewed.includes(movieId)) { |
185 |
| - uniqueMoviesViewed.push(movieId); |
186 |
| - } |
187 |
| - |
188 |
| - localStorage.setItem('movieVisits', JSON.stringify(movieVisits)); |
189 |
| - localStorage.setItem('uniqueMoviesViewed', JSON.stringify(uniqueMoviesViewed)); |
190 |
| -} |
191 |
| - |
192 | 168 | function getMostVisitedDirector() {
|
193 | 169 | const directorVisits = JSON.parse(localStorage.getItem('directorVisits')) || {};
|
194 | 170 | let mostVisitedDirector = '';
|
@@ -304,9 +280,9 @@ function sendInitialInstructions() {
|
304 | 280 | </span>
|
305 | 281 | </div>
|
306 | 282 | <ul style="text-align: left; margin-bottom: 10px; color: #fff;">
|
307 |
| - <li>To find details about a movie, type "Show me details about [movie name]".</li> |
| 283 | + <li>To quickly find the trailer of a movie, type "Show trailer for [movie name]".</li> |
308 | 284 | <li>You can also ask about genres, top-rated movies, latest movies, get a recommended movie, and any general questions!</li>
|
309 |
| - <li>💡<b>Tip:</b> To get the best results, try to avoid phrasing requests like "Show me details about ...", as they might trigger specific functions instead of a broader search.</li> |
| 285 | + <li>💡<b>Tip:</b> To get the best results, try to avoid phrasing requests like "Show trailer for ...", as they might trigger specific functions instead of a broader search.</li> |
310 | 286 | </ul>
|
311 | 287 | <div style="text-align: left; color: #fff;">How may I assist you today? 🎬🍿</div>
|
312 | 288 | `;
|
@@ -476,47 +452,6 @@ function hideSpinner() {
|
476 | 452 | document.getElementById('myModal').classList.remove('modal-visible');
|
477 | 453 | }
|
478 | 454 |
|
479 |
| -async function fetchMovieDetailsFromTMDB(movieName) { |
480 |
| - const url = `${movieee}/search/movie?${generateMovieNames()}${getMovieCode()}&query=${encodeURIComponent(movieName)}`; |
481 |
| - |
482 |
| - try { |
483 |
| - const response = await fetch(url); |
484 |
| - const data = await response.json(); |
485 |
| - |
486 |
| - if (data.results.length > 0) { |
487 |
| - const movie = data.results[0]; |
488 |
| - localStorage.setItem('selectedMovieId', movie.id); |
489 |
| - |
490 |
| - let movieOverview = movie.overview; |
491 |
| - if (movieOverview.length > 500) { |
492 |
| - movieOverview = movieOverview.substring(0, 500) + '...'; |
493 |
| - } |
494 |
| - if (movieOverview === '' || movieOverview === null || !movieOverview) { |
495 |
| - movieOverview = 'N/A'; |
496 |
| - } |
497 |
| - |
498 |
| - let movieReleaseDate = movie.release_date; |
499 |
| - if (movieReleaseDate === '' || movieReleaseDate === null || !movieReleaseDate) { |
500 |
| - movieReleaseDate = 'N/A'; |
501 |
| - } |
502 |
| - |
503 |
| - let movieVoteAverage = movie.vote_average.toFixed(1); |
504 |
| - if (movieVoteAverage === '' || movieVoteAverage === null || !movieVoteAverage) { |
505 |
| - movieVoteAverage = 'N/A'; |
506 |
| - } |
507 |
| - |
508 |
| - return `The title of the movie is ${movie.title}. Its overview is: ${movieOverview}. Its release date is ${movieReleaseDate}, and rating is ${movieVoteAverage}. You can find more info about it if you wish <a href="../html/movie-details.html" class='movie-details-link' style='color: #ff8623; cursor: pointer; text-decoration: underline;' data-movie-id='${movie.id}'>here</a>.`; |
509 |
| - } |
510 |
| - else { |
511 |
| - return "I couldn't find any movie with that name. Please try another movie name."; |
512 |
| - } |
513 |
| - } |
514 |
| - catch (error) { |
515 |
| - console.log('Error fetching movie details:', error); |
516 |
| - return "Sorry, I encountered an error while trying to fetch movie details. Please try again later."; |
517 |
| - } |
518 |
| -} |
519 |
| - |
520 | 455 | async function showMovieOfTheDay() {
|
521 | 456 | const year = new Date().getFullYear();
|
522 | 457 | const url = `https://${getMovieVerseData()}/3/discover/movie?${generateMovieNames()}${getMovieCode()}&sort_by=vote_average.desc&vote_count.gte=100&primary_release_year=${year}&vote_average.gte=7`;
|
|
0 commit comments