Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix redis #611

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
PORT=Port number of the server. (optional)
GOGO_CUSTOM_DOMAIN=Custom domain name for gogoanime (optional) (e.g. anitaku.so)
ZORO_CUSTOM_DOMAIN=Custom domain name for zoro (optional) (e.g. hianime.to)
BILIBILI_COOKIE=Cookie for Bilibili (optional)
PROXY=Proxies for requests (optional) (e.g. ["https://proxy1.com", "https://proxy2.com"])
REDIS_HOST=Redis host (optional)
REDIS_PORT=Redis port (optional)
REDIS_PASSWORD=Redis password (optional)
NINE_ANIME_HELPER_URL=9anime (optional)
TMDB_KEY=TMDB access token auth (optional)
NODE_ENV=Environment (optional) (DEMO or PROD)
NODE_ENV=Environment (optional) (DEMO or PROD)
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ Check out the `.env.example` file for more information.

You can add `-d` flag to run the server in detached mode.

You can add `GOGO_CUSTOM_DOMAIN` and `ZORO_CUSTOM_DOMAIN` as custom domain configarations for gogoanime and zoro in your environment variables respectively, (optional).

### Heroku
Host your own instance of Consumet API on Heroku using the button below.

Expand Down
6 changes: 1 addition & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ import Utils from './utils';

export const redis =
process.env.REDIS_HOST &&
new Redis({
host: process.env.REDIS_HOST,
port: Number(process.env.REDIS_PORT),
password: process.env.REDIS_PASSWORD,
});
new Redis(`rediss://default:${process.env.REDIS_PASSWORD}@${process.env.REDIS_HOST}:${process.env.REDIS_PORT}`);

const fastify = Fastify({
maxParamLength: 1000,
Expand Down
2 changes: 1 addition & 1 deletion src/routes/anime/gogoanime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { redis } from '../../main';
import { Redis } from 'ioredis';

const routes = async (fastify: FastifyInstance, options: RegisterOptions) => {
const gogoanime = new ANIME.Gogoanime();
const gogoanime = new ANIME.Gogoanime(process.env.GOGO_CUSTOM_DOMAIN);
const redisCacheTime = 60 * 60;
const redisPrefix = 'gogoanime:';

Expand Down
2 changes: 1 addition & 1 deletion src/routes/anime/zoro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ANIME } from '@consumet/extensions';
import { StreamingServers } from '@consumet/extensions/dist/models';

const routes = async (fastify: FastifyInstance, options: RegisterOptions) => {
const zoro = new ANIME.Zoro();
const zoro = new ANIME.Zoro(process.env.ZORO_CUSTOM_DOMAIN);

fastify.get('/', (_, rp) => {
rp.status(200).send({
Expand Down
2 changes: 1 addition & 1 deletion src/routes/meta/anilist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ const routes = async (fastify: FastifyInstance, options: RegisterOptions) => {
'/watch/:episodeId',
async (request: FastifyRequest, reply: FastifyReply) => {
const episodeId = (request.params as { episodeId: string }).episodeId;
const provider = (request.query as { provider?: string }).provider;
const provider = (request.query as { provider?: string }).provider || 'gogoanime';
const server = (request.query as { server?: StreamingServers }).server;

if (server && !Object.values(StreamingServers).includes(server))
Expand Down