Skip to content

Commit

Permalink
[ Jessi-md 4.8.0 ⏱️ ]
Browse files Browse the repository at this point in the history
  • Loading branch information
whiteshadowofficial authored Oct 27, 2023
1 parent 858e4c3 commit 47609b2
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions plugins/Movie-info.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import fetch from 'node-fetch';

let handler = async (m, { conn, text }) => {
if (!text) throw 'Please provide a movie title';

try {
let res = await fetch(`https://api.popcat.xyz/imdb?q=${encodeURIComponent(text)}`);

if (!res.ok) {
throw new Error(`API request failed with status ${res.status}`);
}

let json = await res.json();

console.log('JSON response:', json);

let ratings = json.ratings.map(rating => `• *${rating.source}:* ${rating.value}`).join('\n');

let movieInfo =
`*Movie Information:*\n
• *Title:* ${json.title}\n
• *Year:* ${json.year}\n
• *Rated:* ${json.rated}\n
• *Released:* ${json.released}\n
• *Runtime:* ${json.runtime}\n
• *Genres:* ${json.genres}\n
• *Director:* ${json.director}\n
• *Writer:* ${json.writer}\n
• *Actors:* ${json.actors}\n
• *Plot:* ${json.plot}\n
• *Languages:* ${json.languages}\n
• *Country:* ${json.country}\n
• *Awards:* ${json.awards}\n
• *Metascore:* ${json.metascore}\n
• *Rating:* ${json.rating}\n
• *Votes:* ${json.votes}\n
• *IMDB ID:* ${json.imdbid}\n
• *Type:* ${json.type}\n
• *DVD:* ${json.dvd}\n
• *Box Office:* ${json.boxoffice}\n
• *Production:* ${json.production}\n
• *Website:* ${json.website}\n\n
*Ratings:*\n${ratings}`;

// send the movie poster along with the movie information as caption
await conn.sendFile(m.chat, json.poster, 'poster.jpg', movieInfo, m);
} catch (error) {
console.error(error);
// Handle the error appropriately
}
};

handler.help = ['movie'];
handler.tags = ['information'];
handler.command = /^(imdb|movie)$/i;

export default handler;

0 comments on commit 47609b2

Please sign in to comment.