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.
To contribute to Consumet code, you need to know the following:
- Nodejs
- TypeScript
- Web scraping
- Fork the repository
- 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
- Create a new branch:
git checkout -b <new-branch-name>
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
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
ProviderBase <|-- BaseParser
ProviderBase : +String name
ProviderBase : +String baseUrl
ProviderBase: +toString()
BaseParser <|-- AnimeParser
BaseParser <|-- BookParser
BaseParser <|-- MangaParser
BaseParser <|-- LightNovelParser
BaseParser <|-- ComicParser
BaseParser <|-- MovieParser
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)
}
- Create a new file in the
src/providers/<category>/<provider-name>.ts
folder. - 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 classAnimeParser
, which is defined in thesrc/models/anime-parser.ts
file. - Start writing your provider code.
- Add the provider to the
src/providers/<category>/index.ts
file.
- Update the documentation.
- Commit the changes.
- Update the provider code.
- Commit the changes.
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 existingfix:
A fix, for example of a bugrefactor:
Refactoring a specific section of the codebasetest:
Everything related to testingdocs:
Everything related to documentationchore:
Code maintenance
Examples:
feat: Speed up parsing with new technique
fix: Fix 9anime search
refactor: Reformat code at 9anime.ts