File size: 2,181 Bytes
290c0c4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import axios from 'axios';
import config from '../../config.cjs';

const imdb = async (m, gss) => {
  try {
    const prefix = config.PREFIX;
const cmd = m.body.startsWith(prefix) ? m.body.slice(prefix.length).split(' ')[0].toLowerCase() : '';
const text = m.body.slice(prefix.length + cmd.length).trim();

    const validCommands = ['imdb'];

    if (!validCommands.includes(cmd)) return;

    if (!text) return m.reply('Give me a series or movie name');

    let fids = await axios.get(`http://www.omdbapi.com/?apikey=742b2d09&t=${encodeURIComponent(text)}&plot=full`);
    let imdbt = "";
    
    if (fids.data.Response === "False") {
      return m.reply('Movie or series not found');
    }

    imdbt += "⚍⚎⚎⚎⚎⚎⚎⚎⚎⚎⚎⚎⚎⚎⚎⚍\n";
    imdbt += " ```IMDB SEARCH```\n";
    imdbt += "⚎⚎⚎⚎⚎⚎⚎⚎⚎⚎⚎⚎⚎⚎⚎⚎\n";
    imdbt += `🎬Title      : ${fids.data.Title}\n`;
    imdbt += `📅Year       : ${fids.data.Year}\n`;
    imdbt += `⭐Rated      : ${fids.data.Rated}\n`;
    imdbt += `📆Released   : ${fids.data.Released}\n`;
    imdbt += `⏳Runtime    : ${fids.data.Runtime}\n`;
    imdbt += `🌀Genre      : ${fids.data.Genre}\n`;
    imdbt += `👨🏻‍💻Director   : ${fids.data.Director}\n`;
    imdbt += `✍Writer     : ${fids.data.Writer}\n`;
    imdbt += `👨Actors     : ${fids.data.Actors}\n`;
    imdbt += `📃Plot       : ${fids.data.Plot}\n`;
    imdbt += `🌐Language   : ${fids.data.Language}\n`;
    imdbt += `🌍Country    : ${fids.data.Country}\n`;
    imdbt += `🎖️Awards     : ${fids.data.Awards}\n`;
    imdbt += `📦BoxOffice  : ${fids.data.BoxOffice}\n`;
    imdbt += `🏙️Production : ${fids.data.Production}\n`;
    imdbt += `🌟imdbRating : ${fids.data.imdbRating}\n`;
    imdbt += `✅imdbVotes  : ${fids.data.imdbVotes}\n`;

    await gss.sendMessage(m.from, {
      image: {
        url: fids.data.Poster,
      },
      caption: imdbt,
    }, {
      quoted: m,
    });
  } catch (error) {
    console.error('Error:', error);
    m.reply('An error occurred while fetching the data.');
  }
};

export default imdb;