npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

filmaffinity-api-unofficial

v1.1.1

Published

A TypeScript library to scrape movie information from Filmaffinity

Readme

Filmaffinity Scraper

A TypeScript library to scrape movie information from Filmaffinity.

Installation

npm install filmaffinity-api-unofficial

Usage

JavaScript

const { FilmaffinityScraper } = require('filmaffinity-scraper');

async function example() {
    const scraper = new FilmaffinityScraper();
    try {
        // Example: Search for a movie
        const searchResults = await scraper.searchMovies("thor 2");
        console.log(searchResults);

        // If you find a movie, you can get its details
        if (searchResults.length > 0 && searchResults[0].url) {
            const movieDetails = await scraper.getMovie(searchResults[0].url);
            console.log(movieDetails);

            // Get movie trailers
            if (movieDetails?.trailersUrl) {
              const trailers = await scraper.getTrailers(movieDetails.trailersUrl);
              console.log(trailers);
            }
        }
    } catch (error) {
        console.error("Error:", error);
    }
}

TypeScript

const { FilmaffinityScraper, MovieInfo, TrailerInfo, MovieSearchResult } = require('filmaffinity-scraper');

async function example(): Promise<void> {
  const scraper = new FilmaffinityScraper();
  
  // Get movie information
  const movieUrl = 'https://www.filmaffinity.com/es/film123456.html';
  const movieInfo: MovieInfo | null = await scraper.getMovie(movieUrl);
  console.log(movieInfo);
  
  // Get movie trailers
  if (movieInfo?.trailersUrl) {
    const trailers: TrailerInfo[] | null = await scraper.getTrailers(movieInfo.trailersUrl);
    console.log(trailers);
  }

  // Search movies by title
  const searchResults: MovieSearchResult[] = await scraper.searchMovies('La hora fatal');
  console.log(searchResults);
}

Example Responses

Movie Information

{
  title: 'La hora fatal (Mr. Wong en el cuartel)',
  year: '1940',
  duration: '68 min.',
  country: 'Estados Unidos',
  director: 'William Nigh',
  genres: [ 'Intriga', 'Thriller', 'Cine negro' ],
  cast: [
    'Boris Karloff',
    'Marjorie Reynolds',
    'Grant Withers',
    'Charles Trowbridge',
    'Frank Puglia',
    'Craig Reynolds',
    'Lita Chevret',
    'Harry Strang',
    'Hooper Atchley',
    'Jason Robards Sr.',
    'Richard Loo'
  ],
  synopsis: 'James Lee Wong investiga el asesinato de un oficial de policía durante el robo a una joyería. Bobbie Logan es una temeraria reportera que intentará seguir los pasos del inspector oriental Wong para conseguir la exclusiva. (FILMAFFINITY)',
  imageUrl: 'https://pics.filmaffinity.com/the_fatal_hour-580434775-mmed.jpg',
  largeImageUrl: 'https://pics.filmaffinity.com/the_fatal_hour-580434775-large.jpg',
  countryImageUrl: 'https://www.filmaffinity.com/imgs/countries2/US.png',
  trailersUrl: ''
}

Trailers Information

[
  {
    id: "vi2364450073",
    number: "1",
    title: "Tráiler (2:25)",
    iframeSrc: "https://www.filmaffinity.com/es/evideos.php?movie_id=123456"
  },
  {
    id: "vi2364450074",
    number: "2",
    title: "Tráiler 2 (1:53)",
    iframeSrc: "https://www.filmaffinity.com/es/evideos.php?movie_id=123456"
  }
]

Search Results

[
  {
    title: "La hora fatal (Mr. Wong en el cuartel)",
    imageUrl: "https://pics.filmaffinity.com/the_fatal_hour-580434775-mmed.jpg",
    url: "https://www.filmaffinity.com/mx/film123456.html",
    countryImageUrl: "https://www.filmaffinity.com/imgs/countries2/US.png"
  },
  // ... more results
]

Language Support

The scraper supports both Spanish (es) and English (en) languages. You can specify the language in three ways:

1. During initialization

// Default to Spanish
const scraper = new FilmaffinityScraper();

// Or specify English explicitly
const englishScraper = new FilmaffinityScraper('en');

2. Change language after initialization

const scraper = new FilmaffinityScraper();
scraper.setLanguage('en'); // Change to English
scraper.setLanguage('es'); // Change back to Spanish

3. Check current language

const currentLanguage = scraper.getLanguage(); // Returns 'es' or 'en'

The language setting affects all scraper operations, including movie searches and information retrieval. The scraper will automatically use the appropriate Filmaffinity domain (filmaffinity.com/es or filmaffinity.com/en) based on the selected language.

Types

MovieInfo

interface MovieInfo {
  title: string;
  year: string;
  duration: string;
  country: string | undefined;
  director: string;
  genres: string[];
  cast: string[];
  synopsis: string;
  imageUrl: string | undefined;
  largeImageUrl: string | undefined;
  countryImageUrl: string | null;
  trailersUrl: string;
}

TrailerInfo

interface TrailerInfo {
  id: string | undefined;
  number: string | undefined;
  title: string;
  iframeSrc: string | undefined;
}

MovieSearchResult

interface MovieSearchResult {
  title: string;
  imageUrl: string | undefined;
  url: string;
  countryImageUrl: string | null;
}

Features

  • Scrapes detailed movie information from Filmaffinity
  • Search movies by title
  • Supports both movie details and trailer information
  • Provides TypeScript type definitions
  • Returns high-quality movie poster images (both medium and large sizes)
  • Includes comprehensive movie metadata (title, year, duration, country, director, etc.)
  • Extracts full cast list and genres
  • Returns movie synopsis
  • Handles country flags/images

Development

To build the project:

npm run build

This will generate the JavaScript files and type definitions in the dist directory.

Error Handling

The scraper methods return:

  • null when movie information cannot be retrieved (getMovie)
  • Empty array [] when no search results are found (searchMovies)
  • null when:
    • The movie URL is invalid
    • The movie page is not accessible
    • The required information cannot be extracted

License

MIT