Skip to content

Commit

Permalink
feat: Overhaul, bug fixes, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
Eltik committed Oct 18, 2024
1 parent 7f23755 commit 3f5f8b6
Show file tree
Hide file tree
Showing 76 changed files with 2,682 additions and 925 deletions.
42 changes: 24 additions & 18 deletions anify-backend/.env.example
Original file line number Diff line number Diff line change
@@ -1,42 +1,48 @@
# What port to listen to. Recommended but not required.
PORT=3060
# Database URL for PostgreSQL. If not given, will default to SQLite.

# Database URL for PostgreSQL. If not given, will default to using SQLite.
DATABASE_URL="postgresql://postgres:password@localhost:5432/?connection_limit=100"

# Censys credentials used for proxy fetching. You can visit https://search.censys.io/account/api,
# create an account, and get the ID and secret. Highly recommended if not required as some providers
# will not work without proxies.
#
# Censys ID used for finding CORS proxies https://search.censys.io/account/api. Required for proxies to work properly.
CENSYS_ID=""
# Censys secret used for finding CORS proxies https://search.censys.io/account/api. Requirded for proxies to work properly.
CENSYS_SECRET=""

# 9anime resolver URL. Private server that can be obtained via the Consumet Discord if necessary. Required for 9anime to work properly.
# https://discord.gg/yMZTcVstD3
#
NINEANIME_RESOLVER="https://9anime.myresolver.com"
# 9anime resolver API key. Required for 9anime to work properly.
NINEANIME_KEY="9anime"
# NovelUpdates cookies for login purposes. If you have questions join the Anify Discord (https://anify.tv/discord)

# NovelUpdates cookies for login purposes. Visit the NovelUpdates website, create an account, and login.
# Then, visit a novel info page (eg. https://novelupdates.com/novel/overgeared/), inspect element,
# go to the network tab, click on the HTML request, and find the cookie that says
# "wordpress_logged_in_..." and copy the value. If not given, the backend should work fine, but
# the NovelUpdates provider will not work.
#
# Required for NovelUpdates to work properly for chapter fetching.
NOVELUPDATES_LOGIN=""

# Redis caching. Recommended for optimized performance. The backend will still work
# without Redis, but may face performance issues.
#
# Redis URL. Recommended but not required.
REDIS_URL="redis://localhost:6379"
# Redis cache time in seconds. 18000 = 5 hours. Required for Redis to work properly.
REDIS_CACHE_TIME="18000"

# Mixdrop related for uploads. Not required.
# Mixdrop related for uploads. Not required as this is mainly used for manga and novel uploading.
# Signup via https://mixdrop.ag, then view the developer page to get an API key.
#
# Whether to use Mixdrop
USE_MIXDROP="true"
# Mixdrop Email
MIXDROP_EMAIL="myemail@outlook.com"
# Mixdrop API key
MIXDROP_KEY="mixdrop_key"

# Related to subtitles and injecting custom text to all subtitles. Not required.
# Secret key for URL encryption. Allows for encrypted subtitle URLs.
SECRET_KEY="anify"
# The text to inject into all subtitles. Can be left blank.
TEXT_TO_INJECT="Provided by anify.tv"
# The distance from the injected text in seconds. 300 = 5 minutes.
DISTANCE_FROM_INJECTED_TEXT_SECONDS=300
# The cache time for subtitle URLs in seconds. 60 * 60 * 12 = 12 hours.
SUBTITLES_CACHE_TIME="60 * 60 * 12"
# Public URL for the API. Required for subtitle spoofing to work properly.
API_URL="https://api.anify.tv"
# Whether to use subtitle spoofing. Required for subtitle spoofing to work properly.
USE_SUBTITLE_SPOOFING="true"
MIXDROP_KEY="mixdrop_key"
18 changes: 0 additions & 18 deletions anify-backend/.eslintrc.cjs

This file was deleted.

3 changes: 2 additions & 1 deletion anify-backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,5 @@ dist
/manga
db.sqlite
keys.json
bannedIds.json
bannedIds.json
test.ts
40 changes: 40 additions & 0 deletions anify-backend/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
{
ignores: ["dist/*", "node_modules/*", "**/.DS_Store"],
},
...compat.extends("plugin:@typescript-eslint/recommended"),
{
plugins: {
"@typescript-eslint": typescriptEslint,
},

languageOptions: {
parser: tsParser,
ecmaVersion: 5,
sourceType: "script",

parserOptions: {
project: "tsconfig.json",
},
},

rules: {
"@typescript-eslint/no-explicit-any": "off",
},
},
];
9 changes: 6 additions & 3 deletions anify-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"import": "bun run src/scripts/import.ts",
"clear": "bun run src/scripts/clear.ts",
"check:proxies": "bun run src/scripts/checkProxies.ts",
"check:proxies:current": "bun run src/scripts/checkCurrentProxies.ts",
"scrape:proxies": "bun run src/scripts/scrapeProxies.ts",
"build": "bun build ./src/index.ts --outdir ./dist --target node",
"build:db": "bun run src/scripts/buildDb.ts",
Expand All @@ -19,14 +20,16 @@
"lint": "bun run prettier && bun run eslint"
},
"devDependencies": {
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.10.0",
"@types/crypto-js": "^4.1.2",
"@types/pdfkit": "^0.12.10",
"@types/pg": "^8.10.7",
"@typescript-eslint/eslint-plugin": "^6.19.1",
"bun-types": "latest",
"eslint": "^8.56.0",
"eslint": "^9.10.0",
"prettier": "^3.0.3",
"tsc": "^2.0.4"
"tsc": "^2.0.4",
"typescript-eslint": "^8.6.0"
},
"peerDependencies": {
"typescript": "^5.0.0"
Expand Down
2 changes: 1 addition & 1 deletion anify-backend/src/content/impl/chapters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const fetchChapters = async (id: string): Promise<ChapterData[]> => {
});
}
return true;
} catch (e) {
} catch {
return false;
}
});
Expand Down
2 changes: 1 addition & 1 deletion anify-backend/src/content/impl/episodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const fetchEpisodes = async (id: string): Promise<EpisodeData[]> => {
});
}
return true;
} catch (e) {
} catch {
return false;
}
});
Expand Down
2 changes: 1 addition & 1 deletion anify-backend/src/content/impl/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const fetchMetaData = async (id: string): Promise<ContentMetadata[]> => {
});
}
return true;
} catch (e) {
} catch {
return false;
}
});
Expand Down
2 changes: 1 addition & 1 deletion anify-backend/src/content/impl/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const fetchPages = async (providerId: string, readId: string): Promise<st
});
if (!data) return null;
return data;
} catch (e) {
} catch {
return null;
}
};
2 changes: 1 addition & 1 deletion anify-backend/src/content/impl/sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const fetchSources = async (providerId: string, watchId: string, subType:

if (!data) return null;
return data;
} catch (e) {
} catch {
return null;
}
};
8 changes: 4 additions & 4 deletions anify-backend/src/database/impl/fetch/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const get = async (id: string, fields: string[] = []): Promise<Anime | Ma
}

return data as unknown as Anime | Manga;
} catch (e) {
} catch {
return undefined;
}
} else {
Expand All @@ -47,7 +47,7 @@ export const get = async (id: string, fields: string[] = []): Promise<Anime | Ma
}

return data as unknown as Anime | Manga;
} catch (e) {
} catch {
return undefined;
}
}
Expand Down Expand Up @@ -83,7 +83,7 @@ export const get = async (id: string, fields: string[] = []): Promise<Anime | Ma
}

return parsedManga as unknown as Manga;
} catch (e) {
} catch {
return undefined;
}
} else {
Expand Down Expand Up @@ -113,7 +113,7 @@ export const get = async (id: string, fields: string[] = []): Promise<Anime | Ma
}

return parsedAnime as unknown as Anime;
} catch (e) {
} catch {
return undefined;
}
}
Expand Down
4 changes: 2 additions & 2 deletions anify-backend/src/database/impl/fetch/media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export const media = async (providerId: string, id: string, fields: string[] = [
}

return parsedManga as unknown as Manga;
} catch (e) {
} catch {
return undefined;
}
}
Expand Down Expand Up @@ -138,7 +138,7 @@ export const media = async (providerId: string, id: string, fields: string[] = [
}

return parsedAnime as unknown as Anime;
} catch (e) {
} catch {
return undefined;
}
};
10 changes: 5 additions & 5 deletions anify-backend/src/database/impl/fetch/recent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const recent = async <T extends "ANIME" | "MANGA">(type: T, formats: Form
}
});
}
} catch (e) {
} catch {
//
}

Expand Down Expand Up @@ -136,7 +136,7 @@ export const recent = async <T extends "ANIME" | "MANGA">(type: T, formats: Form
characters: JSON.parse(anime.characters),
}) as unknown as Anime,
);
} catch (e) {
} catch {
continue;
}
}
Expand All @@ -155,7 +155,7 @@ export const recent = async <T extends "ANIME" | "MANGA">(type: T, formats: Form
}
});
}
} catch (e) {
} catch {
//
}

Expand Down Expand Up @@ -202,7 +202,7 @@ export const recent = async <T extends "ANIME" | "MANGA">(type: T, formats: Form
characters: JSON.parse(manga.characters),
}) as unknown as Manga,
);
} catch (e) {
} catch {
continue;
}
}
Expand All @@ -221,7 +221,7 @@ export const recent = async <T extends "ANIME" | "MANGA">(type: T, formats: Form
}
});
}
} catch (e) {
} catch {
//
}

Expand Down
4 changes: 2 additions & 2 deletions anify-backend/src/database/impl/fetch/relations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const relations = async (id: string, fields: string[] = []): Promise<Anim
}
});
}
} catch (e) {
} catch {
return undefined;
}

Expand Down Expand Up @@ -146,7 +146,7 @@ export const relations = async (id: string, fields: string[] = []): Promise<Anim

return data;
}
} catch (e) {
} catch {
return undefined;
}
})
Expand Down
4 changes: 2 additions & 2 deletions anify-backend/src/database/impl/fetch/seasonal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const seasonal = async (trending: AnimeInfo[] | MangaInfo[], popular: Ani
characters: JSON.parse(media.characters),
});
return parsedAnime as unknown as Anime;
} catch (e) {
} catch {
return undefined;
}
} else {
Expand All @@ -79,7 +79,7 @@ export const seasonal = async (trending: AnimeInfo[] | MangaInfo[], popular: Ani
});

return parsedManga as unknown as Manga;
} catch (e) {
} catch {
return undefined;
}
}
Expand Down
6 changes: 3 additions & 3 deletions anify-backend/src/database/impl/modify/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const create = async (data: Anime | Manga, stringify: boolean = true) =>
artwork: data.artwork ? JSON.parse((data as any).artwork) : null,
characters: data.characters ? JSON.parse((data as any).characters) : null,
});
} catch (e) {
} catch {
//
}
}
Expand All @@ -36,7 +36,7 @@ export const create = async (data: Anime | Manga, stringify: boolean = true) =>
Object.assign(data, {
episodes: JSON.parse((data as any).episodes),
});
} catch (e) {
} catch {
//
}
}
Expand Down Expand Up @@ -146,7 +146,7 @@ export const create = async (data: Anime | Manga, stringify: boolean = true) =>
Object.assign(data, {
chapters: JSON.parse((data as any).chapters),
});
} catch (e) {
} catch {
//
}
}
Expand Down
2 changes: 1 addition & 1 deletion anify-backend/src/database/impl/search/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export const search = async <T extends Type.ANIME | Type.MANGA>(

return data;
}
} catch (e) {
} catch {
return undefined;
}
});
Expand Down
2 changes: 1 addition & 1 deletion anify-backend/src/database/impl/search/searchAdvanced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export const searchAdvanced = async <T extends Type.ANIME | Type.MANGA>(

return data;
}
} catch (e) {
} catch {
return undefined;
}
});
Expand Down
Loading

0 comments on commit 3f5f8b6

Please sign in to comment.