-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { LatestEpisodesCrawler } from '../abstract/latest-episodes.crawler'; | ||
import { ScraperService } from '../../services/scraper.service'; | ||
import { Episode } from '../../models/episode'; | ||
import { Observable } from 'rxjs'; | ||
import { frenchMonths } from 'src/app/helpers/date.helper'; | ||
|
||
export class AnimeCompletCrawler extends LatestEpisodesCrawler { | ||
constructor(private scraper: ScraperService) { | ||
super('AnimeComplet', 'https://animecomplet.me'); | ||
this.filters = { | ||
...this.filters, | ||
title: (text: string) => { | ||
return text.replace(/vostfr/i, '').trim(); | ||
}, | ||
number: (text: string) => { | ||
const num = text.match(/Episode (\d+)/i); | ||
return num?.length ? +num[1] : 1; | ||
}, | ||
subtitles: (text: string) => { | ||
const sub = text.match(/Episode (?:\d+) (\w+)$/i); | ||
return sub?.length ? sub[1].toLowerCase() : 'vostfr'; | ||
}, | ||
date: (text: string) => { | ||
let date = text.toLowerCase(); | ||
date = date | ||
.replace( | ||
new RegExp('(' + Object.keys(frenchMonths).join('|') + ')', 'g'), | ||
(month) => frenchMonths[month] | ||
) | ||
.trim(); | ||
date = date.split(' ').reverse().join('-'); | ||
return new Date(date)?.getTime(); | ||
}, | ||
}; | ||
} | ||
|
||
_getLatestEpisodes(): Observable<Episode[]> { | ||
return this.scraper.scrape( | ||
`${this.baseUrl}`, | ||
'ul.recent-posts > li', | ||
{ | ||
anime: { | ||
title: '.post-content .meta-category > a | title', | ||
cover: '.post-thumb img@src | concatUrl', | ||
}, | ||
number: '.post-content > h2 > a | number', | ||
streamLinks: [ | ||
{ | ||
url: '.post-content > h2 > a@href', | ||
lang: '.post-content > h2 > a | subtitles', | ||
}, | ||
], | ||
releaseDate: '.post-content .meta-date | date', | ||
}, | ||
this.filters | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters