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

Apply fixes from CodeFactor #251

Merged
merged 2 commits into from
Feb 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions src/providers/anime/marin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class Marin extends AnimeParser {
protected override classPath = 'ANIME.Marin';

private async getToken(): Promise<string[]> {
let token: string[] = [];
const token: string[] = [];

let response = await axios.get('https://marin.moe/anime', {
const response = await axios.get('https://marin.moe/anime', {
headers: {
Referer: 'https://marin.moe/anime',
Cookie: '__ddg1_=;__ddg2_=;',
Expand All @@ -39,10 +39,10 @@ class Marin extends AnimeParser {
}

public recentEpisodes = async (page: number = 1): Promise<ISearch<IAnimeResult>> => {
let token = await this.getToken()
const token = await this.getToken()
let data;
try {
let response = await axios.post('https://marin.moe/anime',{"page" : page,"sort":"rel-d","filter":{"type":[],"status":[],"content_rating":[],"genre":[],"group":[],"production":[],"source":[],"resolution":[],"audio":[],"subtitle":[]},"search": ""}, {
const response = await axios.post('https://marin.moe/anime',{"page" : page,"sort":"rel-d","filter":{"type":[],"status":[],"content_rating":[],"genre":[],"group":[],"production":[],"source":[],"resolution":[],"audio":[],"subtitle":[]},"search": ""}, {
headers: {
Origin: 'https://marin.moe/',
Referer: 'https://marin.moe/anime',
Expand All @@ -57,7 +57,7 @@ class Marin extends AnimeParser {
} catch (error) {
console.log(error)
}
let response_data = {
const response_data = {
currentPage: page,
hasNextPage: data.props.anime_list.meta.last_page > page,
results: data.props.anime_list.data.map((el: any) => {
Expand All @@ -77,10 +77,10 @@ class Marin extends AnimeParser {
* @param query Search query
*/
override search = async (query: string, page: number = 1): Promise<ISearch<IAnimeResult>> => {
let token = await this.getToken()
const token = await this.getToken()
let data;
try {
let response = await axios.post('https://marin.moe/anime',{"page" : page,"sort":"az-a","filter":{"type":[],"status":[],"content_rating":[],"genre":[],"group":[],"production":[],"source":[],"resolution":[],"audio":[],"subtitle":[]},"search": query}, {
const response = await axios.post('https://marin.moe/anime',{"page" : page,"sort":"az-a","filter":{"type":[],"status":[],"content_rating":[],"genre":[],"group":[],"production":[],"source":[],"resolution":[],"audio":[],"subtitle":[]},"search": query}, {
headers: {
Origin: 'https://marin.moe/',
Referer: 'https://marin.moe/anime',
Expand All @@ -95,7 +95,7 @@ class Marin extends AnimeParser {
} catch (error) {
console.log(error)
}
let response_data = {
const response_data = {
currentPage: page,
hasNextPage: data.props.anime_list.meta.last_page > page,
results: data.props.anime_list.data.map((el: any) => {
Expand All @@ -117,7 +117,7 @@ class Marin extends AnimeParser {
override fetchAnimeInfo = async (id: string): Promise<IAnimeInfo> => {
let data;
try {
let response = await axios.get(`https://marin.moe/anime/${id}`, {
const response = await axios.get(`https://marin.moe/anime/${id}`, {
headers: {
Origin: 'https://marin.moe/',
Referer: `https://marin.moe/anime/${id}`,
Expand All @@ -135,9 +135,9 @@ class Marin extends AnimeParser {
}
let episodes: any[] = data.props.episode_list.data
if(data.props.anime.last_episode > 36) {
let token = await this.getToken()
const token = await this.getToken()
for (let index = 2; index < data.props.anime.last_episode / 36; index++) {
let response = await axios.post(`https://marin.moe/anime/${id}`, {"filter":{"episodes":true,"specials":true},"eps_page": index}, {
const response = await axios.post(`https://marin.moe/anime/${id}`, {"filter":{"episodes":true,"specials":true},"eps_page": index}, {
headers: {
Origin: 'https://marin.moe/',
Referer: `https://marin.moe/anime/${id}`,
Expand All @@ -150,13 +150,13 @@ class Marin extends AnimeParser {
"x-xsrf-token": token[1].split(';')[0].replace("%3D", "="),
},
});
let data = await response.data;
const data = await response.data;
episodes = episodes.concat(data.props.episode_list.data);
}
}
//{"filter":{"episodes":true,"specials":true},"eps_page":2}

let response_data: IAnimeInfo = {
const response_data: IAnimeInfo = {
id: id,
title: {
native: data.props.anime.alt_titles["Official Title"][0].text,
Expand Down Expand Up @@ -202,7 +202,7 @@ class Marin extends AnimeParser {
override fetchEpisodeSources = async (id: string, episodeNumber: number): Promise<ISource> => {
let data;
try {
let response = await axios.get(`https://marin.moe/anime/${id}/${episodeNumber}`, {
const response = await axios.get(`https://marin.moe/anime/${id}/${episodeNumber}`, {
headers: {
Origin: 'https://marin.moe/',
Referer: `https://marin.moe/anime/${id}/${episodeNumber}`,
Expand All @@ -219,7 +219,7 @@ class Marin extends AnimeParser {
console.log(error)
}

let response_data = {
const response_data = {
sources: data.props.video.data.mirror.map((el: any) => {
return {
url: el.code.file,
Expand Down Expand Up @@ -247,3 +247,7 @@ class Marin extends AnimeParser {

export default Marin;

//(async () => {
// const marin = new Marin();
// console.log(await marin.recentEpisodes(1));
//})();