Sources
The Enma library is a powerful tool for accessing and managing manga data from various sources. To further enhance its capabilities and functionalities, Enma allows for contributions by extending it with custom sources. This guide provides an overview of how you can contribute to the Enma library by adding your own manga sources.
Defining a New Source [ Optional ]
Create Custom Sources Enum
First, create an enumeration (enum
) that extends SourcesEnum
from Enma, including all existing sources and your new custom source.
Implement the IMangaRepository
Interface
IMangaRepository
InterfaceFor your source to be compatible with Enma, it must implement the IMangaRepository interface. This means your source class to respect the contract shown below:
Each method should be implemented according to the specifications and operational logic of your custom source.
Enhance with Caching
Integrate caching into your custom source to improve performance. For instance, you can decorate methods like get
, search
, or paginate
with caching logic, specifying the TTL (time to live) through environment variables to control cache expiration dynamically.
Registering and Using Your New Source
After defining your source and implementing IMangaRepository
, you need to register this new source with the Enma instance and set when to use it.
Instantiate Enma with Your Custom Source
Add Your Source to the Source Manager
Ensure that YourCustomSourceClass()
is an instance of your source class that implements IMangaRepository
.
Set Your Source as Active
Testing Your Source
After registering your custom source, it's important to test it to ensure it functions as expected. You can test basic functionalities like searching, getting a random manga, and more
Contributing custom sources to the Enma library not only enriches the tool with more options and diversity of content but also offers the opportunity to customize the manga browsing and reading experience. By following the steps outlined, you can easily add your own source, contributing to the Enma community and expanding the library's reach.
If you encounter any challenges or have improvements to suggest, consider contributing to the Enma project on GitHub, where the community can benefit from your contributions.
Last updated
Was this helpful?