Skip to content

Commit

Permalink
chore: add bananimes crawler
Browse files Browse the repository at this point in the history
  • Loading branch information
AXeL-dev committed Sep 17, 2022
1 parent d2a18ee commit d0841ea
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/app/crawlers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ import { WawAnimesCrawler } from './vostfr/wawanimes.crawler';
import { JetAnimesCrawler } from './vostfr/jetanimes.crawler';
import { AnimeCompletCrawler } from './vostfr/animecomplet.crawler';
import { AnimeMaxCrawler } from './vostfr/anime-max.crawler';
import { BanAnimesCrawler } from './vostfr/bananimes.crawler';

const crawlersList = {
vostfr: [
// keep the ones that provides precise release dates at the top
AnimeKoCrawler,
NekoSamaCrawler,
BanAnimesCrawler,
VoirAnimeCrawler,
VoirAnimeOrgCrawler,
VostAnimeyCrawler,
Expand Down
68 changes: 68 additions & 0 deletions src/app/crawlers/vostfr/bananimes.crawler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { LatestEpisodesCrawler } from '../abstract/latest-episodes.crawler';
import { ScraperService } from '../../services/scraper.service';
import { Episode } from '../../models/episode';
import { today, yesterday, dateBefore } from '../../helpers/date.helper';
import { Observable } from 'rxjs';
import { toNumber } from 'src/app/helpers/number.helper';

export class BanAnimesCrawler extends LatestEpisodesCrawler {
constructor(private scraper: ScraperService) {
super('BanAnimes', 'https://bananimes.com', 'vostfr');
this.filters = {
...this.filters,
number: (text: string) => {
const num = text.match(/Episode (\d+)/);
return toNumber(num?.length ? num[1] : text);
},
cover: (text: string) => {
return text.replace('-110x150', '');
},
date: (text: string) => {
if (
text.indexOf('mins ago') !== -1 ||
text.indexOf('hours ago') !== -1 ||
text.indexOf('heures ago') !== -1 ||
text.indexOf('minutes ago') !== -1
) {
return today();
} else if (
text.indexOf('1 day ago') !== -1 ||
text.indexOf('1 jour ago') !== -1
) {
return yesterday();
} else {
const matches = text.match(/(\d+) (?:days|jours) ago/);
if (matches?.length) {
return dateBefore(+matches[1]);
}
return new Date(text)?.getTime();
}
},
};
}

_getLatestEpisodes(): Observable<Episode[]> {
return this.scraper.scrape(
`${this.baseUrl}/?filter=VOSTFR`,
'#loop-content .page-item-detail',
{
anime: {
title: '.post-title h3 a',
cover: 'img.img-responsive@data-src,src | cover',
},
number: '.chapter-item:first-child .chapter a | number',
streamLinks: [
{
url: [
'.chapter-item:first-child .chapter a@href',
'.post-title h3 a@href',
],
lang: '| subtitles',
},
],
releaseDate: '.chapter-item:first-child .post-on | date',
},
this.filters
);
}
}

0 comments on commit d0841ea

Please sign in to comment.