Skip to content

Developer Guides

Lexes Jan Mantiquilla edited this page Jul 18, 2021 · 20 revisions

Adding Page Support

In order to add page support, you will need to create a new Page class in the pages folder. This Page class is mainly used to detect the anime and the episode. You can use the other implemented pages for completed examples.

Adding page support consists of:

  1. Creating a new folder with the name of the page you want to support in the pages folder
  2. Creating an index.ts file containing an implementation of the Page class
  3. Creating a metadata.json file and adding the page URLs of the page
  4. Registering the new page in the PageFactory class

Creating the Page class

The Page interface outlines all the methods which are used when detecting the anime and episode number used to retrieve the skip times. The BasePage class implements the applyRules() and getMalId() functions. You must extend the BasePage class and implement the getTitle(), getIdentifier() and getRawEpisodeNumber() functions.

The general layout of a page class will look like the following:

import BasePage from '../base_page';

class PageName extends BasePage {
  constructor(hostname: string, pathname: string, document: Document) {
    super(hostname, pathname, document);
  }

  getTitle() {
    ...
  }

  getIdentifier() {
    ...
  }

  getRawEpisodeNumber() {
    ...
  }
}

The getTitle() is used as a backup to MALSync's API. If the anime information cannot be found using the MALSync API, this title will be used to search the AniList database for possible matches. This title should be the title with spaces and can be in English or Romanized Japanese. In general this can be found somewhere on the page and you would use document query selectors to retrieve the title. Ensure that this title does not include the episode number in it e.g. '... Episode 10'.

The getIdentifier() is used to query the MALSync API. It has to be in the form which MALSync uses. If you are unsure what the identifier looks like for the page you want to support, you can take a look at the database backup. In general, the identifier can be found in the URL of the website but this is not always the case.

// TODO getRawEpisodeNumber()

// TODO Adding the Page URLs of the Ppage

// TODO Registering the New Page

Clone this wiki locally