mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
[scraper] encode uri component for kitsu id query
This commit is contained in:
@@ -40,7 +40,7 @@ async function getCatalog(apiKey, offset = 0) {
|
|||||||
return AD.magnet.status()
|
return AD.magnet.status()
|
||||||
.then(response => response.data.magnets)
|
.then(response => response.data.magnets)
|
||||||
.then(torrents => (torrents || [])
|
.then(torrents => (torrents || [])
|
||||||
.filter(torrent => statusReady(torrent.statusCode))
|
.filter(torrent => torrent && statusReady(torrent.statusCode))
|
||||||
.map(torrent => ({
|
.map(torrent => ({
|
||||||
id: `${KEY}:${torrent.id}`,
|
id: `${KEY}:${torrent.id}`,
|
||||||
type: Type.OTHER,
|
type: Type.OTHER,
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ async function getCatalog(apiKey, offset = 0) {
|
|||||||
return _getAllTorrents(RD)
|
return _getAllTorrents(RD)
|
||||||
.then(torrents => Array.isArray(torrents) ? torrents : [])
|
.then(torrents => Array.isArray(torrents) ? torrents : [])
|
||||||
.then(torrents => torrents
|
.then(torrents => torrents
|
||||||
.filter(torrent => statusReady(torrent.status))
|
.filter(torrent => torrent && statusReady(torrent.status))
|
||||||
.map(torrent => ({
|
.map(torrent => ({
|
||||||
id: `${KEY}:${torrent.id}`,
|
id: `${KEY}:${torrent.id}`,
|
||||||
type: Type.OTHER,
|
type: Type.OTHER,
|
||||||
|
|||||||
@@ -124,9 +124,10 @@ async function getKitsuId(info) {
|
|||||||
const title = escapeTitle(info.title.replace(/\s\|\s.*/, ''));
|
const title = escapeTitle(info.title.replace(/\s\|\s.*/, ''));
|
||||||
const year = info.year ? ` ${info.year}` : '';
|
const year = info.year ? ` ${info.year}` : '';
|
||||||
const season = info.season > 1 ? ` S${info.season}` : '';
|
const season = info.season > 1 ? ` S${info.season}` : '';
|
||||||
const query = `${title}${year}${season}`;
|
const key = `${title}${year}${season}`;
|
||||||
|
const query = encodeURIComponent(key);
|
||||||
|
|
||||||
return cacheWrapKitsuId(query,
|
return cacheWrapKitsuId(key,
|
||||||
() => needle('get', `${KITSU_URL}/catalog/series/kitsu-anime-list/search=${query}.json`, { open_timeout: 60000 })
|
() => needle('get', `${KITSU_URL}/catalog/series/kitsu-anime-list/search=${query}.json`, { open_timeout: 60000 })
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
const body = response.body;
|
const body = response.body;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ async function scrapeLatestTorrents() {
|
|||||||
|
|
||||||
async function scrapeLatestTorrentsForCategory(category, page = 1) {
|
async function scrapeLatestTorrentsForCategory(category, page = 1) {
|
||||||
console.log(`Scrapping ${NAME} ${category} category page ${page}`);
|
console.log(`Scrapping ${NAME} ${category} category page ${page}`);
|
||||||
return nyaasi.browse(({ page }))
|
return nyaasi.browse({ page, sort: 'id' })
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.warn(`Failed ${NAME} scrapping for [${page}] ${category} due: `, error);
|
console.warn(`Failed ${NAME} scrapping for [${page}] ${category} due: `, error);
|
||||||
return Promise.resolve([]);
|
return Promise.resolve([]);
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ async function scrapeLatestTorrents() {
|
|||||||
|
|
||||||
async function scrapeLatestTorrentsForCategory(category, page = 1) {
|
async function scrapeLatestTorrentsForCategory(category, page = 1) {
|
||||||
console.log(`Scrapping ${NAME} ${category} category page ${page}`);
|
console.log(`Scrapping ${NAME} ${category} category page ${page}`);
|
||||||
return thepiratebay.browse(({ category, page }))
|
return thepiratebay.browse({ category, page })
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.warn(`Failed ${NAME} scrapping for [${page}] ${category} due: `, error);
|
console.warn(`Failed ${NAME} scrapping for [${page}] ${category} due: `, error);
|
||||||
return Promise.resolve([]);
|
return Promise.resolve([]);
|
||||||
|
|||||||
Reference in New Issue
Block a user