adds kitsu mapping for horrible subs
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -88,8 +88,9 @@ async function getImdbId(info) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getKitsuId(title) {
|
async function getKitsuId(title) {
|
||||||
return cacheWrapImdbId(title,
|
const query = title.replace(/[;]+/g, ' ').replace(/[,%']+/g, '');
|
||||||
() => needle('get', `${KITSU_URL}/catalog/series/kitsu-anime-list/search=${title}.json`, { open_timeout: 60000 })
|
return cacheWrapImdbId(query,
|
||||||
|
() => 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;
|
||||||
if (body && body.metas && body.metas.length) {
|
if (body && body.metas && body.metas.length) {
|
||||||
|
|||||||
@@ -39,11 +39,12 @@ async function _scrapeAllShows() {
|
|||||||
|
|
||||||
async function initMapping() {
|
async function initMapping() {
|
||||||
console.log(`${NAME}: initiating kitsu mapping...`);
|
console.log(`${NAME}: initiating kitsu mapping...`);
|
||||||
|
const currentMapping = require('../horrible_subs_mapping');
|
||||||
|
const mappings = Object.values(currentMapping);
|
||||||
const shows = await horriblesubs.allShows()
|
const shows = await horriblesubs.allShows()
|
||||||
.then((shows) => Promise.all(shows.map((show) => limiter.schedule(() => enrichShow(show)))))
|
.then((shows) => shows.filter((show) => !mappings.find((mapping) => mapping.title === show.title)))
|
||||||
.then((shows) => shows.reduce((map, show) => (map[show.showId] = show, map), {}));
|
.then((shows) => Promise.all(shows.map((show) => limiter.schedule(() => enrichShow(show)))))
|
||||||
const kitsuIds = Object.values(shows).map((show) => show.kitsu_id);
|
.then((shows) => shows.reduce((map, show) => (map[show.title] = show, map), currentMapping));
|
||||||
console.log(JSON.stringify(kitsuIds));
|
|
||||||
|
|
||||||
fs.writeFile("./horrible_subs_mapping.json", JSON.stringify(shows), 'utf8', function (err) {
|
fs.writeFile("./horrible_subs_mapping.json", JSON.stringify(shows), 'utf8', function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
@@ -57,8 +58,7 @@ async function enrichShow(show) {
|
|||||||
console.log(`${NAME}: getting show info for ${show.title}...`);
|
console.log(`${NAME}: getting show info for ${show.title}...`);
|
||||||
const showId = await horriblesubs._getShowId(show.url)
|
const showId = await horriblesubs._getShowId(show.url)
|
||||||
.catch((error) => show.title);
|
.catch((error) => show.title);
|
||||||
const slug = show.url.replace(/^.*\//, '');
|
const metadata = await getKitsuId(show.title)
|
||||||
const metadata = await getKitsuId(slug)
|
|
||||||
.then((kitsuId) => getKitsuMetadata(kitsuId))
|
.then((kitsuId) => getKitsuMetadata(kitsuId))
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.log(`Failed getting kitsu meta: ${error.message}`);
|
console.log(`Failed getting kitsu meta: ${error.message}`);
|
||||||
@@ -75,11 +75,6 @@ async function enrichShow(show) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const hardcodedShows = {
|
|
||||||
'199': 'tt2098220',
|
|
||||||
'347': 'tt0388629'
|
|
||||||
};
|
|
||||||
|
|
||||||
async function _parseShowData(showData) {
|
async function _parseShowData(showData) {
|
||||||
console.log(`${NAME}: scrapping ${showData.title} data...`);
|
console.log(`${NAME}: scrapping ${showData.title} data...`);
|
||||||
const imdbId = hardcodedShows[showData.showId] || await getImdbId({
|
const imdbId = hardcodedShows[showData.showId] || await getImdbId({
|
||||||
|
|||||||
Reference in New Issue
Block a user