Skip to content

Latest commit

 

History

History
167 lines (145 loc) · 5.98 KB

CONTRIBUTING.md

File metadata and controls

167 lines (145 loc) · 5.98 KB

Contributing

This guide is for the people who are interested in contributing to consumet.ts. It is not a complete guide yet, but it should help you get started. If you have any questions or any suggestions, please open a issue or join the discord server.

See our informal contributing guide for more details on contributing to this project.

Table of Contents

Prerequisites

To contribute to Consumet code, you need to know the following:

Cloning the repository

  1. Fork the repository
  2. Clone your fork to your local machine using the following command (make sure to change <your_username> to your GitHub username):
git clone https://github.com/<your-username>/consumet-api.git
  1. Create a new branch:
git checkout -b <new-branch-name>

Project structure

I believe that project structure is needed to make it simple to contribute to consumet.ts.

<category> is the category of the provider. For example, anime or book, etc.
<provider-name> is the name of the provider. For example, libgen or gogoanime, etc. (must be in camel case)

> tree
docs/
├── guides/
|   ├── ...
|   ├── anime.md
|   ├── getting-started.md
│   └── contributing.md (informal guide)
├── providers/
│   └── <provider-name>.md (provider documentation)
├── README.md
src/
├── index.ts
|── models
├── providers
│   ├── <category>
│   │   ├── index.ts
│   │   └── <provider-name>.ts
│   └── <category>
└── utils

Writing a provider

Each provider is a class that extends abstract class. For example, Libgen provider extends BooksParser class, and Gogoanime extends AnimeParser. the parser abstract classes can be found in the src/models/ folder as follows:

src/models/anime-parser.ts # AnimeParser
src/models/book-parser.ts  # BookParser
src/models/lightnovel-parser.ts  # LightNovelParser
src/models/comic-parser.ts # ComicParser
src/models/manga-parser.ts # MangaParser
src/models/movie-parser.ts # MovieParser

You are welcome to add anything to the abstract class that you believe will be beneficial.

visualization of the abstract classes hierarchy
classDiagram
      Proxy <|-- BaseProvider
      BaseProvider <|-- BaseParser
      BaseProvider : +String name
      BaseProvider : +String baseUrl
      BaseProvider: +toString()
      BaseParser <|-- AnimeParser
      BaseParser <|-- BookParser
      BaseParser <|-- MangaParser
      BaseParser <|-- LightNovelParser
      BaseParser <|-- ComicParser
      BaseParser <|-- MovieParser
      class Proxy{
         ProxyConfig
      }
      class BaseParser{
         +search(String query)
      }
      class AnimeParser{
         +fetchAnimeInfo(String animeId)
         +fetchEpisodeSources(String episodeId)
         +fetchEpisodeServers(String episodeId)
      }
      class MovieParser{
         +fetchMediaInfo(String mediaId)
         +fetchEpisodeSources(String episodeId)
         +fetchEpisodeServers(String episodeId)
      }
      class BookParser{
         empty
      }
      class MangaParser{
         +fetchMangaInfo(String mangaId)
         +fetchChapterPages(String chapterId)
      }
      class ComicParser{
         empty
      }
      class LightNovelParser{
         +fetchLighNovelInfo(String lightNovelId)
         +fetchChapterContent(String chapterId)
      }

Setting up the provider

  1. Create a new file in the src/providers/<category>/<provider-name>.ts folder.
  2. Import the abstract class from the src/models/<category>-parser.ts file. for example: if you are writing an anime provider, you would need to implement the abstract class AnimeParser, which is defined in the src/models/anime-parser.ts file.
  3. Start writing your provider code.
  4. Add the provider to the src/providers/<category>/index.ts file.

Updaing codebase

Updating documentation

  1. Update the documentation.
  2. Commit the changes.

Fixing a provider

  1. Update the provider code.
  2. Commit the changes.

Commit message

When you've made changes to one or more files, you have to commit that file. You also need a message for that commit.

You should read these guidelines, or that summarized:

  • Short and detailed
  • Prefix one of these commit types:
    • feat: A feature, possibly improving something already existing
    • fix: A fix, for example of a bug
    • refactor: Refactoring a specific section of the codebase
    • test: Everything related to testing
    • docs: Everything related to documentation
    • chore: Code maintenance

Examples:

  • feat: Speed up parsing with new technique
  • fix: Fix 9anime search
  • refactor: Reformat code at 9anime.ts